Conditions | 8 |
Paths | 30 |
Total Lines | 33 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function __construct(Line ...$lines) |
||
24 | { |
||
25 | $this->lines = new Set($lines); |
||
26 | $this->points = new Set(); |
||
27 | $this->linesByPoint = new Map(); |
||
28 | |||
29 | foreach ($lines as $line) { |
||
30 | /** @var CartesianCoordinate $point */ |
||
31 | foreach ($line->pointsIterator() as $point) { |
||
32 | if (!$this->points->contains($point)) { |
||
33 | $this->points->add($point); |
||
34 | } |
||
35 | |||
36 | if (!$this->linesByPoint->hasKey($point)) { |
||
37 | $this->linesByPoint->put($point, new Set()); |
||
38 | } |
||
39 | |||
40 | if (!$this->linesByPoint->get($point)->contains($line)) { |
||
41 | $this->linesByPoint->get($point)->add($line); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | $this->closed = true; |
||
47 | |||
48 | /** @var Set $pointLines */ |
||
49 | foreach ($this->linesByPoint as $pointLines) { |
||
50 | if ($pointLines->count() < 2) { |
||
51 | $this->closed = false; |
||
52 | break; |
||
53 | } |
||
54 | } |
||
55 | } |
||
56 | |||
62 | } |