@@ -6,6 +6,6 @@ |
||
| 6 | 6 | * Class Marker_View |
| 7 | 7 | * @package Clubdeuce\WPLib\Components\GoogleMaps |
| 8 | 8 | */ |
| 9 | -class Marker_View extends \WPLib_View_Base { |
|
| 9 | +class Marker_View extends \WPLib_View_Base { |
|
| 10 | 10 | |
| 11 | 11 | } |
| 12 | 12 | \ No newline at end of file |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | public function setUp() { |
| 35 | - $this->_location = new Location([ |
|
| 35 | + $this->_location = new Location( [ |
|
| 36 | 36 | 'address' => '123 Anywhere Street Anywhere NY', |
| 37 | 37 | 'formatted_address' => '123 Anywhere Street, Anywhere, NY 12345 USA', |
| 38 | 38 | 'latitude' => 100.12345, |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | 'place_id' => 'foobar', |
| 41 | 41 | 'types' => ['foo', 'bar'], |
| 42 | 42 | 'viewport' => ['northeast' => ['lat' => 100.12346, 'lng' => -100.12344], 'southwest' => ['lat' => 100.12344, 'lng' => -100.12346]], |
| 43 | - ]); |
|
| 43 | + ] ); |
|
| 44 | 44 | |
| 45 | - $this->_geocoder = \Mockery::mock('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder'); |
|
| 46 | - $this->_geocoder->shouldReceive('geocode')->andReturn($this->_location); |
|
| 45 | + $this->_geocoder = \Mockery::mock( '\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder' ); |
|
| 46 | + $this->_geocoder->shouldReceive( 'geocode' )->andReturn( $this->_location ); |
|
| 47 | 47 | |
| 48 | - $this->_model = new Marker_Model([ |
|
| 48 | + $this->_model = new Marker_Model( [ |
|
| 49 | 49 | 'address' => $this->_address, |
| 50 | 50 | 'geocoder' => $this->_geocoder, |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | * @covers ::latitude |
| 57 | 57 | */ |
| 58 | 58 | public function testLatitude() { |
| 59 | - $this->assertEquals(100.12345, $this->_model->latitude()); |
|
| 59 | + $this->assertEquals( 100.12345, $this->_model->latitude() ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @covers ::location |
| 64 | 64 | */ |
| 65 | 65 | public function testLocation() { |
| 66 | - $this->assertEquals($this->_location, $this->_model->location()); |
|
| 66 | + $this->assertEquals( $this->_location, $this->_model->location() ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @covers ::_geocoder |
| 78 | 78 | */ |
| 79 | 79 | public function testGeocoder() { |
| 80 | - $this->assertEquals($this->_geocoder, $this->reflectionMethodInvoke($this->_model, '_geocoder')); |
|
| 80 | + $this->assertEquals( $this->_geocoder, $this->reflectionMethodInvoke( $this->_model, '_geocoder' ) ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -85,6 +85,6 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function testCreateGeocoder() { |
| 87 | 87 | $marker_model = new Marker_Model(); |
| 88 | - $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', $this->reflectionMethodInvoke($marker_model, '_geocoder')); |
|
| 88 | + $this->assertInstanceOf( '\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', $this->reflectionMethodInvoke( $marker_model, '_geocoder' ) ); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | \ No newline at end of file |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | <script type="application/javascript"> |
| 13 | 13 | jQuery(document).ready(function() { |
| 14 | 14 | generate_map( |
| 15 | - "<?php echo esc_js($map_id); ?>", |
|
| 16 | - <?php echo json_encode($map_params); ?>, |
|
| 17 | - <?php echo json_encode($markers); ?>, |
|
| 18 | - <?php echo json_encode($info_windows); ?> |
|
| 15 | + "<?php echo esc_js( $map_id ); ?>", |
|
| 16 | + <?php echo json_encode( $map_params ); ?>, |
|
| 17 | + <?php echo json_encode( $markers ); ?>, |
|
| 18 | + <?php echo json_encode( $info_windows ); ?> |
|
| 19 | 19 | ); |
| 20 | 20 | }); |
| 21 | 21 | </script> |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function color() { |
| 40 | 40 | |
| 41 | - return (string)$this->_color; |
|
| 41 | + return ( string ) $this->_color; |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function font_family() { |
| 49 | 49 | |
| 50 | - return (string)$this->_font_family; |
|
| 50 | + return ( string ) $this->_font_family; |
|
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function font_size() { |
| 58 | 58 | |
| 59 | - return (string)$this->_font_size; |
|
| 59 | + return ( string ) $this->_font_size; |
|
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | function font_weight() { |
| 67 | 67 | |
| 68 | - return (string)$this->_font_weight; |
|
| 68 | + return ( string ) $this->_font_weight; |
|
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | function text() { |
| 76 | 76 | |
| 77 | - return (string)$this->_text; |
|
| 77 | + return ( string ) $this->_text; |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | ]; |
| 102 | 102 | |
| 103 | 103 | $args = array_filter( $args, function( $value ) { |
| 104 | - return ! is_null( $value ); |
|
| 104 | + return !is_null( $value ); |
|
| 105 | 105 | } ); |
| 106 | 106 | |
| 107 | - if ( empty( $args['text'] ) ) { |
|
| 107 | + if ( empty($args['text']) ) { |
|
| 108 | 108 | $args = ''; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | private $_location; |
| 20 | 20 | |
| 21 | 21 | public function setUp() { |
| 22 | - $this->_location = new Location_Model([ |
|
| 22 | + $this->_location = new Location_Model( [ |
|
| 23 | 23 | 'address' => '1600 Amphitheatre Parkway Mountain View CA', |
| 24 | 24 | 'formatted_address' => '1600 Amphitheatre Parkway, Mountain View, CA, 12345', |
| 25 | 25 | 'latitude' => 100.12345, |
@@ -33,21 +33,21 @@ discard block |
||
| 33 | 33 | * @covers ::__call |
| 34 | 34 | */ |
| 35 | 35 | public function testAddress() { |
| 36 | - $this->assertEquals('1600 Amphitheatre Parkway Mountain View CA', $this->_location->address()); |
|
| 36 | + $this->assertEquals( '1600 Amphitheatre Parkway Mountain View CA', $this->_location->address() ); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @covers ::__call |
| 41 | 41 | */ |
| 42 | 42 | public function testFormattedAddress() { |
| 43 | - $this->assertEquals('1600 Amphitheatre Parkway, Mountain View, CA, 12345', $this->_location->formatted_address()); |
|
| 43 | + $this->assertEquals( '1600 Amphitheatre Parkway, Mountain View, CA, 12345', $this->_location->formatted_address() ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @covers ::__call |
| 48 | 48 | */ |
| 49 | 49 | public function testLatitude() { |
| 50 | - $this->assertEquals(100.12345, $this->_location->latitude()); |
|
| 50 | + $this->assertEquals( 100.12345, $this->_location->latitude() ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | * @covers ::__call |
| 62 | 62 | */ |
| 63 | 63 | public function testPlaceId() { |
| 64 | - $this->assertEquals('foobar', $this->_location->place_id()); |
|
| 64 | + $this->assertEquals( 'foobar', $this->_location->place_id() ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * @covers ::__call |
| 69 | 69 | */ |
| 70 | 70 | public function testViewport() { |
| 71 | - $this->assertEquals(['foo', 'bar'], $this->_location->viewport()); |
|
| 71 | + $this->assertEquals( ['foo', 'bar'], $this->_location->viewport() ); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $markers = $this->_make_markers_args(); |
| 19 | 19 | $info_windows = $this->_make_info_windows(); |
| 20 | 20 | |
| 21 | - require dirname( __DIR__) . '/templates/map-view.php'; |
|
| 21 | + require dirname( __DIR__ ).'/templates/map-view.php'; |
|
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @var Marker $marker |
| 48 | 48 | */ |
| 49 | - foreach( $this->item->markers() as $marker ) { |
|
| 49 | + foreach ( $this->item->markers() as $marker ) { |
|
| 50 | 50 | $info_window = $marker->info_window(); |
| 51 | 51 | $windows[] = array( |
| 52 | 52 | 'content' => $info_window->content(), |
@@ -118,7 +118,7 @@ |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | - * @param $url |
|
| 121 | + * @param string $url |
|
| 122 | 122 | * @return array|\WP_Error |
| 123 | 123 | */ |
| 124 | 124 | private function _get_data( $url ) { |
@@ -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 | } |
@@ -1,41 +1,41 @@ |
||
| 1 | 1 | <?php |
| 2 | -define('VENDOR_DIRECTORY', dirname(__DIR__) . '/vendor'); |
|
| 3 | -define('TEST_INCLUDES_DIR', dirname(__FILE__) . '/includes'); |
|
| 2 | +define( 'VENDOR_DIRECTORY', dirname( __DIR__ ).'/vendor' ); |
|
| 3 | +define( 'TEST_INCLUDES_DIR', dirname( __FILE__ ).'/includes' ); |
|
| 4 | 4 | |
| 5 | -if (! file_exists( dirname(__DIR__) . '/build' ) ) { |
|
| 6 | - mkdir(dirname(__DIR__) . '/build'); |
|
| 5 | +if ( !file_exists( dirname( __DIR__ ).'/build' ) ) { |
|
| 6 | + mkdir( dirname( __DIR__ ).'/build' ); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -require_once getenv( 'WP_TESTS_DIR' ) . '/tests/phpunit/includes/functions.php'; |
|
| 10 | -require getenv( 'WP_TESTS_DIR' ) . '/tests/phpunit/includes/bootstrap.php'; |
|
| 9 | +require_once getenv( 'WP_TESTS_DIR' ).'/tests/phpunit/includes/functions.php'; |
|
| 10 | +require getenv( 'WP_TESTS_DIR' ).'/tests/phpunit/includes/bootstrap.php'; |
|
| 11 | 11 | |
| 12 | 12 | require 'includes/testCase.php'; |
| 13 | 13 | |
| 14 | -require VENDOR_DIRECTORY . '/autoload.php'; |
|
| 14 | +require VENDOR_DIRECTORY.'/autoload.php'; |
|
| 15 | 15 | |
| 16 | -if ( ! function_exists( 'wplib_define' ) ) { |
|
| 17 | - require( VENDOR_DIRECTORY . '/wplib/wplib/defines.php' ); |
|
| 16 | +if ( !function_exists( 'wplib_define' ) ) { |
|
| 17 | + require(VENDOR_DIRECTORY.'/wplib/wplib/defines.php'); |
|
| 18 | 18 | wplib_define( 'WPLib_Runmode', 'PRODUCTION' ); |
| 19 | 19 | wplib_define( 'WPLib_Stability', 'EXPERIMENTAL' ); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -require VENDOR_DIRECTORY . '/wplib/wplib/wplib.php'; |
|
| 22 | +require VENDOR_DIRECTORY.'/wplib/wplib/wplib.php'; |
|
| 23 | 23 | WPLib::initialize(); |
| 24 | 24 | |
| 25 | -require_once dirname(__DIR__) . '/includes/class-geocoder.php'; |
|
| 26 | -require_once dirname(__DIR__) . '/includes/class-info-window-model.php'; |
|
| 27 | -require_once dirname(__DIR__) . '/includes/class-info-window-view.php'; |
|
| 28 | -require_once dirname(__DIR__) . '/includes/class-info-window.php'; |
|
| 29 | -require_once dirname(__DIR__) . '/includes/class-location.php'; |
|
| 30 | -require_once dirname(__DIR__) . '/includes/class-location-model.php'; |
|
| 31 | -require_once dirname(__DIR__) . '/includes/class-location-view.php'; |
|
| 32 | -require_once dirname(__DIR__) . '/includes/class-map.php'; |
|
| 33 | -require_once dirname(__DIR__) . '/includes/class-map-model.php'; |
|
| 34 | -require_once dirname(__DIR__) . '/includes/class-map-view.php'; |
|
| 35 | -require_once dirname(__DIR__) . '/includes/class-marker.php'; |
|
| 36 | -require_once dirname(__DIR__) . '/includes/class-marker-label.php'; |
|
| 37 | -require_once dirname(__DIR__) . '/includes/class-marker-label-model.php'; |
|
| 38 | -require_once dirname(__DIR__) . '/includes/class-marker-label-view.php'; |
|
| 39 | -require_once dirname(__DIR__) . '/includes/class-marker-model.php'; |
|
| 40 | -require_once dirname(__DIR__) . '/includes/class-marker-view.php'; |
|
| 41 | -require_once dirname(__DIR__) . '/component-google-maps.php'; |
|
| 25 | +require_once dirname( __DIR__ ).'/includes/class-geocoder.php'; |
|
| 26 | +require_once dirname( __DIR__ ).'/includes/class-info-window-model.php'; |
|
| 27 | +require_once dirname( __DIR__ ).'/includes/class-info-window-view.php'; |
|
| 28 | +require_once dirname( __DIR__ ).'/includes/class-info-window.php'; |
|
| 29 | +require_once dirname( __DIR__ ).'/includes/class-location.php'; |
|
| 30 | +require_once dirname( __DIR__ ).'/includes/class-location-model.php'; |
|
| 31 | +require_once dirname( __DIR__ ).'/includes/class-location-view.php'; |
|
| 32 | +require_once dirname( __DIR__ ).'/includes/class-map.php'; |
|
| 33 | +require_once dirname( __DIR__ ).'/includes/class-map-model.php'; |
|
| 34 | +require_once dirname( __DIR__ ).'/includes/class-map-view.php'; |
|
| 35 | +require_once dirname( __DIR__ ).'/includes/class-marker.php'; |
|
| 36 | +require_once dirname( __DIR__ ).'/includes/class-marker-label.php'; |
|
| 37 | +require_once dirname( __DIR__ ).'/includes/class-marker-label-model.php'; |
|
| 38 | +require_once dirname( __DIR__ ).'/includes/class-marker-label-view.php'; |
|
| 39 | +require_once dirname( __DIR__ ).'/includes/class-marker-model.php'; |
|
| 40 | +require_once dirname( __DIR__ ).'/includes/class-marker-view.php'; |
|
| 41 | +require_once dirname( __DIR__ ).'/component-google-maps.php'; |
|
@@ -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 | |