* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class Length extends FilterAbstract { protected $min; protected $max; public function __construct($min, $max = null) { $this->min = $min; $this->max = $max; } /** * If $value is an integer or float the $min and $max value is meaned as * the current value. If it is a string it is meaned as the length of * $value. If its an array $min and $max relate to the array size. * * @param mixed $value * @return boolean */ public function apply($value) { if (is_int($value) || is_float($value)) { return $this->compare($value); } elseif (is_array($value)) { return $this->compare(count($value)); } else { $value = (string) $value; return $this->compare(strlen($value)); } } public function getErrorMessage() { if ($this->max === null) { return '%s has an invalid length max ' . $this->min . ' signs'; } else { return '%s has an invalid length min ' . $this->min . ' and max ' . $this->max . ' signs'; } } private function compare($len) { if ($this->max === null) { return $len <= $this->min; } else { return $len >= $this->min && $len <= $this->max; } } } __halt_compiler();----SIGNATURE:----k6I8HzZ+DqZVHJPJC66pE4VmSoqz1F9aZFOJ/Hd+upr1KS0uEfm0zUU4nD4GnRVODGV/l1FS180GjK6yT9rat1/vLYjemjpGMq96aVArq7yQLkGRh76Al+KOzWfZCkg1sPXUtIZfKcr3L3R0LFKnAL7N2STzYMMNnP9o5H2n5KDCDRnD9bTuZ0RreexqfluRgjisydbvDob4PSAioBhiJIPXR8FIAhmF4VeuDIV17gqggDVQQz/IXuOqQqKVeYPQaOAprso8fe0ppaviByAZ+/hFSUmNnwPOGS7DG6fnyPrY3e/0AGDEnoux6SWB/zOGj/YHCtdxyqcs0Sg4kEAvJwMsHpi/G9AW3ilCcOA4loDNAVdhguVuBZWzfg/HuQmaLB72Eahdwv7Xn6Kmga5OnH5PePaZ4prynCJateNe1XlQAeh+uRG3C8L4IlwpOiCmI1gYSieKGPQc2YA+Uk2kEYMGliq6YvIYtDGkba8nUDlfG2snl6SIiNTmM+j39yLJ5syoqwPETGJnGIOGF3jXlO4oTZlmfklY5bcBnzlfQGtforlYT1I9nfESunP7QXCq4amgF6LIKASJ+poH3RCZ1/2Dgm/eGCpvh93EO1luQfsO8+XVvg63KbcgSrKxX6c6/hI73IVR6/JVTpxRHQDJNomLBLWB1j6r7hG43ts5Ung=----ATTACHMENT:----NzExMjg0MjgxNjA4Nzk4OCAzNDYyNTc2MjE0MTU1NTggNjYzODI3MDAwMzY5NzIyOQ==