Point   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 8
c 3
b 0
f 0
lcom 1
cbo 0
dl 0
loc 63
ccs 15
cts 18
cp 0.8333
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isEmpty() 0 4 2
B compare() 0 17 5
1
<?php
2
3
namespace Recca0120\Twzipcode;
4
5
class Point
6
{
7
    /**
8
     * $x.
9
     *
10
     * @var int
11
     */
12
    public $x = 0;
13
14
    /**
15
     * $y.
16
     *
17
     * @var int
18
     */
19
    public $y = 0;
20
21
    /**
22
     * __construct.
23
     *
24
     * @param int $x
25
     * @param int $y
26
     */
27 37
    public function __construct($x = 0, $y = 0)
28
    {
29 37
        $this->x = $x;
30 37
        $this->y = $y;
31 37
    }
32
33
    /**
34
     * empty.
35
     *
36
     * @return bool
37
     */
38 34
    public function isEmpty()
39
    {
40 34
        return $this->x === 0 && $this->y === 0;
41
    }
42
43
    /**
44
     * compare.
45
     *
46
     * @param Point $point
47
     * @param string $operator
48
     * @return bool
49
     */
50 22
    public function compare(self $point, $operator = '=')
51
    {
52 22
        $sum = $this->x * 10 + $this->y;
53 22
        $sum2 = $point->x * 10 + $point->y;
54
        switch ($operator) {
55 22
            case '>':
56
                return $sum > $sum2;
57 22
            case '>=':
58 10
                return $sum >= $sum2;
59 17
            case '<':
60
                return $sum < $sum2;
61 17
            case '<=':
62 17
                return $sum <= $sum2;
63
        }
64
65
        return $sum === $sum2;
66
    }
67
}
68