DIMagicTrait::__call()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Anax\DI;
3
4
use Anax\DI\Exception\Exception;
5
6
/**
7
 * Trait to use to make a DI container use magic for
8
 * getting services. A class using a DI container can
9
 * access $this->di->session; as an alternative to
10
 * $this->di->get("session");
11
 */
12
trait DIMagicTrait
13
{
14
    /**
15
     * Magic method to get a service.
16
     *
17
     * @param string $service name of the service.
18
     *
19
     * @return mixed as the service requested.
20
     */
21 1
    public function __get($service)
22
    {
23 1
        return $this->get($service);
0 ignored issues
show
Bug introduced by
The method get() does not exist on Anax\DI\DIMagicTrait. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        return $this->/** @scrutinizer ignore-call */ get($service);
Loading history...
24
    }
25
26
27
28
    /**
29
     * Magic method to get and call a service.
30
     *
31
     * @param string $service name of the service.
32
     * @param array  $arguments currently NOT USED.
33
     *
34
     * @return mixed as the service requested.
35
     */
36 1
    public function __call($service, $arguments = [])
37
    {
38 1
        return $this->get($service);
39
    }
40
}
41