1 | <?php |
||
5 | trait Geocoding |
||
6 | { |
||
7 | /** |
||
8 | * Add one or more geospatial items to the specified key. This function must |
||
9 | * be called with at least one longitude, latitude, member triplet. |
||
10 | * |
||
11 | * @param string $key |
||
12 | * @param float $longitude |
||
13 | * @param float $latitude |
||
14 | * @param string $member |
||
15 | * @param $locations |
||
16 | * |
||
17 | * @return int The number of elements added to the geospatial key. |
||
18 | */ |
||
19 | public function geoAdd(string $key, float $longitude, float $latitude, string $member, ...$locations): int |
||
23 | |||
24 | /** |
||
25 | * Retrieve Geohash strings for one or more elements of a geospatial index. |
||
26 | * |
||
27 | * @param string $key |
||
28 | * @param string $member |
||
29 | * @param splat $members |
||
30 | * |
||
31 | * @return array One or more Redis Geohash encoded strings. |
||
32 | */ |
||
33 | public function geoHash(string $key, string $member, ...$members): array |
||
37 | |||
38 | /** |
||
39 | * Return longitude, latitude positions for each requested member. |
||
40 | * |
||
41 | * @param string $key |
||
42 | * @param string $member |
||
43 | * @param splat $members |
||
44 | * |
||
45 | * @return array One or more longitude/latitude positions |
||
46 | */ |
||
47 | public function geoPos(string $key, string $member, ...$members): array |
||
51 | |||
52 | /** |
||
53 | * Return the distance between two members in a geospatial set. If units |
||
54 | * are passed it must be one of the following values:. |
||
55 | * |
||
56 | * @param string $key |
||
57 | * @param string $member1 |
||
58 | * @param string $member2 |
||
59 | * @param string $unit |
||
60 | * |
||
61 | * @return float |
||
62 | */ |
||
63 | public function geoDist(string $key, string $member1, string $member2, string $unit = 'm'): float |
||
67 | |||
68 | /** |
||
69 | * Return members of a set with geospatial information that are within the |
||
70 | * radius specified by the caller. |
||
71 | * |
||
72 | * @param string $key |
||
73 | * @param float $longitude |
||
74 | * @param float $latitude |
||
75 | * @param float $radius |
||
76 | * @param string $unit |
||
77 | * @param array $options |
||
78 | * |
||
79 | * @return array When no STORE option is passed, this function |
||
80 | * returns an array of results. |
||
81 | */ |
||
82 | public function geoRadius( |
||
92 | |||
93 | /** |
||
94 | * This method is identical to geoRadius except that instead of passing a |
||
95 | * longitude and latitude as the "source" you pass an existing member in |
||
96 | * the geospatial set. |
||
97 | * |
||
98 | * @param string $key |
||
99 | * @param string $member |
||
100 | * @param float $radius |
||
101 | * @param string $unit |
||
102 | * @param array $options |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | public function geoRadiusByMember( |
||
115 | } |
||
116 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: