Polldaddy.php
| 1 | <?php |
| 2 | /** |
| 3 | * Polldaddy.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 | * Polldaddy Provider |
| 19 | * Create flexible surveys, polls, quizzes and ratings with Crowdsignal. |
| 20 | * |
| 21 | * @link https://polldaddy.com |
| 22 | * |
| 23 | */ |
| 24 | class Polldaddy extends ProviderAdapter implements ProviderInterface |
| 25 | { |
| 26 | /** inline {@inheritdoc} */ |
| 27 | protected $endpoint = 'https://api.crowdsignal.com/oembed?format=json'; |
| 28 | |
| 29 | /** inline {@inheritdoc} */ |
| 30 | protected static $hosts = [ |
| 31 | '*.poll.fm', |
| 32 | '*.survey.fm', |
| 33 | ]; |
| 34 | |
| 35 | /** inline {@inheritdoc} */ |
| 36 | protected $httpsSupport = true; |
| 37 | |
| 38 | /** inline {@inheritdoc} */ |
| 39 | protected $responsiveSupport = true; |
| 40 | |
| 41 | /** inline {@inheritdoc} */ |
| 42 | public function validateUrl(Url $url) |
| 43 | { |
| 44 | return (bool) ( |
| 45 | preg_match('~polldaddy\.com/(?:poll|s|ratings)/(?:[^/]+)/?$~i', (string) $url) || |
| 46 | preg_match('~(?:poll|survey)\.fm/([^/]+)~i', (string) $url) |
| 47 | ); |
| 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 |