Completed
Push — master ( 535042...d7d013 )
by Ventaquil
02:21
created

Line3D::countLength()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * @author ventaquil <[email protected]>
5
 * @licence MIT
6
 */
7
8
namespace PHPAlgorithms\GraphTools;
9
10
use PHPAlgorithms\GraphTools\Interfaces\LineInterface;
11
use PHPAlgorithms\GraphTools\Exceptions\LineException;
12
13
/**
14
 * Class Line3D
15
 * @package PHPAlgorithms\GraphTools
16
 */
17
class Line3D extends Line2D implements LineInterface {
18
    /**
19
     * Method checks sent variable and throws LineException if it is not an Point3D instance.
20
     *
21
     * @param mixed $point Variable to check.
22
     * @throws LineException If sent argument is not an Point3D instance.
23
     */
24
    protected function checkPoint($point)
25
    {
26
        if (!($point instanceof Point3D)) {
27
            throw new LineException('This is not a point');
28
        }
29
    }
30
31
    /**
32
     * Method counts width.
33
     *
34
     * return float Line width.
35
     */
36
    protected function countLength()
37
    {
38
        return sqrt(pow($this->from->x - $this->to->x, 2) + pow($this->from->y - $this->to->y, 2) + pow($this->from->z - $this->to->z, 2));
0 ignored issues
show
Bug introduced by
The property x does not seem to exist in PHPAlgorithms\GraphTools\Point.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Bug introduced by
The property y does not seem to exist in PHPAlgorithms\GraphTools\Point.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Bug introduced by
The property z does not seem to exist in PHPAlgorithms\GraphTools\Point.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
39
    }
40
41
    /**
42
     * Line3D constructor.
43
     *
44
     * @param mixed $from First end of the line.
45
     * @param mixed $to Second end of the line.
46
     */
47
    public function __construct($from, $to)
48
    {
49
        parent::__construct($from, $to);
50
    }
51
}
52