ThreeQ.php
| 1 | <?php |
| 2 | /** |
| 3 | * ThreeQ.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 | * ThreeQ Provider |
| 19 | * |
| 20 | * @link https://playout.3qsdn.com |
| 21 | * @see https://docs.3q.video/en/Player_API/Basic_usage.html |
| 22 | */ |
| 23 | class ThreeQ extends ProviderAdapter implements ProviderInterface |
| 24 | { |
| 25 | /** inline {@inheritdoc} */ |
| 26 | protected $endpoint = 'https://playout.3qsdn.com/oembed?format=json'; |
| 27 | |
| 28 | /** inline {@inheritdoc} */ |
| 29 | protected static $hosts = [ |
| 30 | 'playout.3qsdn.com' |
| 31 | ]; |
| 32 | |
| 33 | /** inline {@inheritdoc} */ |
| 34 | protected $allowedParams = [ 'maxwidth', 'maxheight' ]; |
| 35 | |
| 36 | /** inline {@inheritdoc} */ |
| 37 | protected $httpsSupport = true; |
| 38 | |
| 39 | /** inline {@inheritdoc} */ |
| 40 | protected $responsiveSupport = false; |
| 41 | |
| 42 | /** inline {@inheritdoc} */ |
| 43 | public function validateUrl(Url $url) |
| 44 | { |
| 45 | return (bool) (preg_match('~playout\.3qsdn\.com/embed/([^/]+)~i', (string) $url)); |
| 46 | } |
| 47 | |
| 48 | public function getUrl($asString = true) |
| 49 | { |
| 50 | if ($asString) { |
| 51 | preg_match('~/embed/([^/]+)~i', (string) $this->url, $matches); |
| 52 | return $matches[1]; |
| 53 | } |
| 54 | |
| 55 | return $this->url; |
| 56 | } |
| 57 | |
| 58 | /** inline {@inheritdoc} */ |
| 59 | public function normalizeUrl(Url $url) |
| 60 | { |
| 61 | $url->convertToHttps(); |
| 62 | $url->removeQueryString(); |
| 63 | $url->removeLastSlash(); |
| 64 | |
| 65 | return $url; |
| 66 | } |
| 67 | } |
| 68 |