Completed
Push — master ( 622c37...dca855 )
by Christian
04:12
created

SelfTestResult::getExplain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of tenside/core.
5
 *
6
 * (c) Christian Schiffler <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * This project is provided in good faith and hope to be usable by anyone.
12
 *
13
 * @package    tenside/core
14
 * @author     Christian Schiffler <[email protected]>
15
 * @copyright  2015 Christian Schiffler <[email protected]>
16
 * @license    https://github.com/tenside/core/blob/master/LICENSE MIT
17
 * @link       https://github.com/tenside/core
18
 * @filesource
19
 */
20
21
namespace Tenside\Core\SelfTest;
22
23
/**
24
 * This class holds the results of an test.
25
 */
26
class SelfTestResult
27
{
28
    /**
29
     * Marks error state - dark red.
30
     */
31
    const STATE_FAIL = 'FAIL';
32
33
    /**
34
     * Marks that the test has been skipped/is not applicable in the current environment - lights off.
35
     */
36
    const STATE_SKIPPED = 'SKIPPED';
37
38
    /**
39
     * Marks success state - all lights are green.
40
     */
41
    const STATE_SUCCESS = 'SUCCESS';
42
43
    /**
44
     * Marks a warning state - bright shade of yellow or maybe orange.
45
     */
46
    const STATE_WARN = 'WARNING';
47
48
    /**
49
     * Optional description that could hint any problems and/or explain the error further.
50
     *
51
     * @var string
52
     */
53
    private $explain;
54
55
    /**
56
     * The detailed message of the test result.
57
     *
58
     * @var string
59
     */
60
    private $message;
61
62
    /**
63
     * The test result state.
64
     *
65
     * @var string
66
     *
67
     * @see SelfTestResult::STATE_FAIL
68
     * @see SelfTestResult::STATE_SKIPPED
69
     * @see SelfTestResult::STATE_SUCCESS
70
     * @see SelfTestResult::STATE_WARN
71
     */
72
    private $state;
73
74
    /**
75
     * The implementing class of the test.
76
     *
77
     * @var string
78
     */
79
    private $testClass;
80
81
    /**
82
     * Create a new instance.
83
     *
84
     * @param string $message   The detailed message of the test result.
85
     *
86
     * @param string $state     The test result state.
87
     *
88
     * @param string $testClass The implementing class of the test.
89
     *
90
     * @param string $explain   An optional description that could hint any problems.
91
     */
92
    public function __construct($message, $state, $testClass, $explain = '')
93
    {
94
        $this->message   = $message;
95
        $this->state     = $state;
96
        $this->testClass = $testClass;
97
        $this->explain   = $explain;
98
    }
99
100
    /**
101
     * Retrieve the message describing the test.
102
     *
103
     * @return string
104
     */
105
    public function getMessage()
106
    {
107
        return $this->message;
108
    }
109
110
    /**
111
     * Retrieve the result state.
112
     *
113
     * @return string
114
     */
115
    public function getState()
116
    {
117
        return $this->state;
118
    }
119
120
    /**
121
     * Retrieve the class name that has created this test result.
122
     *
123
     * @return string
124
     */
125
    public function getTestClass()
126
    {
127
        return $this->testClass;
128
    }
129
130
    /**
131
     * Retrieve the optional explanation.
132
     *
133
     * @return string
134
     */
135
    public function getExplain()
136
    {
137
        return $this->explain;
138
    }
139
}
140