Completed
Push — master ( 77cc75...3bc278 )
by Marcus
01:17
created

Cartesian::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Location\Utility;
6
7
class Cartesian
8
{
9
    /**
10
     * @var float
11
     */
12
    private $x;
13
    /**
14
     * @var float
15
     */
16
    private $y;
17
    /**
18
     * @var float
19
     */
20
    private $z;
21
22
    /**
23
     * Cartesian constructor.
24
     *
25
     * @param $x
26
     * @param $y
27
     * @param $z
28
     */
29
    public function __construct(float $x, float $y, float $z)
30
    {
31
        $this->x = $x;
32
        $this->y = $y;
33
        $this->z = $z;
34
    }
35
36
    /**
37
     * @return float
38
     */
39
    public function getX(): float
40
    {
41
        return $this->x;
42
    }
43
44
    /**
45
     * @return float
46
     */
47
    public function getY(): float
48
    {
49
        return $this->y;
50
    }
51
52
    /**
53
     * @return float
54
     */
55
    public function getZ(): float
56
    {
57
        return $this->z;
58
    }
59
60
    /**
61
     * @param Cartesian $other
62
     *
63
     * @return Cartesian
64
     */
65
    public function add(Cartesian $other): Cartesian
66
    {
67
        return new self(
68
            $this->x + $other->x,
69
            $this->y + $other->y,
70
            $this->z + $other->z
71
        );
72
    }
73
}
74