Completed
Push — master ( d791dd...2d8ee5 )
by Ventaquil
02:14
created

Point1D   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 31
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A checkX() 0 6 2
A __construct() 0 6 1
A move() 0 8 1
A lowerDimension() 0 4 1
1
<?php
2
3
namespace PHPAlgorithms\GraphTools;
4
5
use PHPAlgorithms\GraphTools\Interfaces\PointInterface;
6
use PHPAlgorithms\GraphTools\Exceptions\PointException;
7
8
class Point1D extends AbstractPoint implements PointInterface {
9
    protected $x;
10
11
    protected function checkX($x)
12
    {
13
        if (!is_numeric($x)) {
14
            throw new PointException("x: {$x} must be numeric value");
15
        }
16
    }
17
18
    public function __construct($x)
19
    {
20
        $this->checkX($x);
21
22
        $this->x = $x;
23
    }
24
25
    public function move($x = 0)
26
    {
27
        $this->checkX($x);
28
29
        $this->x += $x;
30
31
        return $this;
32
    }
33
34
    public function lowerDimension()
35
    {
36
        return new AbstractPoint();
37
    }
38
}
39