Skip to content

Commit b6b8529

Browse files
authored
Tumblr provider
1 parent 03a0c0e commit b6b8529

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/Providers/OEmbed/Tumblr.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
}

0 commit comments

Comments
 (0)