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

Point3D::checkZ()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace PHPAlgorithms\GraphTools;
4
5
use PHPAlgorithms\GraphTools\Interfaces\PointInterface;
6
use PHPAlgorithms\GraphTools\Exceptions\PointException;
7
8 View Code Duplication
class Point3D extends Point2D implements PointInterface {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
    protected $z;
10
11
    protected function checkZ($z)
12
    {
13
        if (!is_numeric($z)) {
14
            throw new PointException("z: {$z} must be numeric value");
15
        }
16
    }
17
18
    public function __construct($x, $y, $z)
19
    {
20
        parent::__construct($x, $y);
21
22
        $this->checkZ($z);
23
24
        $this->z = $z;
25
    }
26
27
    public function move($x = 0, $y = 0, $z = 0)
28
    {
29
        parent::move($x, $y);
30
31
        $this->checkZ($z);
32
33
        $this->z += $z;
34
35
        return $this;
36
    }
37
38
    public function lowerDimension()
39
    {
40
        return new Point2D($this->x, $this->y);
41
    }
42
}
43