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

Response   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A valid() 0 4 1
A getMessage() 0 4 1
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