Coordinator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 6
c 1
b 0
f 0
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getWidth() 0 3 1
A __construct() 0 2 1
A getX() 0 3 1
A getY() 0 3 1
A getHeight() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PrinsFrank\PhpGeoSVG\Coordinator;
6
7
use PrinsFrank\PhpGeoSVG\Geometry\BoundingBox\BoundingBox;
8
use PrinsFrank\PhpGeoSVG\Geometry\Position\Position;
9
use PrinsFrank\PhpGeoSVG\Projection\Projection;
10
use PrinsFrank\PhpGeoSVG\Scale\Scale;
11
12
class Coordinator
13
{
14
    public const BASE_SCALE_FACTOR = 2;
15
16 4
    public function __construct(private Projection $projection, private BoundingBox $boundingBox, private Scale $scale)
17
    {
18
    }
19
20 1
    public function getWidth(): float
21
    {
22 1
        return ($this->boundingBox->getWidth() / Position::TOTAL_LONGITUDE * $this->projection->getMaxX()) * $this->scale->getFactorX() * self::BASE_SCALE_FACTOR;
23
    }
24
25 1
    public function getHeight(): float
26
    {
27 1
        return ($this->boundingBox->getHeight() / Position::TOTAL_LATITUDE * $this->projection->getMaxY()) * $this->scale->getFactorY() * self::BASE_SCALE_FACTOR;
28
    }
29
30 1
    public function getX(Position $position): float
31
    {
32 1
        return $this->boundingBox->boundX($position, $this->projection) * $this->scale->getFactorX() * self::BASE_SCALE_FACTOR;
33
    }
34
35 1
    public function getY(Position $position): float
36
    {
37 1
        return $this->boundingBox->boundY($position, $this->projection) * $this->scale->getFactorY() * self::BASE_SCALE_FACTOR;
38
    }
39
}
40