<commit_before><?php
/**
 * G_View_Helper_Video
 * Generic video helper. Can render YouTube and Vimeo.
 * @author <NAME> | grrr.nl
 * @modifiedby $LastChangedBy: $
 * @version $Revision: $
 * @package Garp
 * @subpackage Helper
 * @lastmodified $Date: $
 */
class G_View_Helper_Video extends Zend_View_Helper_Abstract {
	/**
	 * Render a video player.
	 * @param Garp_Db_Table_Row $video A record from a video table
	 * @param Array $options Various rendering options
	 * @return Mixed
	 */
	public function video($video, array $options = array()) {
		$playerurl = $video instanceof Garp_Db_Table_Row ? $video->player : $video;
		if (preg_match('~player\.vimeo\.com~', $playerurl)) {
			return $this->view->vimeo($video, $options);
		} elseif (preg_match('~youtube\.com~', $playerurl)) {
			return $this->view->youTube($video, $options);
		} else {
			throw new Exception('Unsupported media type detected: '.$playerurl);
		}
	}
}<commit_msg>Changed API a little: provided fluent interface<commit_after><?php
/**
 * G_View_Helper_Video
 * Generic video helper. Can render YouTube and Vimeo.
 * @author <NAME> | grrr.nl
 * @modifiedby $LastChangedBy: $
 * @version $Revision: $
 * @package Garp
 * @subpackage Helper
 * @lastmodified $Date: $
 */
class G_View_Helper_Video extends Zend_View_Helper_Abstract {
	/**
	 * Render a video player.
	 * @param Garp_Db_Table_Row $video A record from a video table
	 * @param Array $options Various rendering options
	 * @return Mixed
	 */
	public function video($video = null, array $options = array()) {
		if (!func_num_args()) {
			// provide fluent interface
			return $this;
		}
		if (!$video) {
			throw new InvalidArgumentException(__METHOD__.' expects parameter 1 to be Garp_Db_Table_Row');
		}
		return $this->render($video, $options);
	}


	/**
 	 * Render a video player.
	 * @param Garp_Db_Table_Row $video A record from a video table
	 * @param Array $options Various rendering options
	 * @return Mixed
 	 */
	public function render($video, $options = array()) {
		$playerurl = $video instanceof Garp_Db_Table_Row ? $video->player : $video;
		if (preg_match('~player\.vimeo\.com~', $playerurl)) {
			return $this->view->vimeo($video, $options);
		} elseif (preg_match('~youtube\.com~', $playerurl)) {
			return $this->view->youTube($video, $options);
		} else {
			throw new Exception('Unsupported media type detected: '.$playerurl);
		}
	}		
}
{'fraction_non_alphanumeric': 0.13981636060100167, 'fraction_numerical': 0.00041736227045075126, 'mean_word_length': 4.177105831533478, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1450747', 'n_tokens_mistral': 827, 'n_tokens_neox': 766, 'n_words': 214}