Completed
Push — master ( 7a6150...2f2994 )
by Chad
10s
created

Response::getMessage()   A

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 0
1
<?php
2
/**
3
 * TraderInteractive\SolveMedia\Response class used with
4
 * the TraderInteractive\SolveMedia\Service class.
5
 * This component has been modified from it's original form to
6
 * encapsulate the functionality in a class based structure that is
7
 * compatible with class autoloading functionality.
8
 *
9
 * @author Chris Ryan <[email protected]>
10
 */
11
12
namespace TraderInteractive\SolveMedia;
13
14
/**
15
 * A TraderInteractive\SolveMedia\Response is returned from TraderInteractive\SolveMedia\Service::checkAnswer()
16
 */
17
final class Response
18
{
19
    /**
20
     * @var boolean
21
     */
22
    private $_isValid;
23
24
    /**
25
     * @var string
26
     */
27
    private $_error;
28
29
    /**
30
     * Construct a new Response with a valid flag and error message.
31
     *
32
     * @param boolean $isValid represents if the response received was valid
33
     * @param string $error the error message if the response is not valid
34
     */
35
    public function __construct(bool $isValid = false, string $error = null)
36
    {
37
        $this->_isValid = $isValid;
38
        $this->_error = $error;
39
    }
40
41
    /**
42
     * Return if the request was valid.
43
     *
44
     * @return boolean
45
     */
46
    public function valid() : bool
47
    {
48
        return $this->_isValid;
49
    }
50
51
    /**
52
     * Return the error message, if one is set.
53
     *
54
     * @return string|null
55
     */
56
    public function getMessage()
57
    {
58
        return $this->_error;
59
    }
60
}
61