Skip to content
Snippets Groups Projects
Video.php 509 B
Newer Older
Maxime Veber's avatar
Maxime Veber committed
<?php
namespace App\Items;

class Video implements Item
{
    private $url;

    public function __construct($url)
    {
        $this->url = $url;
    }

    public function getWidget()
    {
Maxime Veber's avatar
Maxime Veber committed
        return '<iframe width="100%" height="400" src="//www.youtube.com/embed/' . $this->getId() . '" frameborder="0" allowfullscreen></iframe>';;
    }

    public function getId()
    {
        preg_match('/^https:\/\/www\.youtube\.com\/watch\?v=(.*)/', $this->url, $matches);

        return $matches[1];
Maxime Veber's avatar
Maxime Veber committed
    }
}