IntegerExpectations::isOdd()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dgame\Expectation;
4
5
/**
6
 * Class IntegerExpectations
7
 * @package Dgame\Expectation
8
 */
9
final class IntegerExpectations extends NumericExpectations
10
{
11
    /**
12
     * @param mixed $value
13
     *
14
     * @return int
15
     */
16 5
    protected function prepare($value): int
17
    {
18 5
        return (int) $value;
19
    }
20
21
    /**
22
     * @return IntegerExpectations
23
     */
24 2
    public function isEven(): self
25
    {
26 2
        return $this->approveIf(($this->value & 1) === 0);
27
    }
28
29
    /**
30
     * @return IntegerExpectations
31
     */
32 2
    public function isOdd(): self
33
    {
34 2
        return $this->approveIf(($this->value & 1) === 1);
35
    }
36
}
37