1 |
<?php
|
2 |
/*
|
3 |
* $Id: Notnull.php 1080 2007-02-10 18:17:08Z romanb $
|
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.org>.
|
20 |
*/
|
21 |
|
22 |
/**
|
23 |
* Doctrine_Validator_Driver
|
24 |
*
|
25 |
* @package Doctrine
|
26 |
* @subpackage Validator
|
27 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
28 |
* @link www.phpdoctrine.org
|
29 |
* @since 1.0
|
30 |
* @version $Revision: 1080 $
|
31 |
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
32 |
*/
|
33 |
class Doctrine_Validator_Driver
|
34 |
{
|
35 |
/**
|
36 |
* @var array $_args an array of plugin specific args
|
37 |
*/
|
38 |
protected $_args = array();
|
39 |
|
40 |
/**
|
41 |
* __get
|
42 |
* an alias for getOption
|
43 |
*
|
44 |
* @param string $arg
|
45 |
*/
|
46 |
public function __get($arg)
|
47 |
{
|
48 |
if (isset($this->_args[$arg])) {
|
49 |
return $this->_args[$arg];
|
50 |
}
|
51 |
return null;
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
* __isset
|
56 |
*
|
57 |
* @param string $arg
|
58 |
*/
|
59 |
public function __isset($arg)
|
60 |
{
|
61 |
return isset($this->_args[$arg]);
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* sets given value to an argument
|
66 |
*
|
67 |
* @param $arg the name of the option to be changed
|
68 |
* @param $value the value of the option
|
69 |
* @return Doctrine_Validator_Driver this object
|
70 |
*/
|
71 |
public function __set($arg, $value)
|
72 |
{
|
73 |
$this->_args[$arg] = $value;
|
74 |
|
75 |
return $this;
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
* returns the value of an argument
|
80 |
*
|
81 |
* @param $arg the name of the option to retrieve
|
82 |
* @return mixed the value of the option
|
83 |
*/
|
84 |
public function getArg($arg)
|
85 |
{
|
86 |
if ( ! isset($this->_args[$arg])) {
|
87 |
throw new Doctrine_Plugin_Exception('Unknown option ' . $arg);
|
88 |
}
|
89 |
|
90 |
return $this->_args[$arg];
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
* sets given value to an argument
|
95 |
*
|
96 |
* @param $arg the name of the option to be changed
|
97 |
* @param $value the value of the option
|
98 |
* @return Doctrine_Validator_Driver this object
|
99 |
*/
|
100 |
public function setArg($arg, $value)
|
101 |
{
|
102 |
$this->_args[$arg] = $value;
|
103 |
|
104 |
return $this;
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
* returns all args and their associated values
|
109 |
*
|
110 |
* @return array all args as an associative array
|
111 |
*/
|
112 |
public function getArgs()
|
113 |
{
|
114 |
return $this->_args;
|
115 |
}
|
116 |
} |