Test Setup Failed
Push — master ( cd3f9b...c6f3fc )
by Marcel
02:47
created

DynamicSaasClientAccessorService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 25
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setClientService() 0 3 1
A __call() 0 14 3
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