Completed
Push — feat-events-tags ( 343dc9...26067f )
by Julien
02:09
created

AbstractDefinition::addArgument()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Fwk
4
 *
5
 * Copyright (c) 2011-2012, Julien Ballestracci <[email protected]>.
6
 * All rights reserved.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
13
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
15
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
16
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
17
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
21
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
 * POSSIBILITY OF SUCH DAMAGE.
23
 *
24
 * PHP Version 5.3
25
 *
26
 * @category  DependencyInjection
27
 * @package   Fwk\Di
28
 * @author    Julien Ballestracci <[email protected]>
29
 * @copyright 2011-2014 Julien Ballestracci <[email protected]>
30
 * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
31
 * @link      http://www.nitronet.org/fwk
32
 */
33
namespace Fwk\Di\Definitions;
34
35
use Fwk\Di\Container;
36
use Fwk\Di\DefinitionInterface;
37
use Fwk\Di\InvokableInterface;
38
use Fwk\Di\Exceptions;
39
use Fwk\Di\Reference;
40
41
/**
42
 * Abstract Definition Utility
43
 *
44
 * @category Utilities
45
 * @package  Fwk\Di
46
 * @author   Julien Ballestracci <[email protected]>
47
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD License
48
 * @link     http://www.nitronet.org/fwk
49
 */
50
abstract class AbstractDefinition
51
{
52
    /**
53
     * Shared result/instance ?
54
     *
55
     * @var bool
56
     */
57
    protected $shared = false;
58
59
    /**
60
     * Definition's meta-data
61
     *
62
     * @var array
63
     */
64
    protected $data = array();
65
66
    /**
67
     * @param bool $bool
68
     *
69
     * @return DefinitionInterface
70
     */
71
    public function setShared($bool)
72
    {
73
        $this->shared = (bool)$bool;
74
75
        return $this;
76
    }
77
78
    /**
79
     * @return bool
80
     */
81
    public function isShared()
82
    {
83
        return $this->shared;
84
    }
85
86
    /**
87 9
     * Sets (erase) definition meta-data
88
     *
89 9
     * @param array $data The Definition's data
90
     *
91 9
     * @return DefinitionInterface
92
     */
93
    public function setData(array $data)
94
    {
95
        $this->data = $data;
96
97
        return $this;
98
    }
99
100
    /**
101
     * Returns all definition meta-data
102
     *
103
     * @return array
104
     */
105
    public function getData()
106
    {
107
        return $this->data;
108
    }
109
110
    /**
111
     * Returns a meta-data parameter ($param) or $default if not defined
112
     *
113
     * @param string     $param   Parameter key
114
     * @param null|mixed $default Default return value if not defined
115
     *
116 10
     * @return mixed
117
     */
118
    public function get($param, $default = null)
119 10
    {
120 10
        return (array_key_exists($param, $this->data) ? $this->data[$param] : $default);
121 10
    }
122
123 10
    /**
124
     * Defines a meta-data parameter
125
     *
126
     * @param string $param Parameter key
127
     * @param mixed  $value Parameter value
128
     *
129
     * @return DefinitionInterface
130
     */
131
    public function set($param, $value)
132
    {
133
        $this->data[$param] = $value;
134
135
        return $this;
136
    }
137 13
138
    /**
139
     * Tells if definition's meta-data matches $dataQuery
140 13
     *
141 13
     * @param array $query
142 12
     *
143 12
     * @return boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
144 9
     */
145 9
    public function match(array $query)
146
    {
147 12
148 3
    }
149
}
150