Passed
Push — master ( b0a232...25e62f )
by Mike
02:57
created

SessionClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 43
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 3 2
A isSessionMethodExist() 0 3 1
A callSessionMethod() 0 8 1
1
<?php
2
3
4
namespace Xervice\Session;
5
6
7
use Xervice\Core\Client\AbstractClient;
8
9
/**
10
 * @method \Xervice\Session\SessionFactory getFactory()
11
 */
12
class SessionClient extends AbstractClient
13
{
14
    /**
15
     * @param $name
16
     * @param $arguments
17
     *
18
     * @return mixed
19
     * @throws \InvalidArgumentException
20
     * @throws \RuntimeException
21
     */
22 1
    public function __call($name, $arguments)
23
    {
24 1
        return $this->isSessionMethodExist($name) ? $this->callSessionMethod($name, $arguments) : null;
25
    }
26
27
    /**
28
     * @param $name
29
     *
30
     * @return bool
31
     * @throws \RuntimeException
32
     * @throws \InvalidArgumentException
33
     */
34 1
    private function isSessionMethodExist($name): bool
35
    {
36 1
        return \method_exists($this->getFactory()->getSession(), $name);
37
    }
38
39
    /**
40
     * @param $name
41
     * @param $arguments
42
     *
43
     * @return mixed
44
     * @throws \RuntimeException
45
     * @throws \InvalidArgumentException
46
     */
47 1
    private function callSessionMethod($name, $arguments)
48
    {
49
        return \call_user_func_array(
50
            [
51 1
                $this->getFactory()->getSession(),
52 1
                $name
53
            ],
54 1
            $arguments
55
        );
56
    }
57
}
58