Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / lib / Doctrine / ORM / Query / Parameter.php
1 <?php
2 /*
3  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * This software consists of voluntary contributions made by many individuals
16  * and is licensed under the MIT license. For more information, see
17  * <http://www.doctrine-project.org>.
18  */
19
20 namespace Doctrine\ORM\Query;
21
22 /**
23  * Define a Query Parameter
24  *
25  * @link    www.doctrine-project.org
26  * @since   2.3
27  * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
28  */
29 class Parameter
30 {
31     /**
32      * @var string Parameter name
33      */
34     private $name;
35
36     /**
37      * @var mixed Parameter value
38      */
39     private $value;
40
41     /**
42      * @var mixed Parameter type
43      */
44     private $type;
45
46     /**
47      * Constructor.
48      *
49      * @param string    $name   Parameter name
50      * @param mixed     $value  Parameter value
51      * @param mixed     $type   Parameter type
52      */
53     public function __construct($name, $value, $type = null)
54     {
55         $this->name  = trim($name, ':');
56
57         $this->setValue($value, $type);
58     }
59
60     /**
61      * Retrieve the Parameter name.
62      *
63      * @return string
64      */
65     public function getName()
66     {
67         return $this->name;
68     }
69
70     /**
71      * Retrieve the Parameter value.
72      *
73      * @return mixed
74      */
75     public function getValue()
76     {
77         return $this->value;
78     }
79
80     /**
81      * Retrieve the Parameter type.
82      *
83      * @return mixed
84      */
85     public function getType()
86     {
87         return $this->type;
88     }
89
90     /**
91      * Define the Parameter value.
92      *
93      * @param mixed     $value  Parameter value
94      * @param mixed     $type   Parameter type
95      */
96     public function setValue($value, $type = null)
97     {
98         $this->value = $value;
99         $this->type  = $type ?: ParameterTypeInferer::inferType($value);
100     }
101 }