93% of 253OPs |
92% of 38Lines |
69% of 32Branches |
54% of 13Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\asserters\integer::__get() | 35 | 51% | 6 | 50% | 6 | 17% | 2 | 50% |
mageekguy\atoum\asserters\integer::setWith() | 42 | 100% | 7 | 100% | 5 | 80% | 2 | 50% |
mageekguy\atoum\asserters\integer::isZero() | 12 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\asserters\integer::isGreaterThan() | 41 | 100% | 6 | 100% | 5 | 80% | 2 | 50% |
mageekguy\atoum\asserters\integer::isGreaterThanOrEqualTo() | 41 | 100% | 6 | 100% | 5 | 80% | 2 | 50% |
mageekguy\atoum\asserters\integer::isLessThan() | 41 | 100% | 6 | 100% | 5 | 80% | 2 | 50% |
mageekguy\atoum\asserters\integer::isLessThanOrEqualTo() | 41 | 100% | 6 | 100% | 5 | 80% | 2 | 50% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\asserters; |
4 |
|
5 |
use |
6 |
mageekguy\atoum\asserters, |
7 |
mageekguy\atoum\exceptions |
8 |
; |
9 |
|
10 |
class integer extends asserters\variable |
11 |
{ |
12 |
public function __get($property)50% |
13 |
{ |
14 |
switch (strtolower($property)) |
15 |
{ |
16 |
case 'iszero': |
17 |
return $this->isZero(); |
18 |
|
19 |
default: |
20 |
return parent::__get($property); |
21 |
} |
22 |
} |
23 |
|
24 |
public function setWith($value)100% |
25 |
{ |
26 |
parent::setWith($value); |
27 |
|
28 |
if ($this->analyzer->isInteger($this->value) === true) |
29 |
{ |
30 |
$this->pass(); |
31 |
} |
32 |
else |
33 |
{ |
34 |
$this->fail($this->_('%s is not an integer', $this)); |
35 |
} |
36 |
|
37 |
return $this; |
38 |
} |
39 |
|
40 |
public function isZero($failMessage = null)100% |
41 |
{ |
42 |
return $this->isEqualTo(0, $failMessage); |
43 |
} |
44 |
|
45 |
public function isGreaterThan($value, $failMessage = null)100% |
46 |
{ |
47 |
if ($this->valueIsSet()->value > $value) |
48 |
{ |
49 |
$this->pass(); |
50 |
} |
51 |
else |
52 |
{ |
53 |
$this->fail($failMessage ?: $this->_('%s is not greater than %s', $this, $this->getTypeOf($value))); |
54 |
} |
55 |
|
56 |
return $this; |
57 |
} |
58 |
|
59 |
public function isGreaterThanOrEqualTo($value, $failMessage = null)100% |
60 |
{ |
61 |
if ($this->valueIsSet()->value >= $value) |
62 |
{ |
63 |
$this->pass(); |
64 |
} |
65 |
else |
66 |
{ |
67 |
$this->fail($failMessage ?: $this->_('%s is not greater than or equal to %s', $this, $this->getTypeOf($value))); |
68 |
} |
69 |
|
70 |
return $this; |
71 |
} |
72 |
|
73 |
public function isLessThan($value, $failMessage = null)100% |
74 |
{ |
75 |
if ($this->valueIsSet()->value < $value) |
76 |
{ |
77 |
$this->pass(); |
78 |
} |
79 |
else |
80 |
{ |
81 |
$this->fail($failMessage ?: $this->_('%s is not less than %s', $this, $this->getTypeOf($value))); |
82 |
} |
83 |
|
84 |
return $this; |
85 |
} |
86 |
|
87 |
public function isLessThanOrEqualTo($value, $failMessage = null)100% |
88 |
{ |
89 |
if ($this->valueIsSet()->value <= $value) |
90 |
{ |
91 |
$this->pass(); |
92 |
} |
93 |
else |
94 |
{ |
95 |
$this->fail($failMessage ?: $this->_('%s is not less than or equal to %s', $this, $this->getTypeOf($value))); |
96 |
} |
97 |
|
98 |
return $this; |
99 |
} |
100 |
} |