<?php

/**
 * Video
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 * 
 * @package    sf
 * @subpackage model
 * @author     Atma
 * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
 */
class Video extends BaseVideo
{
    static public function getYoutubeCode($url)
    {
        $code = '';
        if($url){
            foreach (array("/watch\?v=(.[^?]*)/i", "/youtu.be\/(.[^?]*)/i") as $pattern){
                if(preg_match($pattern, $url, $matches)){
                    if(isset($matches[1])){
                        $code = $matches[1];
                        break;
                    }
                }
            }
        }
        return $code;
    }
}
