geo_hash_decode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
use MuCTS\GeoHash\GeoHash;
4
5
if (!function_exists('geo_hash')) {
6
    function geo_hash(): GeoHash
7
    {
8
        return new GeoHash();
9
    }
10
}
11
12
if (!function_exists('geo_hash_encode')) {
13
    /**
14
     * Decode a geo hash and return an array with decimal lat,long in it
15
     *
16
     * @param float $lat
17
     * @param float $lon
18
     * @param null|int $numBits
19
     * @return string
20
     */
21
    function geo_hash_encode(float $lat, float $lon, ?int $numBits = null): string
22
    {
23
        return geo_hash()->setBits($numBits)->encode($lat, $lon);
24
    }
25
}
26
27
if (!function_exists('geo_hash_decode')) {
28
    /**
29
     * Geo Hash to Latitude and longitude
30
     *
31
     * @param string $geoHash
32
     * @return array
33
     */
34
    function geo_hash_decode(string $geoHash): array
35
    {
36
        return geo_hash()->decode($geoHash);
37
    }
38
}