Completed
Push — dev ( 80a148...4ac9b0 )
by Jordan
03:47
created

Line   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 37
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A length() 0 4 1
A points() 0 4 1
A pointsIterator() 0 4 1
1
<?php
2
3
namespace Samsara\Fermat\Shapes\Base;
4
5
use Ds\Set;
6
use Samsara\Fermat\Values\CartesianCoordinate;
7
use Samsara\Fermat\Values\ImmutableNumber;
8
9
class Line
10
{
11
12
    /**
13
     * @var ImmutableNumber
14
     */
15
    private $length;
16
17
    /**
18
     * @var Set
19
     */
20
    private $points;
21
22
    public function __construct(CartesianCoordinate $coordinate1, CartesianCoordinate $coordinate2)
23
    {
24
        $this->points = new Set();
25
        $this->points->add($coordinate1);
26
        $this->points->add($coordinate2);
27
        $this->length = $coordinate1->distanceTo($coordinate2);
28
    }
29
30
    public function length()
31
    {
32
        return $this->length;
33
    }
34
35
    public function points()
36
    {
37
        return $this->points->toArray();
38
    }
39
40
    public function pointsIterator()
41
    {
42
        return $this->points->getIterator();
43
    }
44
45
}