Your IP : 216.73.216.240


Current Path : /home/juvelize/www/plugins/content/osembed/library/mpratt/embera/src/Embera/Provider/
Upload File :
Current File : /home/juvelize/www/plugins/content/osembed/library/mpratt/embera/src/Embera/Provider/Namchey.php

<?php
/**
 * Namchey.php
 *
 * @package Embera
 * @author Michael Pratt <yo@michael-pratt.com>
 * @link   http://www.michael-pratt.com/
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Embera\Provider;

use Embera\Url;

/**
 * Namchey Provider
 * Share your travel experience in visual form that would be easier for others to know how the exp...
 *
 * @link https://namchey.com
 * @see https://help.namchey.com/app/oembed
 */
class Namchey extends ProviderAdapter implements ProviderInterface
{
    /** inline {@inheritdoc} */
    protected $endpoint = 'https://namchey.com/api/oembed?format=json';

    /** inline {@inheritdoc} */
    protected static $hosts = [
        'namchey.com'
    ];

    /** inline {@inheritdoc} */
    protected $httpsSupport = true;

    /** inline {@inheritdoc} */
    protected $responsiveSupport = true;

    /** inline {@inheritdoc} */
    public function validateUrl(Url $url)
    {
        return (bool) (preg_match('~namchey\.com/itineraries/([^/]+)$~i', (string) $url));
    }

    /** inline {@inheritdoc} */
    public function normalizeUrl(Url $url)
    {
        $url->convertToHttps();
        $url->removeQueryString();
        $url->removeLastSlash();

        return $url;
    }

    /** inline {@inheritdoc} */
    public function getFakeResponse()
    {
        $embedUrl = str_replace('/itineraries/', '/embeds/itineraries/', $this->url);

        $attr = [];
        $attr[] = 'width="100%"';
        $attr[] = 'height="{height}"';
        $attr[] = 'src="' . $embedUrl . '"';
        $attr[] = 'frameborder="0"';
        $attr[] = 'allowfullscreen';

        return [
            'type' => 'rich',
            'provider_name' => 'Namchey',
            'provider_url' => 'https://namchey.com',
            'title' => 'Unknown title',
            'html' => '<iframe ' . implode(' ', $attr). '></iframe>',
        ];
    }

}