library/Garp/Model/Behavior/YouTubeable.php
protected function _getId($watchUrl) {
        $query = array();
        if (!$watchUrl) {
            throw new Garp_Model_Behavior_YouTubeable_Exception_NoUrl(self::EXCEPTION_NO_URL);
        }

        $url = parse_url($watchUrl);
        if (empty($url['query']) && $url['host'] == 'youtu.be') {
            $videoId = substr($url['path'], 1);
        } elseif (isset($url['query'])) {
            parse_str($url['query'], $query);
            if (isset($query['v']) && $query['v']) {
                $videoId = $query['v'];
            }
        }

        if (!isset($videoId)) {
            throw new Garp_Model_Behavior_YouTubeable_Exception_InvalidUrl(
                sprintf(self::EXCEPTION_INVALID_YOUTUBE_URL, $watchUrl)
            );
        }
        return $videoId;
    }
protected function _getId($watchUrl) {
        $query = array();
        if (!$watchUrl) {
            throw new Garp_Model_Behavior_YouTubeable_Exception_NoUrl(self::EXCEPTION_NO_URL);
        }

        $url = parse_url($watchUrl);
        if (empty($url['query']) && $url['host'] == 'youtu.be') {
            $videoId = substr($url['path'], 1);
        } elseif (isset($url['query'])) {
            parse_str($url['query'], $query);
            if (isset($query['v']) && $query['v']) {
                $videoId = $query['v'];
            }
        }

        if (!isset($videoId)) {
            throw new Garp_Model_Behavior_YouTubeable_Exception_InvalidUrl(
                sprintf(self::EXCEPTION_INVALID_YOUTUBE_URL, $watchUrl)
            );
        }
        return $videoId;
    }
protected function _getId ( $ watchUrl ) { $ query = array ( ) ; if ( ! $ watchUrl ) { throw new Garp_Model_Behavior_YouTubeable_Exception_NoUrl ( self :: EXCEPTION_NO_URL ) ; } $ url = parse_url ( $ watchUrl ) ; if ( empty ( $ url [ 'query' ] ) && $ url [ 'host' ] == 'youtu.be' ) { $ videoId = substr ( $ url [ 'path' ] , 1 ) ; } elseif ( isset ( $ url [ 'query' ] ) ) { parse_str ( $ url [ 'query' ] , $ query ) ; if ( isset ( $ query [ 'v' ] ) && $ query [ 'v' ] ) { $ videoId = $ query [ 'v' ] ; } } if ( ! isset ( $ videoId ) ) { throw new Garp_Model_Behavior_YouTubeable_Exception_InvalidUrl ( sprintf ( self :: EXCEPTION_INVALID_YOUTUBE_URL , $ watchUrl ) ) ; } return $ videoId ; }
Retrieves the id value of a YouTube url.

@param string $watchUrl
@return string
Retrieves the id value of a YouTube url .