| Total Complexity | 11 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Coverage | 65.22% |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 |
||
| 91 | } |
||
| 92 | } |
||
| 93 |