Completed
Pull Request — develop (#605)
by
unknown
14:48
created

ProxyManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 41
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addServices() 0 4 1
A getServices() 0 6 1
A getService() 0 7 2
1
<?php
2
/**
3
 * Database manager and query manager
4
 */
5
6
namespace Graviton\ProxyApiBundle\Manager;
7
8
use Graviton\ExceptionBundle\Exception\NotFoundException;
9
use Graviton\ProxyApiBundle\Listener\ProxyExceptionListener;
10
use Graviton\ProxyApiBundle\Model\ProxyModel;
11
12
/**
13
 * Request manager and service definition start up
14
 * Build by compiler to be used in ProxyManager
15
 *
16
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
17
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
18
 * @link     http://swisscom.ch
19
 */
20
class ProxyManager
21
{
22
    /** @var array */
23
    protected $services = [];
24
25
    /**
26
     * Add services ProxyModel
27
     *
28
     * @param ProxyModel $services Injected by Compiler
29
     * @return void
30
     */
31
    public function addServices($services)
32
    {
33
        $this->services = $services;
34
    }
35
36
    /**
37
     * Get available proxy's
38
     *
39
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,array>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
40
     */
41
    public function getServices()
42
    {
43
        return [
44
            'services' => $this->services,
45
        ];
46
    }
47
48
    /**
49
     * @param string $client Name of the Client
50
     * @return ProxyModel
51
     * @throws ProxyExceptionListener
52
     */
53
    public function getService($client)
54
    {
55
        if (array_key_exists($client, $this->services)) {
56
            return $this->services[$client];
57
        }
58
        throw new ProxyExceptionListener(404, sprintf('No proxy found for client: %s', $client));
59
    }
60
}
61