Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 28 changed files with 337 additions and 99 deletions.
8 changes: 4 additions & 4 deletions src/AbstractValidator.php
Expand Up @@ -41,7 +41,7 @@ abstract class AbstractValidator implements
/**
* Limits the maximum returned length of a error message
*
* @var Integer
* @var int
*/
protected static $messageLength = -1;

Expand Down Expand Up @@ -159,7 +159,7 @@ public function setOptions($options = array())
*/
public function getMessages()
{
return $this->abstractOptions['messages'];
return array_unique($this->abstractOptions['messages']);
}

/**
Expand Down Expand Up @@ -547,7 +547,7 @@ public function isTranslatorEnabled()
/**
* Returns the maximum allowed message length
*
* @return integer
* @return int
*/
public static function getMessageLength()
{
Expand All @@ -557,7 +557,7 @@ public static function getMessageLength()
/**
* Sets the maximum allowed message length
*
* @param integer $length
* @param int $length
*/
public static function setMessageLength($length = -1)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Barcode/AbstractAdapter.php
Expand Up @@ -124,7 +124,7 @@ public function getLength()
/**
* Returns the allowed characters
*
* @return integer|string|array
* @return int|string|array
*/
public function getCharacters()
{
Expand Down Expand Up @@ -183,7 +183,7 @@ protected function setLength($length)
/**
* Sets the allowed characters of this barcode
*
* @param integer $characters
* @param int $characters
* @return AbstractAdapter
*/
protected function setCharacters($characters)
Expand Down
2 changes: 1 addition & 1 deletion src/Barcode/AdapterInterface.php
Expand Up @@ -45,7 +45,7 @@ public function getLength();
/**
* Returns the allowed characters
*
* @return integer|string|array
* @return int|string|array
*/
public function getCharacters();

Expand Down
6 changes: 3 additions & 3 deletions src/Barcode/Code128.php
Expand Up @@ -9,9 +9,9 @@

namespace Zend\Validator\Barcode;

use Zend\Validator\Exception;
use Zend\Stdlib\StringUtils;
use Zend\Stdlib\StringWrapper\StringWrapperInterface;
use Zend\Validator\Exception;

class Code128 extends AbstractAdapter
{
Expand Down Expand Up @@ -345,7 +345,7 @@ protected function getCodingSet($value)
*
* @param string $value
* @param string $set
* @return integer
* @return int
*/
protected function ord128($value, $set)
{
Expand Down Expand Up @@ -406,7 +406,7 @@ protected function ord128($value, $set)
* "00" to "99" == 0 to 99
* 132 to 138 == 100 to 106
*
* @param integer $value
* @param int $value
* @param string $set
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Barcode/Identcode.php
Expand Up @@ -13,7 +13,7 @@ class Identcode extends AbstractAdapter
{
/**
* Allowed barcode lengths
* @var integer
* @var int
*/
protected $length = 12;

Expand Down
3 changes: 2 additions & 1 deletion src/CreditCard.php
Expand Up @@ -110,7 +110,8 @@ class CreditCard extends AbstractValidator
'649', '65'),
self::JCB => array('3528', '3529', '353', '354', '355', '356', '357', '358'),
self::LASER => array('6304', '6706', '6771', '6709'),
self::MAESTRO => array('5018', '5020', '5038', '6304', '6759', '6761', '6763'),
self::MAESTRO => array('5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763',
'6764', '6765', '6766'),
self::MASTERCARD => array('51', '52', '53', '54', '55'),
self::SOLO => array('6334', '6767'),
self::UNIONPAY => array('622126', '622127', '622128', '622129', '62213', '62214',
Expand Down
10 changes: 5 additions & 5 deletions src/DateStep.php
Expand Up @@ -30,7 +30,7 @@ class DateStep extends Date
/**
* Optional base date value
*
* @var string|integer|\DateTime
* @var string|int|\DateTime
*/
protected $baseValue = '1970-01-01T00:00:00Z';

Expand Down Expand Up @@ -105,7 +105,7 @@ public function __construct($options = array())
/**
* Sets the base value from which the step should be computed
*
* @param string|integer|\DateTime $baseValue
* @param string|int|\DateTime $baseValue
* @return DateStep
*/
public function setBaseValue($baseValue)
Expand All @@ -117,7 +117,7 @@ public function setBaseValue($baseValue)
/**
* Returns the base value from which the step should be computed
*
* @return string|integer|\DateTime
* @return string|int|\DateTime
*/
public function getBaseValue()
{
Expand Down Expand Up @@ -171,7 +171,7 @@ public function setTimezone(DateTimeZone $timezone)
/**
* Converts an int or string to a DateTime object
*
* @param string|integer|\DateTime $param
* @param string|int|\DateTime $param
* @return \DateTime
* @throws Exception\InvalidArgumentException
*/
Expand Down Expand Up @@ -204,7 +204,7 @@ protected function convertToDateTime($param)
/**
* Returns true if a date is within a valid step
*
* @param string|integer|\DateTime $value
* @param string|int|\DateTime $value
* @return bool
* @throws Exception\InvalidArgumentException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Db/AbstractDb.php
Expand Up @@ -12,8 +12,8 @@
use Traversable;
use Zend\Db\Adapter\Adapter as DbAdapter;
use Zend\Db\Adapter\Driver\DriverInterface as DbDriverInterface;
use Zend\Db\Sql\Sql;
use Zend\Db\Sql\Select;
use Zend\Db\Sql\Sql;
use Zend\Db\Sql\TableIdentifier;
use Zend\Stdlib\ArrayUtils;
use Zend\Validator\AbstractValidator;
Expand Down
4 changes: 2 additions & 2 deletions src/EmailAddress.php
Expand Up @@ -157,7 +157,7 @@ public function setHostnameValidator(Hostname $hostnameValidator = null)
/**
* Returns the allow option of the attached hostname validator
*
* @return integer
* @return int
*/
public function getAllow()
{
Expand All @@ -167,7 +167,7 @@ public function getAllow()
/**
* Sets the allow option of the hostname validator to use
*
* @param integer $allow
* @param int $allow
* @return EmailAddress Provides a fluent interface
*/
public function setAllow($allow)
Expand Down
50 changes: 47 additions & 3 deletions src/Explode.php
Expand Up @@ -12,10 +12,12 @@
use Traversable;
use Zend\Stdlib\ArrayUtils;

class Explode extends AbstractValidator
class Explode extends AbstractValidator implements ValidatorPluginManagerAwareInterface
{
const INVALID = 'explodeInvalid';

protected $pluginManager;

/**
* @var array
*/
Expand Down Expand Up @@ -65,14 +67,56 @@ public function getValueDelimiter()
return $this->valueDelimiter;
}

/**
* Set validator plugin manager
*
* @param ValidatorPluginManager $pluginManager
*/
public function setValidatorPluginManager(ValidatorPluginManager $pluginManager)
{
$this->pluginManager = $pluginManager;
}

/**
* Get validator plugin manager
*
* @return ValidatorPluginManager
*/
public function getValidatorPluginManager()
{
if (!$this->pluginManager) {
$this->setValidatorPluginManager(new ValidatorPluginManager());
}

return $this->pluginManager;
}

/**
* Sets the Validator for validating each value
*
* @param ValidatorInterface $validator
* @param ValidatorInterface|array $validator
* @throws Exception\RuntimeException
* @return Explode
*/
public function setValidator(ValidatorInterface $validator)
public function setValidator($validator)
{
if (is_array($validator)) {
if (!isset($validator['name'])) {
throw new Exception\RuntimeException(
'Invalid validator specification provided; does not include "name" key'
);
}
$name = $validator['name'];
$options = isset($validator['options']) ? $validator['options'] : array();
$validator = $this->getValidatorPluginManager()->get($name, $options);
}

if (!$validator instanceof ValidatorInterface) {
throw new Exception\RuntimeException(
'Invalid validator given'
);
}

$this->validator = $validator;
return $this;
}
Expand Down
16 changes: 8 additions & 8 deletions src/File/Count.php
Expand Up @@ -45,7 +45,7 @@ class Count extends AbstractValidator
/**
* Actual filecount
*
* @var integer
* @var int
*/
protected $count;

Expand Down Expand Up @@ -76,7 +76,7 @@ class Count extends AbstractValidator
* 'min': Minimum filecount
* 'max': Maximum filecount
*
* @param integer|array|\Traversable $options Options for the adapter
* @param int|array|\Traversable $options Options for the adapter
*/
public function __construct($options = null)
{
Expand All @@ -95,7 +95,7 @@ public function __construct($options = null)
/**
* Returns the minimum file count
*
* @return integer
* @return int
*/
public function getMin()
{
Expand All @@ -105,7 +105,7 @@ public function getMin()
/**
* Sets the minimum file count
*
* @param integer|array $min The minimum file count
* @param int|array $min The minimum file count
* @return Count Provides a fluent interface
* @throws Exception\InvalidArgumentException When min is greater than max
*/
Expand All @@ -119,7 +119,7 @@ public function setMin($min)
throw new Exception\InvalidArgumentException('Invalid options to validator provided');
}

$min = (integer) $min;
$min = (int) $min;
if (($this->getMax() !== null) && ($min > $this->getMax())) {
throw new Exception\InvalidArgumentException("The minimum must be less than or equal to the maximum file count, but $min >"
. " {$this->getMax()}");
Expand All @@ -132,7 +132,7 @@ public function setMin($min)
/**
* Returns the maximum file count
*
* @return integer
* @return int
*/
public function getMax()
{
Expand All @@ -142,7 +142,7 @@ public function getMax()
/**
* Sets the maximum file count
*
* @param integer|array $max The maximum file count
* @param int|array $max The maximum file count
* @return Count Provides a fluent interface
* @throws Exception\InvalidArgumentException When max is smaller than min
*/
Expand All @@ -156,7 +156,7 @@ public function setMax($max)
throw new Exception\InvalidArgumentException('Invalid options to validator provided');
}

$max = (integer) $max;
$max = (int) $max;
if (($this->getMin() !== null) && ($max < $this->getMin())) {
throw new Exception\InvalidArgumentException("The maximum must be greater than or equal to the minimum file count, but "
. "$max < {$this->getMin()}");
Expand Down
2 changes: 1 addition & 1 deletion src/File/FilesSize.php
Expand Up @@ -49,7 +49,7 @@ class FilesSize extends Size
* Min limits the used disk space for all files, when used with max=null it is the maximum file size
* It also accepts an array with the keys 'min' and 'max'
*
* @param integer|array|Traversable $options Options for this validator
* @param int|array|Traversable $options Options for this validator
* @throws \Zend\Validator\Exception\InvalidArgumentException
*/
public function __construct($options = null)
Expand Down

0 comments on commit dff3231

Please sign in to comment.