Completed
Pull Request — master (#10)
by Chad
05:48
created

Response::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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
    private $_isValid;
20
    private $_error;
21
22
    /**
23
     * Construct a new Response with a valid flag and error message.
24
     *
25
     * @param boolean $isValid represents if the response received was valid
26
     * @param string $error the error message if the response is not valid
27
     */
28
    public function __construct($isValid = false, $error = null)
29
    {
30
        $this->_isValid = $isValid;
31
        $this->_error = $error;
32
    }
33
34
    /**
35
     * Return if the request was valid.
36
     *
37
     * @return boolean
38
     */
39
    public function valid()
40
    {
41
        return $this->_isValid;
42
    }
43
44
    /**
45
     * Return the error message, if one is set.
46
     *
47
     * @return string|null
48
     */
49
    public function getMessage()
50
    {
51
        return $this->_error;
52
    }
53
}
54