Completed
Branch development (f30b60)
by Daryl
01:58
created
includes/class-geocoder.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
      *
19 19
      * @param array $args
20 20
      */
21
-    function __construct( $args = array() ) {
21
+    function __construct($args = array()) {
22 22
 
23
-        $args = wp_parse_args( $args, array(
24
-            'api_key' => sprintf( __( 'Please set the api key for class %1$s', 'cgm' ), get_called_class() ),
25
-        ) );
23
+        $args = wp_parse_args($args, array(
24
+            'api_key' => sprintf(__('Please set the api key for class %1$s', 'cgm'), get_called_class()),
25
+        ));
26 26
 
27 27
         $this->_api_key = $args['api_key'];
28 28
 
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
      * @param  string $address
42 42
      * @return bool
43 43
      */
44
-    function flush_item_from_cache( $address ) {
44
+    function flush_item_from_cache($address) {
45 45
 
46
-        return wp_cache_delete( $this->_make_cache_key( $this->_make_url( $address ) ) );
46
+        return wp_cache_delete($this->_make_cache_key($this->_make_url($address)));
47 47
 
48 48
     }
49 49
 
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
      * @param  string $address
52 52
      * @return array|\WP_Error
53 53
      */
54
-    function geocode( $address ) {
54
+    function geocode($address) {
55 55
 
56
-        $url       = $this->_make_url( $address );
57
-        $cache_key = $this->_make_cache_key( $url );
56
+        $url       = $this->_make_url($address);
57
+        $cache_key = $this->_make_cache_key($url);
58 58
 
59
-        if ( ! $return = wp_cache_get( $cache_key ) ) {
60
-            if ( wp_http_validate_url( $url ) ) {
61
-                $request = wp_remote_get( $url );
59
+        if (!$return = wp_cache_get($cache_key)) {
60
+            if (wp_http_validate_url($url)) {
61
+                $request = wp_remote_get($url);
62 62
 
63
-                if ( 200 == $request['response']['code'] ) {
64
-                    $return = json_decode( $request['body'], true );
65
-                    wp_cache_set( $cache_key, $return );
63
+                if (200 == $request['response']['code']) {
64
+                    $return = json_decode($request['body'], true);
65
+                    wp_cache_set($cache_key, $return);
66 66
                 }
67 67
 
68
-                if ( ! 200 == $request['response']['code'] ) {
69
-                    $return = new \WP_Error( $request['response']['code'], $request['response']['message'] );
68
+                if (!200 == $request['response']['code']) {
69
+                    $return = new \WP_Error($request['response']['code'], $request['response']['message']);
70 70
                 }
71 71
 
72 72
             }
73 73
         }
74 74
 
75
-        if ( ! is_wp_error( $return ) ) {
76
-            $return = $this->_parse_response( $return );
75
+        if (!is_wp_error($return)) {
76
+            $return = $this->_parse_response($return);
77 77
         }
78 78
 
79 79
         return $return;
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      * @param  string $url
85 85
      * @return string
86 86
      */
87
-    private function _make_cache_key( $url ) {
87
+    private function _make_cache_key($url) {
88 88
 
89
-        return md5( serialize( $url ) );
89
+        return md5(serialize($url));
90 90
 
91 91
     }
92 92
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
      * @param  string $address
95 95
      * @return string
96 96
      */
97
-    private function _make_url( $address ) {
97
+    private function _make_url($address) {
98 98
 
99 99
         return sprintf(
100 100
             'https://maps.googleapis.com/maps/api/geocode/json?address=%1$s&key=%2$s',
101
-            urlencode( filter_var( $address, FILTER_SANITIZE_STRING ) ),
101
+            urlencode(filter_var($address, FILTER_SANITIZE_STRING)),
102 102
             self::api_key()
103 103
         );
104 104
 
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
      * @param  array $response
111 111
      * @return array
112 112
      */
113
-    private function _parse_response( $response ) {
113
+    private function _parse_response($response) {
114 114
 
115 115
         $return = array();
116 116
 
117
-        if ( isset( $response['results'][0]['geometry']['location'] ) ) {
118
-            $return['lat']  = $response['results'][0]['geometry']['location']['lat'];
117
+        if (isset($response['results'][0]['geometry']['location'])) {
118
+            $return['lat'] = $response['results'][0]['geometry']['location']['lat'];
119 119
             $return['lng'] = $response['results'][0]['geometry']['location']['lng'];
120 120
         }
121 121
 
Please login to merge, or discard this patch.
includes/class-location-view.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,6 +6,6 @@
 block discarded – undo
6 6
  * Class Location_View
7 7
  * @package Clubdeuce\WPLib\Components\GoogleMaps
8 8
  */
9
-class Location_View extends \WPLib_View_Base  {
9
+class Location_View extends \WPLib_View_Base {
10 10
 
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-map-model.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     /**
24 24
      * @param Location $location
25 25
      */
26
-    function add_location( Location $location ) {
26
+    function add_location(Location $location) {
27 27
 
28 28
         $this->_locations[] = $location;
29 29
 
Please login to merge, or discard this patch.