File tree Expand file tree Collapse file tree 2 files changed +67
-0
lines changed
Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Embed \Providers \OEmbed ;
4+
5+ use Embed \Adapters \Adapter ;
6+ use Embed \Http \Response ;
7+ use Embed \Http \Url ;
8+
9+ class Tumblr extends EndPoint implements EndPointInterface
10+ {
11+ protected static $ pattern = [
12+ '*.tumblr.com/post/* '
13+ ];
14+
15+ protected static $ endPoint = 'https://www.tumblr.com/oembed/1.0 ' ;
16+
17+ /**
18+ * {@inheritdoc}
19+ */
20+ public static function create (Adapter $ adapter )
21+ {
22+ $ response = $ adapter ->getResponse ();
23+ if ($ response ->getStartingUrl ()->match (static ::$ pattern )) {
24+ return new static ($ response );
25+ }
26+ }
27+
28+ /**
29+ * Constructor.
30+ *
31+ * @param Response $response
32+ */
33+ private function __construct (Response $ response )
34+ {
35+ $ this ->response = $ response ;
36+ }
37+
38+ /**
39+ * {@inheritdoc}
40+ */
41+ public function getEndPoint ()
42+ {
43+ return Url::create (static ::$ endPoint )
44+ ->withQueryParameters ([
45+ 'url ' => (string ) $ this ->response ->getStartingUrl ()
46+ ]);
47+ }
48+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Embed \Tests ;
4+
5+ class TumblrTest extends AbstractTestCase
6+ {
7+ public function testOne ()
8+ {
9+ $ this ->assertEmbed (
10+ 'http://he-who-photographs-rather-ok.tumblr.com/post/165326273724 ' ,
11+ [
12+ 'url ' => 'http://he-who-photographs-rather-ok.tumblr.com/post/165326273724 ' ,
13+ 'authorName ' => 'He-who-photographs-rather-OK ' ,
14+ 'authorUrl ' => 'http://he-who-photographs-rather-ok.tumblr.com/ ' ,
15+ 'type ' => 'rich ' ,
16+ ]
17+ );
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments