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

GeoJSON::format()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 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