RabbitConfig   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Test Coverage

Coverage 65.22%

Importance

Changes 0
Metric Value
wmc 11
dl 0
loc 87
ccs 15
cts 23
cp 0.6522
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setPassword() 0 3 1
A __construct() 0 4 2
A fromArray() 0 5 3
A setBaseUrl() 0 3 1
A setUsername() 0 3 1
A getBaseUrl() 0 3 1
A getUsername() 0 3 1
A getPassword() 0 3 1
1
<?php
2
namespace pmill\RabbitRabbit;
3
4
class RabbitConfig
5
{
6
    /**
7
     * @var string
8
     */
9
    protected $baseUrl;
10
11
    /**
12
     * @var string
13
     */
14
    protected $username;
15
16
    /**
17
     * @var string
18
     */
19
    protected $password;
20
21
    /**
22
     * RabbitConfig constructor.
23
     *
24
     * @param array|null $config
25
     */
26 2
    public function __construct(array $config = null)
27
    {
28 2
        if ($config) {
29 1
            $this->fromArray($config);
30
        }
31 2
    }
32
33
    /**
34
     * @param array $array
35
     */
36 2
    public function fromArray(array $array): void
37
    {
38 2
        foreach ($array as $propertyName => $value) {
39 2
            if (property_exists($this, $propertyName)) {
40 2
                $this->$propertyName = $value;
41
            }
42
        }
43 2
    }
44
45
    /**
46
     * @return string
47
     */
48 2
    public function getBaseUrl(): string
49
    {
50 2
        return $this->baseUrl;
51
    }
52
53
    /**
54
     * @param string $baseUrl
55
     */
56
    public function setBaseUrl(string $baseUrl): void
57
    {
58
        $this->baseUrl = $baseUrl;
59
    }
60
61
    /**
62
     * @return string
63
     */
64 2
    public function getUsername(): string
65
    {
66 2
        return $this->username;
67
    }
68
69
    /**
70
     * @param string $username
71
     */
72
    public function setUsername(string $username): void
73
    {
74
        $this->username = $username;
75
    }
76
77
    /**
78
     * @return string
79
     */
80 2
    public function getPassword(): string
81
    {
82 2
        return $this->password;
83
    }
84
85
    /**
86
     * @param string $password
87
     */
88
    public function setPassword(string $password): void
89
    {
90
        $this->password = $password;
91
    }
92
}
93