Conditions | 3 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 5.3915 |
Changes | 0 |
1 | <?php |
||
8 | 6 | public function augmentSQL(SQLQuery &$query) |
|
9 | { |
||
10 | 6 | $address = Controller::curr()->getRequest()->getVar('Address'); |
|
11 | 6 | if ($this->owner->hasMethod('updateAddressValue')) { |
|
12 | $address = $this->owner->updateAddressValue($address); |
||
13 | } |
||
14 | 6 | if ($address) { // on frontend |
|
15 | $coords = GoogleGeocoding::address_to_point($address); |
||
16 | |||
17 | $Lat = $coords['lat']; |
||
18 | $Lng = $coords['lng']; |
||
19 | |||
20 | $query |
||
21 | ->addSelect(array( |
||
22 | '( 3959 * acos( cos( radians(' . $Lat . ') ) * cos( radians( `Lat` ) ) * cos( radians( `Lng` ) - radians(' . $Lng . ') ) + sin( radians(' . $Lat . ') ) * sin( radians( `Lat` ) ) ) ) AS distance', |
||
23 | )); |
||
24 | } |
||
25 | 6 | } |
|
26 | } |
||
27 |