gwRangeExceptionInfo::getMaximum()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Gwa\Exception;
4
5
/**
6
 * An exception info container for out of range exceptions.
7
 */
8
class gwRangeExceptionInfo extends gwCoreExceptionInfo implements gwiExceptionInfo
9
{
10
    /**
11
     * @var int
12
     */
13
    protected $value;
14
15
    /**
16
     * @var int
17
     */
18
    protected $maximum;
19
20
    /**
21
     * @var int
22
     */
23
    protected $minimum;
24
25
    /**
26
     * @var string
27
     */
28
    protected $note;
29
30
    /**
31
     * Constructor.
32
     *
33
     * @param int    $value   the actual value that caused the exception
34
     * @param int    $minimum the minimum legal value
35
     * @param int    $maximum the maximum legal value
36
     * @param string $note    an optional note
37
     */
38
    public function __construct($value, $minimum, $maximum, $note = '')
39
    {
40
        $this->value = $value;
41
        $this->minimum = $minimum;
42
        $this->maximum = $maximum;
43
        $this->note = $note;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function fetch()
50
    {
51
        $output = sprintf(
52
            '%s MUST BE within the range of [%s to %s]',
53
            $this->value,
54
            $this->minimum,
55
            $this->maximum
56
        );
57
        if ($this->note) {
58
            $output .= ' ('.$this->note.')';
59
        }
60
61
        return $output;
62
    }
63
64
    /**
65
     * @return int
66
     */
67
    public function getMaximum()
68
    {
69
        return $this->maximum;
70
    }
71
72
    /**
73
     * @return int
74
     */
75
    public function getMinimum()
76
    {
77
        return $this->minimum;
78
    }
79
}
80