Tumblr.php
| 1 | <?php |
| 2 | /** |
| 3 | * Tumbl.php |
| 4 | * |
| 5 | * @package Embera |
| 6 | * @author Michael Pratt <yo@michael-pratt.com> |
| 7 | * @link http://www.michael-pratt.com/ |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | |
| 13 | namespace Embera\Provider; |
| 14 | |
| 15 | use Embera\Url; |
| 16 | |
| 17 | /** |
| 18 | * Tumbl Provider |
| 19 | * @link https://*.tumblr.com |
| 20 | */ |
| 21 | class Tumblr extends ProviderAdapter implements ProviderInterface |
| 22 | { |
| 23 | /** inline {@inheritdoc} */ |
| 24 | protected $endpoint = 'https://www.tumblr.com/oembed/1.0?format=json'; |
| 25 | |
| 26 | /** inline {@inheritdoc} */ |
| 27 | protected static $hosts = [ |
| 28 | '*.tumblr.com' |
| 29 | ]; |
| 30 | |
| 31 | /** inline {@inheritdoc} */ |
| 32 | protected $allowedParams = [ 'maxwidth', 'maxheight' ]; |
| 33 | |
| 34 | /** inline {@inheritdoc} */ |
| 35 | protected $httpsSupport = true; |
| 36 | |
| 37 | /** inline {@inheritdoc} */ |
| 38 | protected $responsiveSupport = false; |
| 39 | |
| 40 | /** inline {@inheritdoc} */ |
| 41 | public function validateUrl(Url $url) |
| 42 | { |
| 43 | return (bool) (preg_match('~tumblr\.com/post/([^/]+)~i', (string) $url)); |
| 44 | } |
| 45 | |
| 46 | /** inline {@inheritdoc} */ |
| 47 | public function normalizeUrl(Url $url) |
| 48 | { |
| 49 | $url->convertToHttps(); |
| 50 | $url->removeQueryString(); |
| 51 | $url->removeLastSlash(); |
| 52 | |
| 53 | return $url; |
| 54 | } |
| 55 | |
| 56 | } |
| 57 |