1 |
<?php
|
2 |
/*
|
3 |
* $Id: Usstate.php 2963 2007-10-21 06:23:59Z Jonathan.Wage $
|
4 |
*
|
5 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
6 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
7 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
8 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
9 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
10 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
11 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
12 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
13 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
14 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
15 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
16 |
*
|
17 |
* This software consists of voluntary contributions made by many individuals
|
18 |
* and is licensed under the LGPL. For more information, see
|
19 |
* <http://www.phpdoctrine.com>.
|
20 |
*/
|
21 |
|
22 |
/**
|
23 |
* Doctrine_Validator_Usstate
|
24 |
*
|
25 |
* @package Doctrine
|
26 |
* @subpackage Validator
|
27 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
28 |
* @link www.phpdoctrine.com
|
29 |
* @since 1.0
|
30 |
* @version $Revision: 2963 $
|
31 |
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
32 |
*/
|
33 |
class Doctrine_Validator_Usstate
|
34 |
{
|
35 |
private static $states = array(
|
36 |
'AK' => true,
|
37 |
'AL' => true,
|
38 |
'AR' => true,
|
39 |
'AZ' => true,
|
40 |
'CA' => true,
|
41 |
'CO' => true,
|
42 |
'CT' => true,
|
43 |
'DC' => true,
|
44 |
'DE' => true,
|
45 |
'FL' => true,
|
46 |
'GA' => true,
|
47 |
'HI' => true,
|
48 |
'IA' => true,
|
49 |
'ID' => true,
|
50 |
'IL' => true,
|
51 |
'IN' => true,
|
52 |
'KS' => true,
|
53 |
'KY' => true,
|
54 |
'LA' => true,
|
55 |
'MA' => true,
|
56 |
'MD' => true,
|
57 |
'ME' => true,
|
58 |
'MI' => true,
|
59 |
'MN' => true,
|
60 |
'MO' => true,
|
61 |
'MS' => true,
|
62 |
'MT' => true,
|
63 |
'NC' => true,
|
64 |
'ND' => true,
|
65 |
'NE' => true,
|
66 |
'NH' => true,
|
67 |
'NJ' => true,
|
68 |
'NM' => true,
|
69 |
'NV' => true,
|
70 |
'NY' => true,
|
71 |
'OH' => true,
|
72 |
'OK' => true,
|
73 |
'OR' => true,
|
74 |
'PA' => true,
|
75 |
'PR' => true,
|
76 |
'RI' => true,
|
77 |
'SC' => true,
|
78 |
'SD' => true,
|
79 |
'TN' => true,
|
80 |
'TX' => true,
|
81 |
'UT' => true,
|
82 |
'VA' => true,
|
83 |
'VI' => true,
|
84 |
'VT' => true,
|
85 |
'WA' => true,
|
86 |
'WI' => true,
|
87 |
'WV' => true,
|
88 |
'WY' => true
|
89 |
);
|
90 |
public function getStates()
|
91 |
{
|
92 |
return self::$states;
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
* checks if given value is a valid US state code
|
97 |
*
|
98 |
* @param string $args
|
99 |
* @return boolean
|
100 |
*/
|
101 |
public function validate($value)
|
102 |
{
|
103 |
return isset(self::$states[$value]);
|
104 |
}
|
105 |
} |