Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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.doctrine-project.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.doctrine-project.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
    public $args;
39
    public $invoker;
40
    public $field;
41
 
42
    /**
43
     * __get
44
     * an alias for getOption
45
     *
46
     * @param string $arg
47
     */
48
    public function __get($arg)
49
    {
50
        if (isset($this->args[$arg])) {
51
            return $this->args[$arg];
52
        }
53
        return null;
54
    }
55
 
56
    /**
57
     * __isset
58
     *
59
     * @param string $arg
60
     */
61
    public function __isset($arg)
62
    {
63
        return isset($this->args[$arg]);
64
    }
65
 
66
    /**
67
     * sets given value to an argument
68
     *
69
     * @param $arg          the name of the option to be changed
70
     * @param $value        the value of the option
71
     * @return Doctrine_Validator_Driver    this object
72
     */
73
    public function __set($arg, $value)
74
    {
75
        $this->args[$arg] = $value;
76
 
77
        return $this;
78
    }
79
 
80
    /**
81
     * returns the value of an argument
82
     *
83
     * @param $arg          the name of the option to retrieve
84
     * @return mixed        the value of the option
85
     */
86
    public function getArg($arg)
87
    {
88
        if ( ! isset($this->args[$arg])) {
89
            throw new Doctrine_Validator_Exception('Unknown option ' . $arg);
90
        }
91
 
92
        return $this->args[$arg];
93
    }
94
 
95
    /**
96
     * sets given value to an argument
97
     *
98
     * @param $arg          the name of the option to be changed
99
     * @param $value        the value of the option
100
     * @return Doctrine_Validator_Driver    this object
101
     */
102
    public function setArg($arg, $value)
103
    {
104
        $this->args[$arg] = $value;
105
 
106
        return $this;
107
    }
108
 
109
    /**
110
     * returns all args and their associated values
111
     *
112
     * @return array    all args as an associative array
113
     */
114
    public function getArgs()
115
    {
116
        return $this->args;
117
    }
118
 
119
    public function __toString()
120
    {
121
        $className = get_class($this);
122
        if (strpos($className, 'Doctrine_Validator_') === 0) {
123
            return strtolower(substr($className, 19));
124
        } else {
125
            return $className;
126
        }
127
    }
128
}