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

SessionClient::isSessionMethodExist()   A

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
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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