Completed
Push — master ( e401e5...bd7189 )
by Julien
01:48
created

ArrayDefinition.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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;
34
35
/**
36
 * ArrayDefinition
37
 * 
38
 * Represents a PHP Array definition
39
 *
40
 * @category Definition
41
 * @package  Fwk\Di
42
 * @author   Julien Ballestracci <[email protected]>
43
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD License
44
 * @link     http://www.nitronet.org/fwk
45
 */
46
class ArrayDefinition extends AbstractDefinition implements Invokable
47
{
48
    /**
49
     * The array
50
     * @var array
51
     */
52
    protected $array;
53
    
54
    /**
55
     * Constructor
56
     * 
57
     * @param array<mixed> $array     The PHP array
58
     * @param array<mixed> $arguments List of arguments
59
     * 
60
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
61
     */
62
    public function __construct($array, array $arguments = array())
63
    {
64
        $this->array        = $array;
65
        $this->arguments    = $arguments;
66
    }
67
    
68
    /**
69
     * Calls $this->callable and return its value
70
     * 
71
     * @param Container   $container The Di Container
72
     * @param null|string $name      Name of the definition (if any)
73
     * 
74
     * @return array<mixed>
75
     */
76
    public function invoke(Container $container, $name = null)
77
    {
78
        return $this->propertizeArguments($this->array, $container, $name);
79
    }
80
    
81
    /**
82
     * Returns the array
83
     * 
84
     * @return array<mixed>
85
     */
86
    public function getArray()
87
    {
88
        return $this->array;
89
    }
90
    
91
    /**
92
     * Defines the array
93
     * 
94
     * @param array<mixed> $array The callable function
95
     * 
96
     * @return void
97
     */
98
    public function setArray(array $array)
99
    {
100
        $this->array = $array;
101
    }
102
}