Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Zend/Validate/Regex.php')
-rw-r--r--libs/Zend/Validate/Regex.php47
1 files changed, 13 insertions, 34 deletions
diff --git a/libs/Zend/Validate/Regex.php b/libs/Zend/Validate/Regex.php
index e46143287f..e4707f5f60 100644
--- a/libs/Zend/Validate/Regex.php
+++ b/libs/Zend/Validate/Regex.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Zend Framework
*
@@ -14,35 +15,35 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Regex.php 21574 2010-03-19 20:00:37Z thomas $
+ * @version $Id: Regex.php 17470 2009-08-08 22:27:09Z thomas $
*/
+
/**
* @see Zend_Validate_Abstract
*/
-// require_once 'Zend/Validate/Abstract.php';
+require_once 'Zend/Validate/Abstract.php';
+
/**
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Regex extends Zend_Validate_Abstract
{
const INVALID = 'regexInvalid';
const NOT_MATCH = 'regexNotMatch';
- const ERROROUS = 'regexErrorous';
/**
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be string, integer or float",
- self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'",
- self::ERROROUS => "There was an internal error while using the pattern '%pattern%'",
+ self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'"
);
/**
@@ -62,25 +63,11 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
/**
* Sets validator options
*
- * @param string|Zend_Config $pattern
- * @throws Zend_Validate_Exception On missing 'pattern' parameter
+ * @param string $pattern
* @return void
*/
public function __construct($pattern)
{
- if ($pattern instanceof Zend_Config) {
- $pattern = $pattern->toArray();
- }
-
- if (is_array($pattern)) {
- if (array_key_exists('pattern', $pattern)) {
- $pattern = $pattern['pattern'];
- } else {
- // require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Missing option 'pattern'");
- }
- }
-
$this->setPattern($pattern);
}
@@ -98,19 +85,11 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
* Sets the pattern option
*
* @param string $pattern
- * @throws Zend_Validate_Exception if there is a fatal error in pattern matching
* @return Zend_Validate_Regex Provides a fluent interface
*/
public function setPattern($pattern)
{
$this->_pattern = (string) $pattern;
- $status = @preg_match($this->_pattern, "Test");
-
- if (false === $status) {
- // require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Internal error while using the pattern '$this->_pattern'");
- }
-
return $this;
}
@@ -120,6 +99,7 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
* Returns true if and only if $value matches against the pattern option
*
* @param string $value
+ * @throws Zend_Validate_Exception if there is a fatal error in pattern matching
* @return boolean
*/
public function isValid($value)
@@ -133,15 +113,14 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
$status = @preg_match($this->_pattern, $value);
if (false === $status) {
- $this->_error(self::ERROROUS);
- return false;
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$value'");
}
-
if (!$status) {
$this->_error(self::NOT_MATCH);
return false;
}
-
return true;
}
+
}