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 / Changefreq.php
blob66ad90a9b899b04f649d7c155230e344fe420fe4
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 <changefreq> value
17 * @link http://www.sitemaps.org/protocol.php Sitemaps XML format
19 class Changefreq extends AbstractValidator
21 /**
22 * Validation key for not valid
25 const NOT_VALID = 'sitemapChangefreqNotValid';
26 const INVALID = 'sitemapChangefreqInvalid';
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 changefreq",
35 self::INVALID => "Invalid type given. String expected",
38 /**
39 * Valid change frequencies
41 * @var array
43 protected $changeFreqs = array(
44 'always', 'hourly', 'daily', 'weekly',
45 'monthly', 'yearly', 'never'
48 /**
49 * Validates if a string is valid as a sitemap changefreq
51 * @link http://www.sitemaps.org/protocol.php#changefreqdef <changefreq>
53 * @param string $value value to validate
54 * @return bool
56 public function isValid($value)
58 if (!is_string($value)) {
59 $this->error(self::INVALID);
60 return false;
63 $this->setValue($value);
64 if (!is_string($value)) {
65 return false;
68 if (!in_array($value, $this->changeFreqs, true)) {
69 $this->error(self::NOT_VALID);
70 return false;
73 return true;