Completed
Pull Request — master (#60)
by
unknown
01:14
created

BoundsFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A expandFromCenterCoordinate() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Location\Factory;
6
7
use Location\Bearing\BearingInterface;
8
use Location\Bounds;
9
use Location\Coordinate;
10
11
/**
12
 * Bounds Factory
13
 */
14
class BoundsFactory
15
{
16
    /**
17
     *
18
     * @param Coordinate $center
19
     * @param float $distance in meter
20
     * @param BearingInterface $bearing
21
     * @return Bounds
22
     * @throws \InvalidArgumentException if bounds crosses the 180/-180 degrees meridian.
23
     */
24
    public static function expandFromCenterCoordinate(
25
        Coordinate $center,
26
        float $distance,
27
        BearingInterface $bearing
28
    ): Bounds {
29
        $NW = $bearing->calculateDestination($center, 315, $distance);
30
        $SE = $bearing->calculateDestination($center, 135, $distance);
31
        return new Bounds($NW, $SE);
32
    }
33
}
34