Passed
Pull Request — master (#400)
by Théo
03:00
created

ConfigurationLogger::addWarning()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the box project.
7
 *
8
 * (c) Kevin Herrera <[email protected]>
9
 *     Théo Fidry <[email protected]>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14
15
namespace KevinGH\Box\Configuration;
16
17
use function array_keys;
18
use Assert\Assertion;
19
use function trim;
20
21
/**
22
 * @private
23
 */
24
final class ConfigurationLogger
25
{
26
    private $recommendations = [];
27
    private $warnings = [];
28
29
    public function addRecommendation(string $message): void
30
    {
31
        $message = trim($message);
32
33
        Assertion::false('' === $message, 'Expected to have a message but a blank string was given instead.');
34
35
        $this->recommendations[$message] = $message;
36
    }
37
38
    /**
39
     * @return string[]
40
     */
41
    public function getRecommendations(): array
42
    {
43
        return array_keys($this->recommendations);
44
    }
45
46
    public function addWarning(string $message): void
47
    {
48
        $message = trim($message);
49
50
        Assertion::false('' === $message, 'Expected to have a message but a blank string was given instead.');
51
52
        $this->warnings[$message] = $message;
53
    }
54
55
    /**
56
     * @return string[]
57
     */
58
    public function getWarnings(): array
59
    {
60
        return array_keys($this->warnings);
61
    }
62
}
63