Source for file Constraint.class.php
Documentation is available at Constraint.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @desc Input Constraint Class
gumbo_load ("Interface_Constraint");
/** @var string|array$_method */
/** @var array $_cases extra arguments to pass */
* Constructor (extra arguments are the various Case parameters)
* @param string $func function/method name
* @param string|StdClass$cls class name or object
* @param int $key location to place data in argument of function/method
public function __construct ($func=
null, $cls=
null, $key=
0) {
* Tests the Constraint, returning either boolean or formatted data
public function test ($data) {
foreach ($this->getCases () as $key=>
$val) {
if ($key ===
$this->getKey ()) {
* Adds a Case to the Constraint Method (accepts additional arguments)
* Resets all Case Argument
* @postcondition !getCases()
* Sets the Function|Method
* @param string|StdClass$obj
* @throws Gumbo_Exception
public function setMethod ($func, $obj=
null) {
$func =
array ($obj, $func);
$e->setFunction (__METHOD__
);
* Sets the Key, which indicates the location the 'data' argument should be placed (starts at 0 for 1st position)
public function setKey ($key) {
$this->_key = (int)
$key;
$e->setFunction (__METHOD__
);
* Returns the Function|Method
* Returns the Case Arguments (extra parameters sent to the function)