DynamicSaasClientAccessorService::__call()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 14
rs 10
1
<?php
2
3
/*
4
 * This file is part of the SaasProviderBundle package.
5
 * (c) Fluxter <http://fluxter.net/>
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Fluxter\SaasProviderBundle\Service;
11
12
class DynamicSaasClientAccessorService
13
{
14
    /** @var SaasClientService */
15
    private $_clientService;
16
17
    public function __call($name, $arguments)
18
    {
19
        $client = $this->_clientService->getCurrentClient();
20
21
        $method = "get$name";
22
        if (method_exists($client, $method)) {
23
            return $client->$method();
24
        }
25
        $method = "is$name";
26
        if (method_exists($client, $method)) {
27
            return $client->$method();
28
        }
29
30
        throw new \Exception("Unknown Settings function / variable: {$name}!");
31
    }
32
33
    /** @required */
34
    public function setClientService(SaasClientService $clientService)
35
    {
36
        $this->_clientService = $clientService;
37
    }
38
}
39