pax_global_header00006660000000000000000000000064120563530720014515gustar00rootroot0000000000000052 comment=2d121194b8a2c33d00e208eaf134546bbad95881 php-horde-constraint-2.0.1/000077500000000000000000000000001205635307200155655ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/000077500000000000000000000000001205635307200214665ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/doc/000077500000000000000000000000001205635307200222335ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/doc/Horde/000077500000000000000000000000001205635307200232745ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/doc/Horde/Constraint/000077500000000000000000000000001205635307200254205ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/doc/Horde/Constraint/COPYING000066400000000000000000000024301205635307200264520ustar00rootroot00000000000000 Copyright 1999-2012 Horde LLC. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HORDE PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/000077500000000000000000000000001205635307200222345ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/000077500000000000000000000000001205635307200232755ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint.php000066400000000000000000000002421205635307200261300ustar00rootroot00000000000000 */ interface Horde_Constraint { public function evaluate($value); } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/000077500000000000000000000000001205635307200254215ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/AlwaysFalse.php000066400000000000000000000003411205635307200303430ustar00rootroot00000000000000 */ class Horde_Constraint_AlwaysFalse implements Horde_Constraint { public function evaluate($value) { return false; } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/AlwaysTrue.php000066400000000000000000000003361205635307200302340ustar00rootroot00000000000000 */ class Horde_Constraint_AlwaysTrue implements Horde_Constraint { public function evaluate($value) { return true; } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/And.php000066400000000000000000000007501205635307200266360ustar00rootroot00000000000000 */ class Horde_Constraint_And extends Horde_Constraint_Coupler { public function evaluate($value) { foreach ($this->_constraints as $c) { if (!$c->evaluate($value)) { return false; } } return true; } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/Coupler.php000066400000000000000000000017751205635307200275550ustar00rootroot00000000000000 */ abstract class Horde_Constraint_Coupler implements Horde_Constraint { protected $_constraints = array(); public function __construct() { $constraints = func_get_args(); foreach ($constraints as $c) { if (! $c instanceof Horde_Constraint) { throw new IllegalArgumentException("$c does not implement Horde_Constraint"); } $this->addConstraint($c); } } public function addConstraint(Horde_Constraint $constraint) { $kind = get_class($this); if ($constraint instanceof $kind) { foreach ($constraint->getConstraints() as $c) { $this->addConstraint($c); } } else { $this->_constraints[] = $constraint; } return $this; } public function getConstraints() { return $this->_constraints; } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/IsEqual.php000066400000000000000000000006151205635307200274770ustar00rootroot00000000000000 */ class Horde_Constraint_IsEqual implements Horde_Constraint { private $_value; public function __construct($value) { $this->_value = $value; } public function evaluate($value) { return $this->_value == $value; } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/IsInstanceOf.php000066400000000000000000000006501205635307200304600ustar00rootroot00000000000000 */ class Horde_Constraint_IsInstanceOf implements Horde_Constraint { private $_type; public function __construct($type) { $this->_type = $type; } public function evaluate($value) { return $value instanceof $this->_type; } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/Not.php000066400000000000000000000006771205635307200267040ustar00rootroot00000000000000 */ class Horde_Constraint_Not implements Horde_Constraint { private $_constraint; public function __construct(Horde_Constraint $constraint) { $this->_constraint = $constraint; } public function evaluate($value) { return !$this->_constraint->evaluate($value); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/Null.php000066400000000000000000000004341205635307200270450ustar00rootroot00000000000000 */ class Horde_Constraint_Null implements Horde_Constraint { public function evaluate($value) { return is_null($value); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/Or.php000066400000000000000000000007371205635307200265210ustar00rootroot00000000000000 * @author Chuck Hagenbuch */ class Horde_Constraint_Or extends Horde_Constraint_Coupler { public function evaluate($value) { foreach ($this->_constraints as $c) { if ($c->evaluate($value)) { return true; } } return false; } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/lib/Horde/Constraint/PregMatch.php000066400000000000000000000006501205635307200300050ustar00rootroot00000000000000 */ class Horde_Constraint_PregMatch implements Horde_Constraint { private $_regex; public function __construct($regex) { $this->_regex = $regex; } public function evaluate($value) { return preg_match($this->_regex, $value) > 0; } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/000077500000000000000000000000001205635307200224455ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/000077500000000000000000000000001205635307200235065ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/000077500000000000000000000000001205635307200256325ustar00rootroot00000000000000php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/AllTests.php000066400000000000000000000001321205635307200300720ustar00rootroot00000000000000run(); php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/AlwaysFalseTest.php000066400000000000000000000007731205635307200314250ustar00rootroot00000000000000assertFalse($const->evaluate($value)); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/AlwaysTrueTest.php000066400000000000000000000007671205635307200313150ustar00rootroot00000000000000assertTrue($const->evaluate($value)); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/AndTest.php000066400000000000000000000040371205635307200277110ustar00rootroot00000000000000assertFalse($and->evaluate('test_string')); } public function testAndEvaluatesFalseWhenBothConstraintsAreFalse() { $c1 = new Horde_Constraint_AlwaysFalse(); $c2 = new Horde_Constraint_AlwaysFalse(); $and = new Horde_Constraint_And($c1, $c2); $this->assertFalse($and->evaluate('test_string')); } public function testAndEvaluatesTrueWhenBothConstraintsAreTrue() { $c1 = new Horde_Constraint_AlwaysTrue(); $c2 = new Horde_Constraint_AlwaysTrue(); $and = new Horde_Constraint_And($c1, $c2); $this->assertTrue($and->evaluate('test_string')); } public function testAndEvaluatesFalseWhenFalseConstraintIsAddedViaSetter() { $c1 = new Horde_Constraint_AlwaysTrue(); $c2 = new Horde_Constraint_AlwaysTrue(); $and = new Horde_Constraint_And($c1, $c2); $and->addConstraint(new Horde_Constraint_AlwaysFalse()); $this->assertFalse($and->evaluate('test_string')); } public function testAndaddConstraintReturnsAndConstraint() { $c1 = new Horde_Constraint_AlwaysTrue(); $c2 = new Horde_Constraint_AlwaysTrue(); $and = new Horde_Constraint_And($c1, $c2); $returnConst = $and->addConstraint(new Horde_Constraint_AlwaysFalse()); $this->assertInstanceOf('Horde_Constraint_And', $returnConst); } public function testReturnedAndEvaluatesFalseWhenFalseConstraintIsAddedViaSetter() { $c1 = new Horde_Constraint_AlwaysTrue(); $c2 = new Horde_Constraint_AlwaysTrue(); $and = new Horde_Constraint_And($c1, $c2); $and = $and->addConstraint(new Horde_Constraint_AlwaysFalse()); $this->assertFalse($and->evaluate('test_string')); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/IsInstanceOfTest.php000066400000000000000000000010421205635307200315250ustar00rootroot00000000000000assertFalse($const->evaluate($foo)); } public function testConstraintReturnsTrueWhenInstanceIsCorrectClass() { $foo = new StdClass(); $const = new Horde_Constraint_IsInstanceOf('StdClass'); $this->assertTrue($const->evaluate($foo)); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/NotTest.php000066400000000000000000000007041205635307200277440ustar00rootroot00000000000000assertTrue($not->evaluate('foo')); } public function testNotMakesTrueConstraintFalse() { $not = new Horde_Constraint_Not(new Horde_Constraint_AlwaysTrue()); $this->assertFalse($not->evaluate('foo')); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/NullTest.php000066400000000000000000000006421205635307200301170ustar00rootroot00000000000000assertTrue($const->evaluate(null)); } public function testNullReturnsFalseWhenValue_IsNot_Null() { $const = new Horde_Constraint_Null(); $this->assertFalse($const->evaluate('not null value')); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/OrTest.php000066400000000000000000000037561205635307200275760ustar00rootroot00000000000000assertTrue($or->evaluate('test_string')); } public function testOrEvaluatesFalseWhenBothConstraintsAreFalse() { $c1 = new Horde_Constraint_AlwaysFalse(); $c2 = new Horde_Constraint_AlwaysFalse(); $or = new Horde_Constraint_Or($c1, $c2); $this->assertFalse($or->evaluate('test_string')); } public function testOrEvaluatesTrueWhenBothConstraintsAreTrue() { $c1 = new Horde_Constraint_AlwaysTrue(); $c2 = new Horde_Constraint_AlwaysTrue(); $or = new Horde_Constraint_Or($c1, $c2); $this->assertTrue($or->evaluate('test_string')); } public function testOrEvaluatesTrueWhenTrueConstraintIsAddedViaSetter() { $c1 = new Horde_Constraint_AlwaysFalse(); $c2 = new Horde_Constraint_AlwaysFalse(); $or = new Horde_Constraint_Or($c1, $c2); $or->addConstraint(new Horde_Constraint_AlwaysTrue()); $this->assertTrue($or->evaluate('test_string')); } public function testOraddConstraintReturnsOrConstraint() { $c1 = new Horde_Constraint_AlwaysTrue(); $c2 = new Horde_Constraint_AlwaysTrue(); $or = new Horde_Constraint_Or($c1, $c2); $returnConst = $or->addConstraint(new Horde_Constraint_AlwaysFalse()); $this->assertInstanceOf('Horde_Constraint_Or', $returnConst); } public function testReturnedOrEvaluatesTrueWhenTrueConstraintIsAddedViaSetter() { $c1 = new Horde_Constraint_AlwaysFalse(); $c2 = new Horde_Constraint_AlwaysFalse(); $or = new Horde_Constraint_Or($c1, $c2); $or = $or->addConstraint(new Horde_Constraint_AlwaysTrue()); $this->assertTrue($or->evaluate('test_string')); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/PregMatchTest.php000066400000000000000000000007301205635307200310550ustar00rootroot00000000000000assertTrue($preg->evaluate('somestring')); } public function testPregReturnsFalseWhenRegex_DoesNot_Match() { $preg = new Horde_Constraint_PregMatch('/somestring/'); $this->assertFalse($preg->evaluate('some other string')); } } php-horde-constraint-2.0.1/Horde_Constraint-2.0.1/test/Horde/Constraint/bootstrap.php000066400000000000000000000001431205635307200303560ustar00rootroot00000000000000 php-horde-constraint-2.0.1/package.xml000066400000000000000000000234661205635307200177150ustar00rootroot00000000000000 Horde_Constraint pear.horde.org Horde Constraint library A programmatic way of building constraints that evaluate to true or false. Chuck Hagenbuch chuck chuck@horde.org yes 2012-11-19 2.0.1 1.0.0 stable stable BSD-2-Clause * [mms] Use new Horde_Test layout. 5.3.0 1.7.0 Horde_Test pear.horde.org 2.1.0 3.0.0alpha1 3.0.0alpha1 1.0.0alpha1 1.0.0 alpha alpha 2011-03-08 BSD-2-Clause * First alpha release for Horde 4. 1.0.0beta1 1.0.0 beta beta 2011-03-16 BSD-2-Clause * First beta release for Horde 4. 1.0.0RC1 1.0.0 beta beta 2011-03-22 BSD-2-Clause * First release candidate for Horde 4. 1.0.0RC2 1.0.0 beta beta 2011-03-29 BSD-2-Clause * Second release candidate for Horde 4. 1.0.0 1.0.0 stable stable 2011-04-06 BSD-2-Clause * First stable release for Horde 4. 1.0.1 1.0.0 stable stable 2011-11-22 BSD-2-Clause * [jan] Fix tests to work with PHPUnit 3.6. 2.0.0alpha1 1.0.0 alpha stable 2012-07-05 BSD-2-Clause * First alpha release for Horde 5. 2.0.0beta1 1.0.0 beta stable 2012-07-19 BSD-2-Clause * First beta release for Horde 5. 2.0.0 1.0.0 stable stable 2012-10-30 BSD-2-Clause * First stable release for Horde 5. 2.0.1 1.0.0 stable stable 2012-11-19 BSD-2-Clause * [mms] Use new Horde_Test layout.