. */ require_once 'phing/tasks/system/condition/Condition.php'; /** * A simple string comparator. Compares two strings for eqiality in a * binary safe manner. Implements the condition interface specification. * * @author Andreas Aderhold * @copyright © 2001,2002 THYRELL. All rights reserved * @version $Revision: 905 $ $Date: 2010-10-05 18:28:03 +0200 (Tue, 05 Oct 2010) $ * @access public * @package phing.tasks.system.condition */ class EqualsCondition implements Condition { private $arg1; private $arg2; private $trim = false; private $caseSensitive = true; public function setArg1($a1) { $this->arg1 = $a1; } public function setArg2($a2) { $this->arg2 = $a2; } /** * Should we want to trim the arguments before comparing them? * @param boolean $b */ public function setTrim($b) { $this->trim = (boolean) $b; } /** * Should the comparison be case sensitive? * @param boolean $b */ public function setCaseSensitive($b) { $this->caseSensitive = (boolean) $b; } public function evaluate() { if ($this->arg1 === null || $this->arg2 === null) { throw new BuildException("Both arg1 and arg2 are required in equals."); } if ($this->trim) { $this->arg1 = trim($this->arg1); $this->arg2 = trim($this->arg2); } //print("[comparison] Comparing '".$this->arg1."' and '".$this->arg2."'\n"); return $this->caseSensitive ? $this->arg1 === $this->arg2 : strtolower($this->arg1) === strtolower($this->arg2); } }