@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | function geocode( $address ) { |
| 45 | 45 | |
| 46 | - $location = new \WP_Error(100, 'No results found', array( 'address' => $address ) ); |
|
| 46 | + $location = new \WP_Error( 100, 'No results found', array( 'address' => $address ) ); |
|
| 47 | 47 | $url = $this->_make_url( $address ); |
| 48 | 48 | |
| 49 | 49 | $response = $this->_make_request( $url ); |
| 50 | 50 | |
| 51 | - if ( ! is_wp_error( $response ) && count( $response['results'] ) > 0 ) { |
|
| 51 | + if ( !is_wp_error( $response ) && count( $response['results'] ) > 0 ) { |
|
| 52 | 52 | $location = $this->_make_location( $response['results'][0] ); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $result_value = ''; |
| 125 | 125 | |
| 126 | - if ( isset( $results['address_components'] ) ) { |
|
| 126 | + if ( isset($results['address_components']) ) { |
|
| 127 | 127 | foreach ( $results['address_components'] as $component ) { |
| 128 | 128 | if ( $component['types'][0] === $value ) { |
| 129 | 129 | $result_value = $component['short_name']; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $cache_key = md5( serialize( $url ) ); |
| 169 | 169 | |
| 170 | - if ( ! $data = wp_cache_get( $cache_key ) ) { |
|
| 170 | + if ( !$data = wp_cache_get( $cache_key ) ) { |
|
| 171 | 171 | $data = wp_remote_get( $url ); |
| 172 | 172 | wp_cache_add( $cache_key, $data, 300 ); |
| 173 | 173 | } |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | function latitude() { |
| 96 | 96 | |
| 97 | - if ( is_null( $this->_latitude ) && ! is_wp_error( $this->location() ) ) { |
|
| 98 | - $this->_latitude =$this->location()->latitude(); |
|
| 97 | + if ( is_null( $this->_latitude ) && !is_wp_error( $this->location() ) ) { |
|
| 98 | + $this->_latitude = $this->location()->latitude(); |
|
| 99 | 99 | } |
| 100 | 100 | return doubleval( $this->_latitude ); |
| 101 | 101 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return Location|\WP_Error |
| 105 | 105 | */ |
| 106 | 106 | function location() { |
| 107 | - if ( ! is_object( $this->_location ) ) { |
|
| 107 | + if ( !is_object( $this->_location ) ) { |
|
| 108 | 108 | $this->_location = $this->_geocoder()->geocode( $this->_address ); |
| 109 | 109 | } |
| 110 | 110 | return $this->_location; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | function longitude() { |
| 117 | 117 | |
| 118 | - if ( is_null( $this->_longitude ) && ! is_wp_error( $this->location() ) ) { |
|
| 118 | + if ( is_null( $this->_longitude ) && !is_wp_error( $this->location() ) ) { |
|
| 119 | 119 | $this->_longitude = doubleval( $this->location()->longitude() ); |
| 120 | 120 | } |
| 121 | 121 | return doubleval( $this->_longitude ); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @return Geocoder |
| 162 | 162 | */ |
| 163 | 163 | private function _geocoder() { |
| 164 | - if (! is_object( $this->_geocoder ) ) { |
|
| 164 | + if ( !is_object( $this->_geocoder ) ) { |
|
| 165 | 165 | $this->_geocoder = new Geocoder(); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -20,38 +20,38 @@ discard block |
||
| 20 | 20 | private $_geocoder; |
| 21 | 21 | |
| 22 | 22 | public function setUp() { |
| 23 | - $this->_geocoder = new Geocoder(['api_key' => '']); |
|
| 23 | + $this->_geocoder = new Geocoder( ['api_key' => ''] ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @covers ::_make_request |
| 28 | 28 | */ |
| 29 | 29 | public function testMakeRequest() { |
| 30 | - $url = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 31 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', $url); |
|
| 30 | + $url = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 31 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', $url ); |
|
| 32 | 32 | |
| 33 | - $this->assertInternalType('array', $response); |
|
| 33 | + $this->assertInternalType( 'array', $response ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @covers ::_make_request |
| 38 | 38 | */ |
| 39 | 39 | public function testMakeRequestError404() { |
| 40 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', 'https://maps.googleapis.com/maps/api/geo'); |
|
| 40 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', 'https://maps.googleapis.com/maps/api/geo' ); |
|
| 41 | 41 | |
| 42 | - $this->assertInstanceOf('WP_Error', $response); |
|
| 43 | - $this->assertObjectHasAttribute('errors', $response); |
|
| 44 | - $this->assertArrayHasKey('404', $response->errors); |
|
| 42 | + $this->assertInstanceOf( 'WP_Error', $response ); |
|
| 43 | + $this->assertObjectHasAttribute( 'errors', $response ); |
|
| 44 | + $this->assertArrayHasKey( '404', $response->errors ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @covers ::_get_data |
| 49 | 49 | */ |
| 50 | 50 | public function testGetData() { |
| 51 | - $url = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 52 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_get_data', $url); |
|
| 51 | + $url = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 52 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_get_data', $url ); |
|
| 53 | 53 | |
| 54 | - $this->assertInternalType('array', $response); |
|
| 54 | + $this->assertInternalType( 'array', $response ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -59,26 +59,26 @@ discard block |
||
| 59 | 59 | * @covers ::_make_location |
| 60 | 60 | */ |
| 61 | 61 | public function testGeocode() { |
| 62 | - $location = $this->_geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); |
|
| 62 | + $location = $this->_geocoder->geocode( '1600 Amphitheatre Parkway, Mountain View, CA' ); |
|
| 63 | 63 | |
| 64 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location); |
|
| 65 | - $this->assertEquals('1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->address()); |
|
| 66 | - $this->assertEquals('1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->formatted_address()); |
|
| 67 | - $this->assertInternalType('double', $location->latitude()); |
|
| 68 | - $this->assertInternalType('double', $location->longitude()); |
|
| 69 | - $this->assertEquals('ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id()); |
|
| 70 | - $this->assertInternalType('array', $location->viewport()); |
|
| 71 | - $this->assertArrayHasKey('northeast', $location->viewport()); |
|
| 72 | - $this->assertArrayHasKey('southwest', $location->viewport()); |
|
| 73 | - $this->assertInternalType('array', $location->viewport()['northeast']); |
|
| 74 | - $this->assertArrayHasKey('lat', $location->viewport()['northeast']); |
|
| 75 | - $this->assertArrayHasKey('lng', $location->viewport()['northeast']); |
|
| 76 | - $this->assertInternalType('double', $location->viewport()['northeast']['lat']); |
|
| 77 | - $this->assertInternalType('double', $location->viewport()['northeast']['lng']); |
|
| 78 | - $this->assertInternalType('array', $location->viewport()['southwest']); |
|
| 79 | - $this->assertArrayHasKey('lat', $location->viewport()['southwest']); |
|
| 80 | - $this->assertArrayHasKey('lng', $location->viewport()['southwest']); |
|
| 81 | - $this->assertInternalType('double', $location->viewport()['southwest']['lat']); |
|
| 82 | - $this->assertInternalType('double', $location->viewport()['southwest']['lng']); |
|
| 64 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location ); |
|
| 65 | + $this->assertEquals( '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->address() ); |
|
| 66 | + $this->assertEquals( '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', $location->formatted_address() ); |
|
| 67 | + $this->assertInternalType( 'double', $location->latitude() ); |
|
| 68 | + $this->assertInternalType( 'double', $location->longitude() ); |
|
| 69 | + $this->assertEquals( 'ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id() ); |
|
| 70 | + $this->assertInternalType( 'array', $location->viewport() ); |
|
| 71 | + $this->assertArrayHasKey( 'northeast', $location->viewport() ); |
|
| 72 | + $this->assertArrayHasKey( 'southwest', $location->viewport() ); |
|
| 73 | + $this->assertInternalType( 'array', $location->viewport()['northeast'] ); |
|
| 74 | + $this->assertArrayHasKey( 'lat', $location->viewport()['northeast'] ); |
|
| 75 | + $this->assertArrayHasKey( 'lng', $location->viewport()['northeast'] ); |
|
| 76 | + $this->assertInternalType( 'double', $location->viewport()['northeast']['lat'] ); |
|
| 77 | + $this->assertInternalType( 'double', $location->viewport()['northeast']['lng'] ); |
|
| 78 | + $this->assertInternalType( 'array', $location->viewport()['southwest'] ); |
|
| 79 | + $this->assertArrayHasKey( 'lat', $location->viewport()['southwest'] ); |
|
| 80 | + $this->assertArrayHasKey( 'lng', $location->viewport()['southwest'] ); |
|
| 81 | + $this->assertInternalType( 'double', $location->viewport()['southwest']['lat'] ); |
|
| 82 | + $this->assertInternalType( 'double', $location->viewport()['southwest']['lng'] ); |
|
| 83 | 83 | } |
| 84 | 84 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | 29 | public function setUp() { |
| 30 | - $this->_geocoder = new Geocoder(['api_key' => $this->_api_key]); |
|
| 30 | + $this->_geocoder = new Geocoder( ['api_key' => $this->_api_key] ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -35,54 +35,54 @@ discard block |
||
| 35 | 35 | * @covers ::api_key |
| 36 | 36 | */ |
| 37 | 37 | public function testConstructorWithAPIKey() { |
| 38 | - $this->assertEquals($this->_api_key, $this->_geocoder->api_key()); |
|
| 38 | + $this->assertEquals( $this->_api_key, $this->_geocoder->api_key() ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @covers ::_make_url |
| 43 | 43 | */ |
| 44 | 44 | public function testMakeUrl() { |
| 45 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_url', '123 Anywhere Street New York 10001'); |
|
| 45 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_url', '123 Anywhere Street New York 10001' ); |
|
| 46 | 46 | |
| 47 | - $this->assertInternalType('string', $response); |
|
| 48 | - $this->assertRegExp('/address\=123\+Anywhere\+Street\+New\+York\+10001/', $response); |
|
| 49 | - $this->assertRegExp("/key={$this->_api_key}/", $response); |
|
| 47 | + $this->assertInternalType( 'string', $response ); |
|
| 48 | + $this->assertRegExp( '/address\=123\+Anywhere\+Street\+New\+York\+10001/', $response ); |
|
| 49 | + $this->assertRegExp( "/key={$this->_api_key}/", $response ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @covers ::_get_data |
| 54 | 54 | */ |
| 55 | 55 | public function testGetDataCache() { |
| 56 | - wp_cache_add( md5(serialize('foo.bar')), 'foobar'); |
|
| 56 | + wp_cache_add( md5( serialize( 'foo.bar' ) ), 'foobar' ); |
|
| 57 | 57 | |
| 58 | - $this->assertEquals('foobar', $this->reflectionMethodInvokeArgs($this->_geocoder, '_get_data', 'foo.bar')); |
|
| 58 | + $this->assertEquals( 'foobar', $this->reflectionMethodInvokeArgs( $this->_geocoder, '_get_data', 'foo.bar' ) ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @covers ::_make_location |
| 63 | 63 | */ |
| 64 | 64 | public function testMakeLocation() { |
| 65 | - $response = json_decode(file_get_contents(TEST_INCLUDES_DIR . '/geocoder-response.json'), true); |
|
| 66 | - $location = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_location', $response['results'][0] ); |
|
| 65 | + $response = json_decode( file_get_contents( TEST_INCLUDES_DIR.'/geocoder-response.json' ), true ); |
|
| 66 | + $location = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_location', $response['results'][0] ); |
|
| 67 | 67 | |
| 68 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location); |
|
| 69 | - $this->assertEquals('1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->address()); |
|
| 70 | - $this->assertEquals('1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->formatted_address()); |
|
| 71 | - $this->assertEquals(37.4224764, $location->latitude()); |
|
| 68 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Location', $location ); |
|
| 69 | + $this->assertEquals( '1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->address() ); |
|
| 70 | + $this->assertEquals( '1600 Amphitheatre Parkway, Mountain View, CA 94043, USA', $location->formatted_address() ); |
|
| 71 | + $this->assertEquals( 37.4224764, $location->latitude() ); |
|
| 72 | 72 | $this->assertEquals(-122.0842499, $location->longitude()); |
| 73 | - $this->assertEquals('ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id()); |
|
| 74 | - $this->assertInternalType('array', $location->viewport()); |
|
| 75 | - $this->assertArrayHasKey('northeast', $location->viewport()); |
|
| 76 | - $this->assertArrayHasKey('southwest', $location->viewport()); |
|
| 77 | - $this->assertInternalType('array', $location->viewport()['northeast']); |
|
| 78 | - $this->assertArrayHasKey('lat', $location->viewport()['northeast']); |
|
| 79 | - $this->assertArrayHasKey('lng', $location->viewport()['northeast']); |
|
| 80 | - $this->assertEquals(37.4238253802915, $location->viewport()['northeast']['lat']); |
|
| 73 | + $this->assertEquals( 'ChIJ2eUgeAK6j4ARbn5u_wAGqWA', $location->place_id() ); |
|
| 74 | + $this->assertInternalType( 'array', $location->viewport() ); |
|
| 75 | + $this->assertArrayHasKey( 'northeast', $location->viewport() ); |
|
| 76 | + $this->assertArrayHasKey( 'southwest', $location->viewport() ); |
|
| 77 | + $this->assertInternalType( 'array', $location->viewport()['northeast'] ); |
|
| 78 | + $this->assertArrayHasKey( 'lat', $location->viewport()['northeast'] ); |
|
| 79 | + $this->assertArrayHasKey( 'lng', $location->viewport()['northeast'] ); |
|
| 80 | + $this->assertEquals( 37.4238253802915, $location->viewport()['northeast']['lat'] ); |
|
| 81 | 81 | $this->assertEquals(-122.0829009197085, $location->viewport()['northeast']['lng']); |
| 82 | - $this->assertInternalType('array', $location->viewport()['southwest']); |
|
| 83 | - $this->assertArrayHasKey('lat', $location->viewport()['southwest']); |
|
| 84 | - $this->assertArrayHasKey('lng', $location->viewport()['southwest']); |
|
| 85 | - $this->assertEquals(37.4211274197085, $location->viewport()['southwest']['lat']); |
|
| 82 | + $this->assertInternalType( 'array', $location->viewport()['southwest'] ); |
|
| 83 | + $this->assertArrayHasKey( 'lat', $location->viewport()['southwest'] ); |
|
| 84 | + $this->assertArrayHasKey( 'lng', $location->viewport()['southwest'] ); |
|
| 85 | + $this->assertEquals( 37.4211274197085, $location->viewport()['southwest']['lat'] ); |
|
| 86 | 86 | $this->assertEquals(-122.0855988802915, $location->viewport()['southwest']['lng']); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | * @covers ::_make_request |
| 91 | 91 | */ |
| 92 | 92 | public function testMakeRequestInvalidURL() { |
| 93 | - $response = $this->reflectionMethodInvokeArgs($this->_geocoder, '_make_request', 'foo.bar'); |
|
| 94 | - $this->assertInstanceOf('WP_Error', $response); |
|
| 93 | + $response = $this->reflectionMethodInvokeArgs( $this->_geocoder, '_make_request', 'foo.bar' ); |
|
| 94 | + $this->assertInstanceOf( 'WP_Error', $response ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\UnitTests; |
| 4 | 4 | |
| 5 | -require_once dirname( dirname(__DIR__) ) . '/component-google-maps.php'; |
|
| 5 | +require_once dirname( dirname( __DIR__ ) ).'/component-google-maps.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Clubdeuce\WPLib\Components\Google_Maps; |
| 8 | 8 | use Clubdeuce\WPLib\Components\GoogleMaps\Marker; |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function testApiKeySetAndGet() { |
| 23 | 23 | |
| 24 | - Google_Maps::register_api_key('foo'); |
|
| 25 | - $this->assertEquals('foo', Google_Maps::api_key()); |
|
| 24 | + Google_Maps::register_api_key( 'foo' ); |
|
| 25 | + $this->assertEquals( 'foo', Google_Maps::api_key() ); |
|
| 26 | 26 | |
| 27 | 27 | } |
| 28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function testGeocoder() { |
| 33 | 33 | |
| 34 | - $this->assertInstanceOf('Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', Google_Maps::geocoder()); |
|
| 34 | + $this->assertInstanceOf( 'Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', Google_Maps::geocoder() ); |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $map = Google_Maps::make_new_map(); |
| 44 | 44 | |
| 45 | - $this->assertInstanceOf('Clubdeuce\WPLib\Components\GoogleMaps\Map', $map); |
|
| 45 | + $this->assertInstanceOf( 'Clubdeuce\WPLib\Components\GoogleMaps\Map', $map ); |
|
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $conditions = Google_Maps::script_conditions(); |
| 58 | 58 | |
| 59 | - $this->assertInternalType('array', $conditions); |
|
| 60 | - $this->assertContains('is_search', $conditions); |
|
| 59 | + $this->assertInternalType( 'array', $conditions ); |
|
| 60 | + $this->assertContains( 'is_search', $conditions ); |
|
| 61 | 61 | |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function testMakeMarkerByAddress() { |
| 68 | 68 | |
| 69 | - $marker = Google_Maps::make_marker_by_address('1600 Amphitheatre Way'); |
|
| 69 | + $marker = Google_Maps::make_marker_by_address( '1600 Amphitheatre Way' ); |
|
| 70 | 70 | |
| 71 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Marker', $marker); |
|
| 71 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Marker', $marker ); |
|
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function testDrivingDirectionsHref() { |
| 79 | 79 | |
| 80 | - $href = Google_Maps::driving_directions_href('1600 Amphitheatre Way'); |
|
| 80 | + $href = Google_Maps::driving_directions_href( '1600 Amphitheatre Way' ); |
|
| 81 | 81 | |
| 82 | - $this->assertRegExp('#^https:\/\/maps\.google\.com\/maps\?saddr=My\+Location&daddr=1600\+Amphitheatre\+Way#', $href); |
|
| 82 | + $this->assertRegExp( '#^https:\/\/maps\.google\.com\/maps\?saddr=My\+Location&daddr=1600\+Amphitheatre\+Way#', $href ); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function testDrivingDirectionsWithStartAddress() { |
| 90 | 90 | |
| 91 | - $href = Google_Maps::driving_directions_href('1600 Amphitheatre Way', array( 'start' => '1600 Pennsylvania Avenue')); |
|
| 91 | + $href = Google_Maps::driving_directions_href( '1600 Amphitheatre Way', array( 'start' => '1600 Pennsylvania Avenue' ) ); |
|
| 92 | 92 | |
| 93 | - $this->assertRegExp('#^https:\/\/maps\.google\.com\/maps\?saddr=1600\+Pennsylvania\+Avenue&daddr=1600\+Amphitheatre\+Way#', $href); |
|
| 93 | + $this->assertRegExp( '#^https:\/\/maps\.google\.com\/maps\?saddr=1600\+Pennsylvania\+Avenue&daddr=1600\+Amphitheatre\+Way#', $href ); |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function testEvaluateCondition() { |
| 101 | 101 | |
| 102 | - $this->assertTrue($this->reflectionMethodInvokeArgs('\Clubdeuce\WPLib\Components\Google_Maps', '_evaluate_condition', function(){return true;})); |
|
| 103 | - $this->assertFalse($this->reflectionMethodInvokeArgs('\Clubdeuce\WPLib\Components\Google_Maps', '_evaluate_condition', 'foo')); |
|
| 102 | + $this->assertTrue( $this->reflectionMethodInvokeArgs( '\Clubdeuce\WPLib\Components\Google_Maps', '_evaluate_condition', function() {return true; }) ); |
|
| 103 | + $this->assertFalse( $this->reflectionMethodInvokeArgs( '\Clubdeuce\WPLib\Components\Google_Maps', '_evaluate_condition', 'foo' ) ); |
|
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | Google_Maps::_wp_enqueue_scripts_9(); |
| 113 | 113 | |
| 114 | - $this->assertTrue(wp_script_is('google-maps', 'registered')); |
|
| 115 | - $this->assertTrue(wp_script_is('map-control', 'registered')); |
|
| 114 | + $this->assertTrue( wp_script_is( 'google-maps', 'registered' ) ); |
|
| 115 | + $this->assertTrue( wp_script_is( 'map-control', 'registered' ) ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function testWpEnqueueScripts9Enqueue() { |
| 122 | 122 | |
| 123 | - Google_Maps::register_script_condition(function(){return true;}); |
|
| 123 | + Google_Maps::register_script_condition( function() {return true; }); |
|
| 124 | 124 | Google_Maps::_wp_enqueue_scripts_9(); |
| 125 | 125 | |
| 126 | - $this->assertTrue(wp_script_is('jquery', 'enqueued')); |
|
| 127 | - $this->assertTrue(wp_script_is('google-maps', 'enqueued')); |
|
| 128 | - $this->assertTrue(wp_script_is('map-control', 'enqueued')); |
|
| 126 | + $this->assertTrue( wp_script_is( 'jquery', 'enqueued' ) ); |
|
| 127 | + $this->assertTrue( wp_script_is( 'google-maps', 'enqueued' ) ); |
|
| 128 | + $this->assertTrue( wp_script_is( 'map-control', 'enqueued' ) ); |
|
| 129 | 129 | } |
| 130 | 130 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $reflection = new \ReflectionMethod( $class, $method ); |
| 43 | 43 | $reflection->setAccessible( true ); |
| 44 | - if (is_string($class)) { |
|
| 44 | + if ( is_string( $class ) ) { |
|
| 45 | 45 | $class = null; |
| 46 | 46 | } |
| 47 | 47 | return $reflection->invoke( $class ); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $reflection = new \ReflectionMethod( $class, $method ); |
| 59 | 59 | $reflection->setAccessible( true ); |
| 60 | - if (is_string($class)) { |
|
| 60 | + if ( is_string( $class ) ) { |
|
| 61 | 61 | $class = null; |
| 62 | 62 | } |
| 63 | 63 | return $reflection->invoke( $class, $args ); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | static function geocoder() { |
| 63 | 63 | |
| 64 | - if ( ! isset( static::$_geocoder ) ) { |
|
| 65 | - static::$_geocoder = new Geocoder( ['api_key' => self::api_key() ] ); |
|
| 64 | + if ( !isset(static::$_geocoder) ) { |
|
| 65 | + static::$_geocoder = new Geocoder( ['api_key' => self::api_key()] ); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | return static::$_geocoder; |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | $source = sprintf( '%1$s/assets/maps.js', self::source_url() ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - wp_register_script('google-maps', "https://maps.google.com/maps/api/js?v=3&key={$key}", false, '3.0', true ); |
|
| 111 | - wp_register_script('map-control', $source, array( 'jquery', 'google-maps' ), '0.1.2', true ); |
|
| 110 | + wp_register_script( 'google-maps', "https://maps.google.com/maps/api/js?v=3&key={$key}", false, '3.0', true ); |
|
| 111 | + wp_register_script( 'map-control', $source, array( 'jquery', 'google-maps' ), '0.1.2', true ); |
|
| 112 | 112 | |
| 113 | 113 | $conditions = array_map( array( __CLASS__, '_evaluate_condition' ), static::$_script_conditions ); |
| 114 | 114 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param array $args |
| 145 | 145 | * @return string |
| 146 | 146 | */ |
| 147 | - static function driving_directions_href($destination, $args = array() ) { |
|
| 147 | + static function driving_directions_href( $destination, $args = array() ) { |
|
| 148 | 148 | |
| 149 | 149 | $args = wp_parse_args( $args, array( |
| 150 | 150 | 'start' => 'My Location', |