EndpointConfiguration::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * Copyright 2014 Jonathan Bouzekri. All rights reserved.
5
 *
6
 * @copyright Copyright 2014 Jonathan Bouzekri <[email protected]>
7
 * @license https://github.com/jbouzekri/FileUploaderBundle/blob/master/LICENSE
8
 * @link https://github.com/jbouzekri/FileUploaderBundle
9
 */
10
11
namespace Jb\Bundle\FileUploaderBundle\Service;
12
13
/**
14
 * EndpointConfiguration
15
 *
16
 * @author jobou
17
 */
18
class EndpointConfiguration
19
{
20
    /**
21
     * @var array
22
     */
23
    protected $endpoints;
24
25
    /**
26
     * Constructor
27
     *
28
     * @param array $endpoints
29
     */
30
    public function __construct(array $endpoints)
31
    {
32
        $this->endpoints = $endpoints;
33
    }
34
35
36
    /**
37
     * Get configuration value
38
     *
39
     * @param string $endpoint
40
     * @param string $key
41
     *
42
     * @return mixed
43
     */
44
    public function getValue($endpoint, $key)
45
    {
46
        if (isset($this->endpoints['endpoints'][$endpoint])
47
            && isset($this->endpoints['endpoints'][$endpoint][$key])
48
        ) {
49
            return $this->endpoints['endpoints'][$endpoint][$key];
50
        }
51
52
        if (isset($this->endpoints[$key])) {
53
            return $this->endpoints[$key];
54
        }
55
56
        return null;
57
    }
58
59
    /**
60
     * Get enpoint configuration
61
     *
62
     * @param string $endpoint
63
     * @return mixed
64
     */
65
    public function getEndpoint($endpoint)
66
    {
67
        return $this->endpoints[$endpoint];
68
    }
69
}
70