12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace Cube\Validate;
- class InArray extends AbstractValidate
- {
- protected $_message = "'%s' was not found in the haystack.";
-
- protected $_haystack = array();
-
- public function __construct(array $haystack = null)
- {
- if ($haystack !== null) {
- $this->setHaystack($haystack);
- }
- }
-
- public function getHaystack()
- {
- return $this->_haystack;
- }
-
- public function setHaystack(array $haystack)
- {
- $this->_haystack = $haystack;
- return $this;
- }
-
- public function isValid()
- {
- if (!in_array($this->_value, $this->_haystack)) {
- return false;
- }
- return true;
- }
- }
|