Completed
Push — milestone/4.0 ( 4a7219...1803cd )
by Marcus
01:48
created

GeoJSON   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Phpgeo\Formatter\Point;
6
7
use Phpgeo\Point;
8
9
/**
10
 * GeoJSON Coordinates Formatter
11
 *
12
 * @author Marcus Jaschen <[email protected]>
13
 */
14
class GeoJSON implements FormatterInterface
15
{
16
    /**
17
     * @param Point $point
18
     *
19
     * @return string
20
     */
21
    public function format(Point $point): string
22
    {
23
        return json_encode(
24
            [
25
                'type' => 'Point',
26
                'coordinates' => [
27
                    $point->getLng(),
28
                    $point->getLat(),
29
                ],
30
            ],
31
            JSON_THROW_ON_ERROR
32
        );
33
    }
34
}
35