Bag::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Enzyme\Loopy;
4
5
class Bag
6
{
7
    /**
8
     * The internal data store for this bag.
9
     *
10
     * @var array
11
     */
12
    protected $store = [];
13
14
    /**
15
     * Create a new bag with the given store data.
16
     *
17
     * @param array $store The associated data.
18
     */
19
    public function __construct($store)
20
    {
21
        $this->store = $store;
22
    }
23
24
    /**
25
     * Magic method to fetch data from the store.
26
     *
27
     * @param string $name The name of value to fetch.
28
     * @param mixed  $args Associated arguments (ignored).
29
     *
30
     * @return mixed|null The value.
31
     */
32
    public function __call($name, $args)
33
    {
34
        if (array_key_exists($name, $this->store)) {
35
            return $this->store[$name];
36
        }
37
38
        return null;
39
    }
40
}