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

Commit

Permalink
Browse files Browse the repository at this point in the history
- s/Extensions/Extension/g
- Added explanatory comments
- Alias both exception types in DateTime validator
  • Loading branch information
weierophinney committed May 2, 2013
1 parent fe2f165 commit a2203c3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Validator/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Traversable;
use Zend\I18n\Exception as I18nException;
use Zend\Validator\AbstractValidator;
use Zend\Validator\Exception;
use Zend\Validator\Exception as ValidatorException;

class DateTime extends AbstractValidator
{
Expand Down Expand Up @@ -81,7 +81,7 @@ class DateTime extends AbstractValidator
* Constructor for the Date validator
*
* @param array|Traversable $options
* @throws Exception\ExtensionNotLoadedException if ext/intl is not present
* @throws I18nException\ExtensionNotLoadedException if ext/intl is not present
*/
public function __construct($options = array())
{
Expand All @@ -92,6 +92,7 @@ public function __construct($options = array())
));
}

// Delaying initialization until we know ext/intl is available
$this->dateType = IntlDateFormatter::NONE;
$this->timeType = IntlDateFormatter::NONE;
$this->calendar = IntlDateFormatter::GREGORIAN;
Expand Down Expand Up @@ -252,7 +253,7 @@ public function getLocale()
*
* @param string $value
* @return bool
* @throws Exception\InvalidArgumentException
* @throws ValidatorException\InvalidArgumentException
*/
public function isValid($value)
{
Expand All @@ -267,7 +268,7 @@ public function isValid($value)
$formatter = $this->getIntlDateFormatter();

if (intl_is_failure($formatter->getErrorCode())) {
throw new Exception\InvalidArgumentException("Invalid locale string given");
throw new ValidatorException\InvalidArgumentException("Invalid locale string given");
}

$position = 0;
Expand Down

0 comments on commit a2203c3

Please sign in to comment.