GeoJSON::format()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Location\Formatter\Coordinate;
6
7
use Location\Coordinate;
8
9
/**
10
 * GeoJSON Coordinate Formatter
11
 *
12
 * @author Marcus Jaschen <[email protected]>
13
 */
14
class GeoJSON implements FormatterInterface
15
{
16
    /**
17
     * @param Coordinate $coordinate
18
     *
19
     * @return string
20
     */
21
    public function format(Coordinate $coordinate): string
22
    {
23
        return json_encode(
24
            [
25
                'type'        => 'Point',
26
                'coordinates' => [
27
                    $coordinate->getLng(),
28
                    $coordinate->getLat(),
29
                ],
30
            ]
31
        );
32
    }
33
}
34