<?php
/*
 * Copyright (c) 2010, webvariants GbR, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

class WV_Filter_Or extends _WV_Filter_Multi {
	public function __construct() {
		$arguments = func_get_args();
		if (count($arguments) === 1 && is_array($arguments[0])) $arguments = $arguments[0];
		parent::__construct($arguments, 'OR');
	}

	public function optimize(array $filters) {
		foreach ($filters as $idx => $filter) {
			if ($filter === '1' || $filter === 'TRUE') {
				return array('1');
			}

			if ($filter === '0' || $filter === 'FALSE') {
				unset($filters[$idx]);
			}
		}

		return array_values($filters);
	}
}
