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