Completed
Branch master (35ad35)
by Tristan
17:10 queued 07:53
created

Bag::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4286
cc 2
eloc 4
nc 2
nop 2
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
}