Cartesian   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 67
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getX() 0 4 1
A getY() 0 4 1
A getZ() 0 4 1
A add() 0 8 1
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