TypeTrait::isZero()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Mathematical\Operator;
4
5
/**
6
 * Class TypeTrait
7
 *
8
 * @package   BestServedCold\PhalueObjects\Mathematical\Operator
9
 * @author    Adam Lewis <[email protected]>
10
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
11
 * @license   http://http://opensource.org/licenses/GPL-3.0 GPL License
12
 * @link      http://bestservedcold.com
13
 * @since     0.0.1-alpha
14
 * @version   0.0.2-alpha
15
 */
16
trait TypeTrait
17
{
18
    /**
19
     * @return int
20
     */
21
    public abstract function getValue();
22
23
    /**
24
     * @return bool
25
     */
26 3
    public function isPositive()
27
    {
28 3
        return $this->getValue() > 0;
29
    }
30
31
    /**
32
     * @return bool
33
     */
34 5
    public function isNegative()
35
    {
36 5
        return $this->getValue() < 0;
37
    }
38
39
    /**
40
     * @return bool
41
     */
42 6
    public function isZero()
43
    {
44 6
        return $this->getValue() === 0;
45
    }
46
47
    /**
48
     * @return bool
49
     */
50 1
    public function isNegativeOrZero()
51
    {
52 1
        return $this->isNegative() || $this->isZero();
53
    }
54
55
    /**
56
     * @return bool
57
     */
58 1
    public function isPositiveOrZero()
59
    {
60 1
        return $this->isPositive() || $this->isZero();
61
    }
62
}
63