Docswell.php
| 1 | <?php |
| 2 | /** |
| 3 | * Docswell.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 | * Docswell Provider |
| 19 | * |
| 20 | * @link https://docswell.com |
| 21 | */ |
| 22 | class Docswell extends ProviderAdapter implements ProviderInterface |
| 23 | { |
| 24 | /** inline {@inheritdoc} */ |
| 25 | protected $endpoint = 'https://www.docswell.com/service/oembed?format=json'; |
| 26 | |
| 27 | /** inline {@inheritdoc} */ |
| 28 | protected static $hosts = [ |
| 29 | 'docswell.com' |
| 30 | ]; |
| 31 | |
| 32 | /** inline {@inheritdoc} */ |
| 33 | protected $allowedParams = [ 'maxwidth', 'maxheight' ]; |
| 34 | |
| 35 | /** inline {@inheritdoc} */ |
| 36 | protected $httpsSupport = true; |
| 37 | |
| 38 | /** inline {@inheritdoc} */ |
| 39 | protected $responsiveSupport = false; |
| 40 | |
| 41 | /** inline {@inheritdoc} */ |
| 42 | public function validateUrl(Url $url) |
| 43 | { |
| 44 | return (bool) (preg_match('~docswell\.com/s/([^/]+)/([^/]+)~i', (string) $url)); |
| 45 | } |
| 46 | |
| 47 | /** inline {@inheritdoc} */ |
| 48 | public function normalizeUrl(Url $url) |
| 49 | { |
| 50 | $url->convertToHttps(); |
| 51 | $url->removeQueryString(); |
| 52 | $url->removeLastSlash(); |
| 53 | |
| 54 | return $url; |
| 55 | } |
| 56 | |
| 57 | } |
| 58 |