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