Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Validator / Sitemap / Priority.php
blob4c7d0f99289c9256c64ad1afce991d004c9ea213
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Validator\Sitemap;
12 use Zend\Validator\AbstractValidator;
14 /**
15 * Validates whether a given value is valid as a sitemap <priority> value
17 * @link http://www.sitemaps.org/protocol.php Sitemaps XML format
19 class Priority extends AbstractValidator
21 /**
22 * Validation key for not valid
25 const NOT_VALID = 'sitemapPriorityNotValid';
26 const INVALID = 'sitemapPriorityInvalid';
28 /**
29 * Validation failure message template definitions
31 * @var array
33 protected $messageTemplates = array(
34 self::NOT_VALID => "The input is not a valid sitemap priority",
35 self::INVALID => "Invalid type given. Numeric string, integer or float expected",
38 /**
39 * Validates if a string is valid as a sitemap priority
41 * @link http://www.sitemaps.org/protocol.php#prioritydef <priority>
43 * @param string $value value to validate
44 * @return bool
46 public function isValid($value)
48 if (!is_numeric($value)) {
49 $this->error(self::INVALID);
50 return false;
53 $this->setValue($value);
54 $value = (float) $value;
55 if ($value < 0 || $value > 1) {
56 $this->error(self::NOT_VALID);
57 return false;
60 return true;