From c39c5f37e60c5f61bfd5a18b86b491e35998da5a Mon Sep 17 00:00:00 2001 From: Eric GELOEN Date: Fri, 12 Aug 2016 22:42:39 +0200 Subject: [PATCH] [2.0] Refactor core (#134) --- .coveralls.yml | 3 - .gitignore | 13 +- .php_cs | 20 + .travis.yml | 28 +- LICENSE | 2 +- README.md | 90 +- UPGRADE.md => UPGRADE-1.0.md | 2 +- UPGRADE-2.0.md | 6 + composer.json | 40 +- doc/control/index.md | 11 + doc/control/map_type.md | 69 + doc/control/rotate.md | 41 + doc/control/scale.md | 55 + doc/control/street_view.md | 40 + doc/control/zoom.md | 53 + doc/event.md | 88 + doc/helper/api.md | 54 + doc/helper/index.md | 77 + doc/helper/map.md | 171 ++ doc/helper/place_autocomplete.md | 125 ++ doc/installation.md | 64 +- doc/layer/index.md | 8 + doc/layer/kml_layer.md | 52 + doc/map.md | 135 ++ doc/overlay/circle.md | 71 + doc/overlay/encoded_polyline.md | 57 + doc/overlay/ground_overlay.md | 72 + doc/overlay/icon.md | 80 + doc/overlay/index.md | 15 + doc/overlay/info_box.md | 15 + doc/overlay/info_window.md | 122 ++ doc/overlay/marker.md | 102 + doc/overlay/marker_clusterer.md | 13 + .../overlays => overlay}/marker_shape.md | 40 +- doc/overlay/polygon.md | 66 + doc/overlay/polyline.md | 66 + doc/overlay/rectangle.md | 78 + doc/place/autocomplete.md | 101 + doc/{usage/places => place}/index.md | 2 +- doc/service/business_account.md | 95 + doc/service/directions/directions.md | 48 + doc/service/directions/directions_request.md | 134 ++ .../directions/directions_response.md} | 144 +- .../distance_matrix/distance_matrix.md | 51 + .../distance_matrix_request.md | 100 + .../distance_matrix_response.md | 81 + doc/service/geocoder/geocoder.md | 55 + doc/service/geocoder/geocoder_request.md | 58 + doc/service/geocoder/geocoder_response.md | 108 + doc/service/index.md | 6 + doc/service/service.md | 51 + doc/usage.md | 180 +- doc/usage/controls/index.md | 13 - doc/usage/controls/map_type.md | 143 -- doc/usage/controls/overview.md | 27 - doc/usage/controls/pan.md | 79 - doc/usage/controls/rotate.md | 79 - doc/usage/controls/scale.md | 97 - doc/usage/controls/street_view.md | 79 - doc/usage/controls/zoom.md | 106 - doc/usage/events.md | 76 - doc/usage/helper/container.md | 78 - doc/usage/helper/extension.md | 70 - doc/usage/layers/index.md | 7 - doc/usage/layers/kml_layer.md | 33 - doc/usage/map.md | 184 -- doc/usage/overlays/circle.md | 37 - doc/usage/overlays/encoded_polyline.md | 36 - doc/usage/overlays/ground_overlay.md | 31 - doc/usage/overlays/index.md | 15 - doc/usage/overlays/info_box.md | 39 - doc/usage/overlays/info_window.md | 82 - doc/usage/overlays/marker.md | 126 -- doc/usage/overlays/marker_cluster.md | 116 - doc/usage/overlays/marker_image.md | 46 - doc/usage/overlays/polygon.md | 48 - doc/usage/overlays/polyline.md | 48 - doc/usage/overlays/rectangle.md | 36 - doc/usage/places/autocomplete.md | 71 - doc/usage/services/business_account.md | 97 - .../services/directions/directions_request.md | 47 - .../distance_matrix/distance_matrix.md | 124 -- .../distance_matrix_request.md | 40 - doc/usage/services/geocoding/geocoder.md | 60 - .../services/geocoding/geocoder_request.md | 33 - .../services/geocoding/ivory_geocoder.md | 194 -- doc/usage/services/index.md | 8 - phpunit.travis.xml | 17 + phpunit.xml.dist | 10 +- .../AbstractJavascriptVariableAsset.php | 91 - src/Assets/AbstractOptionsAsset.php | 141 -- src/Base/Bound.php | 194 +- src/Base/Coordinate.php | 84 +- src/Base/Point.php | 62 +- src/Base/Size.php | 133 +- src/Control/ControlManager.php | 198 ++ src/{Controls => Control}/ControlPosition.php | 35 +- src/Control/MapTypeControl.php | 147 ++ .../MapTypeControlStyle.php | 26 +- src/Control/RotateControl.php | 49 + src/Control/ScaleControl.php | 72 + .../ScaleControlStyle.php | 24 +- src/Control/StreetViewControl.php | 49 + src/Control/ZoomControl.php | 72 + .../ZoomControlStyle.php | 26 +- src/Controls/MapTypeControl.php | 144 -- src/Controls/OverviewMapControl.php | 62 - src/Controls/PanControl.php | 62 - src/Controls/RotateControl.php | 62 - src/Controls/ScaleControl.php | 95 - src/Controls/StreetViewControl.php | 62 - src/Controls/ZoomControl.php | 92 - src/Event/Event.php | 124 ++ src/Event/EventManager.php | 325 +++ src/{Events => Event}/MouseEvent.php | 28 +- src/Events/Event.php | 167 -- src/Events/EventManager.php | 148 -- src/Exception/AssetException.php | 62 - src/Exception/BaseException.php | 142 -- src/Exception/ControlException.php | 98 - src/Exception/DirectionsException.php | 328 --- src/Exception/DistanceMatrixException.php | 190 -- src/Exception/EventException.php | 60 - src/Exception/GeocodingException.php | 254 --- src/Exception/HelperException.php | 141 -- src/Exception/LayerException.php | 30 - src/Exception/MapException.php | 249 --- src/Exception/OverlayException.php | 536 ----- src/Exception/PlaceException.php | 148 -- src/Exception/ServiceException.php | 113 - src/Helper/AbstractHelper.php | 47 +- src/Helper/ApiHelper.php | 81 +- src/Helper/Base/BoundHelper.php | 96 - src/Helper/Base/SizeHelper.php | 49 - src/Helper/Builder/AbstractHelperBuilder.php | 199 ++ src/Helper/Builder/ApiHelperBuilder.php | 125 ++ src/Helper/Builder/MapHelperBuilder.php | 358 +++ .../PlaceAutocompleteHelperBuilder.php | 93 + src/Helper/Collector/AbstractCollector.php | 48 + src/Helper/Collector/Base/BoundCollector.php | 99 + .../Collector/Base/CoordinateCollector.php | 225 ++ src/Helper/Collector/Base/PointCollector.php | 77 + src/Helper/Collector/Base/SizeCollector.php | 103 + .../Collector/Event/DomEventCollector.php | 33 + .../Collector/Event/DomEventOnceCollector.php | 33 + src/Helper/Collector/Event/EventCollector.php | 33 + .../Collector/Event/EventOnceCollector.php | 33 + .../Collector/Layer/KmlLayerCollector.php | 33 + .../Collector/Overlay/CircleCollector.php | 33 + .../Overlay/DefaultInfoWindowCollector.php | 28 + .../Overlay/EncodedPolylineCollector.php | 33 + .../Collector/Overlay/ExtendableCollector.php | 33 + .../Overlay/GroundOverlayCollector.php | 33 + .../Collector/Overlay/IconCollector.php | 68 + .../Collector/Overlay/InfoBoxCollector.php | 28 + .../Collector/Overlay/InfoWindowCollector.php | 108 + .../Collector/Overlay/MarkerCollector.php | 33 + .../Collector/Overlay/PolygonCollector.php | 33 + .../Collector/Overlay/PolylineCollector.php | 33 + .../Collector/Overlay/RectangleCollector.php | 33 + .../Place/AutocompleteBoundCollector.php | 37 + .../Place/AutocompleteCoordinateCollector.php | 72 + src/Helper/Controls/ControlPositionHelper.php | 53 - src/Helper/Controls/MapTypeControlHelper.php | 159 -- .../Controls/MapTypeControlStyleHelper.php | 44 - .../Controls/OverviewMapControlHelper.php | 38 - src/Helper/Controls/PanControlHelper.php | 77 - src/Helper/Controls/RotateControlHelper.php | 77 - src/Helper/Controls/ScaleControlHelper.php | 112 - .../Controls/ScaleControlStyleHelper.php | 42 - .../Controls/StreetViewControlHelper.php | 80 - src/Helper/Controls/ZoomControlHelper.php | 112 - .../Controls/ZoomControlStyleHelper.php | 44 - src/Helper/Event/AbstractEvent.php | 57 + src/Helper/Event/ApiEvent.php | 442 ++++ src/Helper/Event/ApiEvents.php | 29 + src/Helper/Event/MapEvent.php | 41 + src/Helper/Event/MapEvents.php | 58 + src/Helper/Event/PlaceAutocompleteEvent.php | 41 + src/Helper/Event/PlaceAutocompleteEvents.php | 34 + src/Helper/Events/EventManagerHelper.php | 96 - .../Extension/AbstractExtensionHelper.php | 46 - src/Helper/Extension/CoreExtensionHelper.php | 152 -- .../Extension/ExtensionHelperInterface.php | 49 - .../Extension/InfoBoxExtensionHelper.php | 112 - src/Helper/Formatter/Formatter.php | 449 ++++ src/Helper/Geometry/EncodingHelper.php | 41 - src/Helper/Layers/KMLLayerHelper.php | 47 - src/Helper/MapHelper.php | 1910 +---------------- src/Helper/MapTypeIdHelper.php | 45 - src/Helper/Overlays/AnimationHelper.php | 43 - src/Helper/Overlays/CircleHelper.php | 48 - src/Helper/Overlays/EncodedPolylineHelper.php | 87 - src/Helper/Overlays/GroundOverlayHelper.php | 48 - src/Helper/Overlays/InfoBoxHelper.php | 36 - src/Helper/Overlays/InfoWindowHelper.php | 94 - .../AbstractMarkerClusterHelper.php | 62 - .../DefaultMarkerClusterHelper.php | 147 -- .../MarkerCluster/JsMarkerClusterHelper.php | 73 - .../MarkerCluster/MarkerClusterHelper.php | 141 -- .../MarkerClusterHelperInterface.php | 53 - src/Helper/Overlays/MarkerHelper.php | 106 - src/Helper/Overlays/MarkerImageHelper.php | 42 - src/Helper/Overlays/MarkerShapeHelper.php | 38 - src/Helper/Overlays/PolygonHelper.php | 52 - src/Helper/Overlays/PolylineHelper.php | 52 - src/Helper/Overlays/RectangleHelper.php | 47 - src/Helper/PlaceAutocompleteHelper.php | 65 + src/Helper/Places/AutocompleteHelper.php | 240 --- src/Helper/Renderer/AbstractJsonRenderer.php | 63 + src/Helper/Renderer/AbstractRenderer.php | 49 + src/Helper/Renderer/ApiInitRenderer.php | 63 + src/Helper/Renderer/ApiRenderer.php | 180 ++ src/Helper/Renderer/Base/BoundRenderer.php | 39 + .../Base/CoordinateRenderer.php} | 23 +- .../Base/PointRenderer.php} | 23 +- src/Helper/Renderer/Base/SizeRenderer.php | 42 + .../Control/ControlManagerRenderer.php | 115 + .../Control/ControlPositionRenderer.php | 30 + .../Control/ControlRendererInterface.php} | 12 +- .../Control/MapTypeControlRenderer.php | 133 ++ .../Control/MapTypeControlStyleRenderer.php | 30 + .../Control/RotateControlRenderer.php | 77 + .../Renderer/Control/ScaleControlRenderer.php | 104 + .../Control/ScaleControlStyleRenderer.php | 30 + .../Control/StreetViewControlRenderer.php | 77 + .../Renderer/Control/ZoomControlRenderer.php | 102 + .../Control/ZoomControlStyleRenderer.php | 30 + .../Renderer/Event/AbstractEventRenderer.php | 59 + .../Renderer/Event/DomEventOnceRenderer.php | 26 + .../Renderer/Event/DomEventRenderer.php | 26 + .../Renderer/Event/EventOnceRenderer.php | 34 + src/Helper/Renderer/Event/EventRenderer.php | 34 + .../Renderer/Geometry/EncodingRenderer.php | 37 + .../Renderer/Html/AbstractTagRenderer.php | 53 + .../Renderer/Html/JavascriptTagRenderer.php | 35 + .../Renderer/Html/StylesheetRenderer.php | 33 + .../Renderer/Html/StylesheetTagRenderer.php | 82 + src/Helper/Renderer/Html/TagRenderer.php | 48 + .../Renderer/Layer/KmlLayerRenderer.php | 41 + src/Helper/Renderer/LoaderRenderer.php | 63 + src/Helper/Renderer/MapBoundRenderer.php | 34 + src/Helper/Renderer/MapCenterRenderer.php | 34 + src/Helper/Renderer/MapContainerRenderer.php | 49 + src/Helper/Renderer/MapHtmlRenderer.php | 80 + src/Helper/Renderer/MapRenderer.php | 157 ++ src/Helper/Renderer/MapTypeIdRenderer.php | 28 + .../Overlay/AbstractInfoWindowRenderer.php | 58 + .../Renderer/Overlay/AnimationRenderer.php | 19 +- .../Renderer/Overlay/CircleRenderer.php | 42 + .../Overlay/DefaultInfoWindowRenderer.php | 26 + .../Overlay/EncodedPolylineRenderer.php | 80 + .../Overlay/Extendable/ExtendableRenderer.php | 115 + .../ExtendableRendererInterface.php | 29 + .../Extendable/PathExtendableRenderer.php | 40 + .../Extendable/PositionExtendableRenderer.php | 34 + .../Extendable/UnionExtendableRenderer.php | 34 + .../Overlay/GroundOverlayRenderer.php | 42 + src/Helper/Renderer/Overlay/IconRenderer.php | 50 + .../Renderer/Overlay/InfoBoxRenderer.php | 90 + .../Overlay/InfoWindowCloseRenderer.php | 31 + .../Overlay/InfoWindowOpenRenderer.php | 41 + .../Overlay/InfoWindowRendererInterface.php | 28 + .../Overlay/MarkerClustererRenderer.php | 97 + .../Renderer/Overlay/MarkerRenderer.php | 147 ++ .../Renderer/Overlay/MarkerShapeRenderer.php | 34 + .../Renderer/Overlay/PolygonRenderer.php | 46 + .../Renderer/Overlay/PolylineRenderer.php | 46 + .../Renderer/Overlay/RectangleRenderer.php | 41 + .../Place/AutocompleteContainerRenderer.php | 32 + .../Place/AutocompleteHtmlRenderer.php | 44 + .../Renderer/Place/AutocompleteRenderer.php | 102 + .../Renderer/Utility/CallbackRenderer.php | 30 + .../Utility/ObjectToArrayRenderer.php | 52 + .../Utility/RequirementLoaderRenderer.php | 92 + .../Renderer/Utility/RequirementRenderer.php | 32 + .../Renderer/Utility/SourceRenderer.php | 72 + .../Subscriber/AbstractDelegateSubscriber.php | 51 + src/Helper/Subscriber/AbstractSubscriber.php | 50 + .../Subscriber/ApiJavascriptSubscriber.php | 123 ++ src/Helper/Subscriber/Base/BaseSubscriber.php | 36 + .../Subscriber/Base/BoundSubscriber.php | 109 + .../Subscriber/Base/CoordinateSubscriber.php | 109 + .../Subscriber/Base/PointSubscriber.php | 109 + src/Helper/Subscriber/Base/SizeSubscriber.php | 109 + .../DelegateSubscriberInterface.php | 25 + .../Event/DomEventOnceSubscriber.php | 109 + .../Subscriber/Event/DomEventSubscriber.php | 109 + .../Subscriber/Event/EventOnceSubscriber.php | 109 + .../Subscriber/Event/EventSubscriber.php | 36 + .../Event/SimpleEventSubscriber.php | 109 + .../Subscriber/Layer/KmlLayerSubscriber.php | 109 + .../Subscriber/Layer/LayerSubscriber.php | 29 + src/Helper/Subscriber/MapBoundSubscriber.php | 75 + src/Helper/Subscriber/MapCenterSubscriber.php | 75 + .../Subscriber/MapContainerSubscriber.php | 77 + src/Helper/Subscriber/MapHtmlSubscriber.php | 71 + src/Helper/Subscriber/MapInitSubscriber.php | 33 + .../Subscriber/MapJavascriptSubscriber.php | 182 ++ .../Subscriber/MapStylesheetSubscriber.php | 75 + src/Helper/Subscriber/MapSubscriber.php | 77 + .../Overlay/AbstractInfoWindowSubscriber.php | 54 + .../Overlay/AbstractMarkerSubscriber.php | 56 + .../Subscriber/Overlay/CircleSubscriber.php | 109 + .../Overlay/DefaultInfoWindowSubscriber.php | 103 + .../Overlay/EncodedPolylineSubscriber.php | 131 ++ .../Overlay/ExtendableSubscriber.php | 104 + .../Overlay/GroundOverlaySubscriber.php | 109 + .../Subscriber/Overlay/InfoBoxSubscriber.php | 125 ++ .../Overlay/InfoWindowCloseSubscriber.php | 90 + .../Overlay/InfoWindowOpenSubscriber.php | 83 + .../Overlay/MarkerClustererSubscriber.php | 121 ++ .../MarkerInfoWindowOpenSubscriber.php | 151 ++ .../Subscriber/Overlay/MarkerSubscriber.php | 92 + .../Subscriber/Overlay/OverlaySubscriber.php | 43 + .../Subscriber/Overlay/PolygonSubscriber.php | 109 + .../Subscriber/Overlay/PolylineSubscriber.php | 109 + .../Overlay/RectangleSubscriber.php | 109 + .../Place/AutocompleteContainerSubscriber.php | 77 + .../Place/AutocompleteHtmlSubscriber.php | 72 + .../Place/AutocompleteInitSubscriber.php | 33 + .../AutocompleteJavascriptSubscriber.php | 179 ++ .../Place/AutocompleteSubscriber.php | 78 + .../Place/Base/AutocompleteBaseSubscriber.php | 34 + .../Base/AutocompleteBoundSubscriber.php | 109 + .../Base/AutocompleteCoordinateSubscriber.php | 109 + .../Utility/ObjectToArraySubscriber.php | 76 + src/Layer/KmlLayer.php | 58 + src/Layer/LayerManager.php | 121 ++ src/Layers/KMLLayer.php | 68 - src/Map.php | 1115 ++-------- src/MapTypeId.php | 25 +- src/{Overlays => Overlay}/Animation.php | 25 +- src/Overlay/Circle.php | 83 + src/Overlay/EncodedPolyline.php | 59 + .../ExtendableInterface.php} | 8 +- src/Overlay/GroundOverlay.php | 83 + src/Overlay/Icon.php | 181 ++ src/Overlay/InfoWindow.php | 227 ++ src/Overlay/InfoWindowType.php | 28 + src/Overlay/Marker.php | 187 ++ src/Overlay/MarkerCluster.php | 190 ++ src/Overlay/MarkerClusterType.php | 28 + src/Overlay/MarkerShape.php | 109 + src/Overlay/MarkerShapeType.php | 29 + src/Overlay/OverlayManager.php | 694 ++++++ src/Overlay/Polygon.php | 105 + src/Overlay/Polyline.php | 105 + src/Overlay/Rectangle.php | 58 + src/Overlays/Circle.php | 114 - src/Overlays/EncodedPolyline.php | 69 - src/Overlays/GroundOverlay.php | 141 -- src/Overlays/InfoWindow.php | 319 --- src/Overlays/Marker.php | 354 --- src/Overlays/MarkerCluster.php | 110 - src/Overlays/MarkerImage.php | 309 --- src/Overlays/MarkerShape.php | 175 -- src/Overlays/Polygon.php | 103 - src/Overlays/Polyline.php | 103 - src/Overlays/Rectangle.php | 106 - src/Place/Autocomplete.php | 419 ++++ .../AutocompleteComponentRestriction.php | 27 + src/Place/AutocompleteType.php | 30 + src/Places/Autocomplete.php | 476 ---- .../AutocompleteComponentRestriction.php | 44 - src/Places/AutocompleteType.php | 50 - src/Service/AbstractService.php | 214 ++ src/Service/Base/Distance.php | 72 + src/Service/Base/Duration.php | 72 + src/{Services => Service}/Base/TravelMode.php | 27 +- src/{Services => Service}/Base/UnitSystem.php | 25 +- src/Service/BusinessAccount.php | 122 ++ src/Service/Directions/Directions.php | 194 ++ src/Service/Directions/DirectionsLeg.php | 295 +++ src/Service/Directions/DirectionsRequest.php | 516 +++++ src/Service/Directions/DirectionsResponse.php | 116 + src/Service/Directions/DirectionsRoute.php | 336 +++ .../Directions/DirectionsStatus.php | 31 +- src/Service/Directions/DirectionsStep.php | 228 ++ src/Service/Directions/DirectionsWaypoint.php | 80 + src/Service/DistanceMatrix/DistanceMatrix.php | 138 ++ .../DistanceMatrix/DistanceMatrixElement.php | 108 + .../DistanceMatrixElementStatus.php | 31 + .../DistanceMatrix/DistanceMatrixRequest.php | 411 ++++ .../DistanceMatrix/DistanceMatrixResponse.php | 254 +++ .../DistanceMatrix/DistanceMatrixRow.php | 87 + .../DistanceMatrix/DistanceMatrixStatus.php | 31 +- .../Geocoder/GeocoderAddressComponent.php | 147 ++ src/Service/Geocoder/GeocoderGeometry.php | 139 ++ .../Geocoder}/GeocoderLocationType.php | 27 +- src/Service/Geocoder/GeocoderProvider.php | 209 ++ src/Service/Geocoder/GeocoderRequest.php | 180 ++ src/Service/Geocoder/GeocoderResponse.php | 116 + src/Service/Geocoder/GeocoderResult.php | 263 +++ .../Geocoder}/GeocoderStatus.php | 30 +- src/Service/Utility/XmlParser.php | 57 + src/Services/AbstractService.php | 267 --- src/Services/Base/Distance.php | 93 - src/Services/Base/Duration.php | 93 - src/Services/BusinessAccount.php | 138 -- src/Services/Directions/Directions.php | 400 ---- src/Services/Directions/DirectionsLeg.php | 268 --- src/Services/Directions/DirectionsRequest.php | 650 ------ .../Directions/DirectionsResponse.php | 100 - src/Services/Directions/DirectionsRoute.php | 281 --- src/Services/Directions/DirectionsStep.php | 230 -- .../Directions/DirectionsWaypoint.php | 128 -- .../DistanceMatrix/DistanceMatrix.php | 264 --- .../DistanceMatrixElementStatus.php | 50 - .../DistanceMatrix/DistanceMatrixRequest.php | 452 ---- .../DistanceMatrix/DistanceMatrixResponse.php | 180 -- .../DistanceMatrixResponseElement.php | 121 -- .../DistanceMatrixResponseRow.php | 68 - src/Services/Geocoding/Geocoder.php | 47 - src/Services/Geocoding/GeocoderProvider.php | 456 ---- src/Services/Geocoding/GeocoderRequest.php | 328 --- .../Result/GeocoderAddressComponent.php | 138 -- .../Geocoding/Result/GeocoderGeometry.php | 139 -- .../Geocoding/Result/GeocoderResponse.php | 100 - .../Geocoding/Result/GeocoderResult.php | 222 -- src/Services/Utils/XmlParser.php | 81 - src/Utility/OptionsAwareInterface.php | 63 + src/Utility/OptionsAwareTrait.php | 95 + src/Utility/VariableAwareInterface.php | 28 + src/Utility/VariableAwareTrait.php | 61 + tests/Assets/JavascriptVariableAssetTest.php | 86 - tests/Assets/OptionsAssetTest.php | 106 - tests/Base/BoundTest.php | 162 +- tests/Base/CoordinateTest.php | 81 +- tests/Base/PointTest.php | 59 +- tests/Base/SizeTest.php | 103 +- tests/Control/ControlManagerTest.php | 207 ++ tests/Control/MapTypeControlTest.php | 107 + tests/Control/RotateControlTest.php | 53 + tests/Control/ScaleControlTest.php | 66 + tests/Control/StreetViewControlTest.php | 53 + tests/Control/ZoomControlTest.php | 66 + tests/Controls/ControlPositionTest.php | 42 - tests/Controls/MapTypeControlStyleTest.php | 33 - tests/Controls/MapTypeControlTest.php | 92 - tests/Controls/OverviewMapControlTest.php | 62 - tests/Controls/PanControlTest.php | 62 - tests/Controls/RotateControlTest.php | 62 - tests/Controls/ScaleControlTest.php | 74 - tests/Controls/StreetViewControlTest.php | 62 - tests/Controls/ZoomControlStyleTest.php | 33 - tests/Controls/ZoomControlTest.php | 74 - tests/Event/EventManagerTest.php | 242 +++ tests/Event/EventTest.php | 107 + tests/Events/EventManagerTest.php | 97 - tests/Events/EventTest.php | 123 -- tests/Events/MouseEventTest.php | 36 - tests/Helper/AbstractHelperTest.php | 58 - tests/Helper/ApiHelperTest.php | 135 -- tests/Helper/Base/BoundHelperTest.php | 146 -- tests/Helper/Base/CoordinateHelperTest.php | 53 - tests/Helper/Base/PointHelperTest.php | 42 - tests/Helper/Base/SizeHelperTest.php | 50 - tests/Helper/Builder/ApiHelperBuilderTest.php | 45 + tests/Helper/Builder/HelperBuilderTest.php | 146 ++ tests/Helper/Builder/MapHelperBuilderTest.php | 45 + .../PlaceAutocompleteHelperBuilderTest.php | 45 + .../Collector/Base/BoundCollectorTest.php | 100 + .../Base/CoordinateCollectorTest.php | 219 ++ .../Collector/Base/PointCollectorTest.php | 85 + .../Collector/Base/SizeCollectorTest.php | 106 + .../Collector/Event/DomEventCollectorTest.php | 43 + .../Event/DomEventOnceCollectorTest.php | 43 + .../Collector/Event/EventCollectorTest.php | 43 + .../Event/EventOnceCollectorTest.php | 43 + .../Collector/Layer/KmlLayerCollectorTest.php | 43 + .../Collector/Overlay/CircleCollectorTest.php | 44 + .../DefaultInfoWindowCollectorTest.php | 48 + .../Overlay/EncodedPolylineCollectorTest.php | 43 + .../Overlay/ExtendableCollectorTest.php | 51 + .../Overlay/GroundOverlayCollectorTest.php | 44 + .../Collector/Overlay/IconCollectorTest.php | 64 + .../Overlay/InfoBoxCollectorTest.php | 48 + .../Overlay/InfoWindowCollectorTest.php | 107 + .../Collector/Overlay/MarkerCollectorTest.php | 44 + .../Overlay/PolygonCollectorTest.php | 43 + .../Overlay/PolylineCollectorTest.php | 43 + .../Overlay/RectangleCollectorTest.php | 44 + .../Place/AutocompleteBoundCollectorTest.php | 48 + .../AutocompleteCoordinateCollectorTest.php | 69 + .../Controls/ControlPositionHelperTest.php | 115 - .../Controls/MapTypeControlHelperTest.php | 97 - .../MapTypeControlStyleHelperTest.php | 69 - .../Controls/OverviewMapControlHelperTest.php | 49 - .../Helper/Controls/PanControlHelperTest.php | 70 - .../Controls/RotateControlHelperTest.php | 70 - .../Controls/ScaleControlHelperTest.php | 78 - .../Controls/ScaleControlStyleHelperTest.php | 59 - .../Controls/StreetViewControlHelperTest.php | 70 - .../Helper/Controls/ZoomControlHelperTest.php | 78 - .../Controls/ZoomControlStyleHelperTest.php | 69 - tests/Helper/Event/ApiEventTest.php | 240 +++ tests/Helper/Event/EventTest.php | 71 + tests/Helper/Event/MapEventTest.php | 59 + .../Event/PlaceAutocompleteEventTest.php | 59 + .../Helper/Events/EventManagerHelperTest.php | 86 - .../Extension/CoreExtensionHelperTest.php | 149 -- .../Extension/InfoBoxExtensionHelperTest.php | 134 -- tests/Helper/Formatter/FormatterTest.php | 766 +++++++ .../Functional/AbstractApiFunctionalTest.php | 215 ++ .../Functional/AbstractFunctionalTest.php | 83 + .../Functional/AbstractMapFunctionalTest.php | 420 ++++ .../Functional/CompoundFunctionalTest.php | 76 + .../Control/MapTypeControlFunctionalTest.php | 49 + .../Control/RotateControlFunctionalTest.php | 42 + .../Control/ScaleControlFunctionalTest.php | 43 + .../StreetViewControlFunctionalTest.php | 42 + .../Control/ZoomControlFunctionalTest.php | 43 + .../Layer/KmlLayerFunctionalTest.php | 51 + tests/Helper/Functional/MapFunctionalTest.php | 73 + .../Overlay/CircleFunctionalTest.php | 52 + .../Overlay/EncodedPolylineFunctionalTest.php | 51 + .../Overlay/GroundOverlayFunctionalTest.php | 56 + .../Overlay/InfoBoxFunctionalTest.php | 71 + .../Overlay/InfoWindowFunctionalTest.php | 69 + .../Overlay/MarkerClustererFunctionalTest.php | 61 + .../Overlay/MarkerFunctionalTest.php | 93 + .../MarkerInfoWindowFunctionalTest.php | 64 + .../Overlay/MixedInfoWindowFunctionalTest.php | 71 + .../Overlay/PolygonFunctionalTest.php | 57 + .../Overlay/PolylineFunctionalTest.php | 57 + .../Overlay/RectangleFunctionalTest.php | 53 + .../AbstractAutocompleteFunctionalTest.php | 123 ++ .../Place/AutocompleteFunctionalTest.php | 103 + tests/Helper/Geometry/EncodingHelperTest.php | 66 - tests/Helper/Layers/KMLLayerHelperTest.php | 79 - tests/Helper/MapHelperTest.php | 1280 ----------- tests/Helper/MapTypeIdHelperTest.php | 59 - tests/Helper/Overlays/AnimationHelperTest.php | 57 - tests/Helper/Overlays/CircleHelperTest.php | 70 - .../Overlays/EncodedPolylineHelperTest.php | 98 - .../Overlays/GroundOverlayHelperTest.php | 90 - tests/Helper/Overlays/InfoBoxHelperTest.php | 68 - .../Helper/Overlays/InfoWindowHelperTest.php | 134 -- .../AbstractMarkerClusterHelperTest.php | 55 - .../DefaultMarkerClusterHelperTest.php | 112 - .../JsMarkerClusterHelperTest.php | 119 - .../MarkerCluster/MarkerClusterHelperTest.php | 140 -- tests/Helper/Overlays/MarkerHelperTest.php | 168 -- .../Helper/Overlays/MarkerImageHelperTest.php | 68 - .../Helper/Overlays/MarkerShapeHelperTest.php | 75 - tests/Helper/Overlays/PolygonHelperTest.php | 102 - tests/Helper/Overlays/PolylineHelperTest.php | 102 - tests/Helper/Overlays/RectangleHelperTest.php | 90 - .../Helper/Places/AutocompleteHelperTest.php | 290 --- tests/Helper/Renderer/ApiInitRendererTest.php | 106 + tests/Helper/Renderer/ApiRendererTest.php | 201 ++ .../Renderer/Base/BoundRendererTest.php | 91 + .../Renderer/Base/CoordinateRendererTest.php | 52 + .../Renderer/Base/PointRendererTest.php | 52 + .../Helper/Renderer/Base/SizeRendererTest.php | 63 + .../Control/ControlManagerRendererTest.php | 155 ++ .../Control/ControlPositionRendererTest.php | 49 + .../Control/MapTypeControlRendererTest.php | 121 ++ .../MapTypeControlStyleRendererTest.php | 49 + .../Control/RotateControlRendererTest.php | 82 + .../Control/ScaleControlRendererTest.php | 100 + .../Control/ScaleControlStyleRendererTest.php | 49 + .../Control/StreetViewControlRendererTest.php | 82 + .../Control/ZoomControlRendererTest.php | 94 + .../Control/ZoomControlStyleRendererTest.php | 43 + .../Event/AbstractEventRendererTest.php | 69 + .../Event/DomEventOnceRendererTest.php | 52 + .../Renderer/Event/DomEventRendererTest.php | 52 + .../Renderer/Event/EventOnceRendererTest.php | 52 + .../Renderer/Event/EventRendererTest.php | 52 + .../Geometry/EncodingRendererTest.php | 67 + .../Renderer/Html/AbstractTagRendererTest.php | 87 + .../Html/JavascriptTagRendererTest.php | 82 + .../Renderer/Html/StylesheetRendererTest.php | 52 + .../Html/StylesheetTagRendererTest.php | 107 + .../Helper/Renderer/Html/TagRendererTest.php | 85 + tests/Helper/Renderer/JsonRendererTest.php | 112 + .../Renderer/Layer/KmlLayerRendererTest.php | 57 + tests/Helper/Renderer/LoaderRendererTest.php | 84 + .../Helper/Renderer/MapBoundRendererTest.php | 50 + .../Helper/Renderer/MapCenterRendererTest.php | 50 + .../Renderer/MapContainerRendererTest.php | 91 + tests/Helper/Renderer/MapHtmlRendererTest.php | 92 + tests/Helper/Renderer/MapRendererTest.php | 151 ++ .../Helper/Renderer/MapTypeIdRendererTest.php | 40 + .../Overlay/AnimationRendererTest.php | 46 + .../Renderer/Overlay/CircleRendererTest.php | 61 + .../Overlay/DefaultInfoWindowRendererTest.php | 75 + .../Overlay/EncodedPolylineRendererTest.php | 77 + .../Extendable/ExtendableRendererTest.php | 137 ++ .../Extendable/PathExtendableRendererTest.php | 80 + .../PositionExtendableRendererTest.php | 80 + .../UnionExtendableRendererTest.php | 80 + .../Overlay/GroundOverlayRendererTest.php | 61 + .../Renderer/Overlay/IconRendererTest.php | 72 + .../Renderer/Overlay/InfoBoxRendererTest.php | 108 + .../Overlay/InfoWindowCloseRendererTest.php | 49 + .../Overlay/InfoWindowOpenRendererTest.php | 75 + .../Overlay/InfoWindowRendererTest.php | 94 + .../Overlay/MarkerClustererRendererTest.php | 95 + .../Renderer/Overlay/MarkerRendererTest.php | 140 ++ .../Overlay/MarkerShapeRendererTest.php | 51 + .../Renderer/Overlay/PolygonRendererTest.php | 64 + .../Renderer/Overlay/PolylineRendererTest.php | 64 + .../Overlay/RectangleRendererTest.php | 61 + .../AutocompleteContainerRendererTest.php | 49 + .../Place/AutocompleteHtmlRendererTest.php | 68 + .../Place/AutocompleteRendererTest.php | 102 + tests/Helper/Renderer/RendererTest.php | 72 + .../Renderer/Utility/CallbackRendererTest.php | 45 + .../Utility/ObjectToArrayRendererTest.php | 66 + .../Utility/RequirementLoaderRendererTest.php | 66 + .../Renderer/Utility/SourceRendererTest.php | 66 + tests/Layer/KmlLayerTest.php | 68 + tests/Layer/LayerManagerTest.php | 116 + tests/Layers/KMLLayerTest.php | 69 - tests/MapTest.php | 931 ++------ tests/MapTypeIdTest.php | 34 - tests/Overlay/CircleTest.php | 89 + tests/Overlay/EncodedPolylineTest.php | 71 + tests/Overlay/GroundOverlayTest.php | 97 + tests/Overlay/IconTest.php | 157 ++ tests/Overlay/InfoWindowTest.php | 167 ++ tests/Overlay/MarkerClusterTest.php | 288 +++ tests/Overlay/MarkerShapeTest.php | 86 + tests/Overlay/MarkerTest.php | 198 ++ tests/Overlay/OverlayManagerTest.php | 1196 +++++++++++ tests/Overlay/PolygonTest.php | 112 + tests/Overlay/PolylineTest.php | 111 + tests/Overlay/RectangleTest.php | 80 + tests/Overlays/AnimationTest.php | 32 - tests/Overlays/CircleTest.php | 107 - tests/Overlays/EncodedPolylineTest.php | 62 - tests/Overlays/GroundOverlayTest.php | 144 -- tests/Overlays/InfoWindowTest.php | 235 -- tests/Overlays/MarkerClusterTest.php | 65 - tests/Overlays/MarkerImageTest.php | 249 --- tests/Overlays/MarkerShapeTest.php | 175 -- tests/Overlays/MarkerTest.php | 305 --- tests/Overlays/PolygonTest.php | 86 - tests/Overlays/PolylineTest.php | 86 - tests/Overlays/RectangleTest.php | 144 -- tests/Place/AutocompleteTest.php | 269 +++ .../AutocompleteComponentRestrictionTest.php | 30 - tests/Places/AutocompleteTest.php | 281 --- tests/Places/AutocompleteTypeTest.php | 35 - tests/Service/.cache/0/G/+GzvChCNKC3DaLz2oxPg | Bin 0 -> 2486 bytes tests/Service/.cache/1/J/ofymTyre3fHTOJ1NdqkQ | Bin 0 -> 6358 bytes tests/Service/.cache/3/j/tedxvL8kjLkHVEVUVzJg | Bin 0 -> 39659 bytes tests/Service/.cache/6/W/0NC+6QA9PyiUswxLXrlg | Bin 0 -> 2486 bytes tests/Service/.cache/A/l/PchupASIKWubyOo44B3A | Bin 0 -> 3836 bytes tests/Service/.cache/A/y/OYhD4u1fh4kR7UkMEE6A | Bin 0 -> 2486 bytes tests/Service/.cache/B/0/JlpD73RFxlhSBl5v8GpA | Bin 0 -> 2435 bytes tests/Service/.cache/C/6/BkdZWhu17mUUfJfJ99Og | Bin 0 -> 39659 bytes tests/Service/.cache/L/B/IG6IT4HHJzhrGCF8jbEA | Bin 0 -> 2536 bytes tests/Service/.cache/M/X/Idjx5HZUUigUg2-PS0kQ | Bin 0 -> 89708 bytes tests/Service/.cache/N/G/WjiVLJAzRsi8tdJXKgow | Bin 0 -> 19019 bytes tests/Service/.cache/O/+/eEdAvTWtWvIQWFIstqLw | Bin 0 -> 5469 bytes tests/Service/.cache/O/3/Z11lXG43qQ14lYU0JXtA | Bin 0 -> 39659 bytes tests/Service/.cache/O/v/P5LtIbOLpceRXfKhOCWw | Bin 0 -> 3794 bytes tests/Service/.cache/P/B/IavO8VJ5AzalRMSw6juA | Bin 0 -> 2486 bytes tests/Service/.cache/S/R/SCHdwMXvr81IgBFn3SYA | Bin 0 -> 2542 bytes tests/Service/.cache/S/y/ALbZbs-ES8zgvfPbpbFA | Bin 0 -> 2486 bytes tests/Service/.cache/V/J/S7lTw55ItQnE++nJlxNQ | Bin 0 -> 39659 bytes tests/Service/.cache/Z/y/k-471oym0TOSmHsBQALQ | Bin 0 -> 21854 bytes tests/Service/.cache/d/-/dv8bvFVsoGcE21e2n4PA | Bin 0 -> 2486 bytes tests/Service/.cache/d/k/I1UGOZB79LQiK0GlapLA | Bin 0 -> 5538 bytes tests/Service/.cache/g/i/R724U9mpkjhZuwoQvgHg | Bin 0 -> 5519 bytes tests/Service/.cache/h/H/+7II4g5fdI92KaPhDoSA | 3 + tests/Service/.cache/h/I/0RzQt4n60sUFmL-7xk0g | Bin 0 -> 31591 bytes tests/Service/.cache/i/5/dXZUYxu+wzMxvCYhvVlQ | Bin 0 -> 119025 bytes tests/Service/.cache/m/1/NYlgc92PLB+CHQxyMyAg | Bin 0 -> 5469 bytes tests/Service/.cache/n/u/wnUryzMtlAq1P2MDMNSw | Bin 0 -> 39659 bytes tests/Service/.cache/o/s/cWZEtDFEJNKdDr-9rElA | Bin 0 -> 39659 bytes tests/Service/.cache/q/T/qlAToFSNCJ-FOlkd4sNw | Bin 0 -> 39659 bytes tests/Service/.cache/q/Z/P3l5MZYvMpMfDXGpD9+A | Bin 0 -> 39659 bytes tests/Service/.cache/r/+/W4JvLH5KNZM1m-qw2EUg | Bin 0 -> 39852 bytes tests/Service/.cache/v/E/KKeEAYnZW+G+uOVxSZaA | Bin 0 -> 161261 bytes tests/Service/.cache/v/v/bru-4eLCrJjT4fi3aj9w | Bin 0 -> 21596 bytes tests/Service/.cache/x/k/zk2vyqdID0wC23yca6vQ | 3 + tests/Service/.cache/y/P/lKyR4+cjcCGyJ49zN02A | Bin 0 -> 39955 bytes tests/Service/.cache/z/A/syfS2Tia0KK6N8wqlhRA | Bin 0 -> 5056 bytes tests/Service/AbstractServiceTest.php | 86 + tests/Service/Base/DistanceTest.php | 63 + tests/Service/Base/DurationTest.php | 63 + tests/Service/BusinessAccountTest.php | 127 ++ .../Service/Directions/DirectionsLegTest.php | 237 ++ .../Directions/DirectionsRequestTest.php | 543 +++++ .../Directions/DirectionsResponseTest.php | 106 + .../Directions/DirectionsRouteTest.php | 241 +++ .../Service/Directions/DirectionsStepTest.php | 207 ++ tests/Service/Directions/DirectionsTest.php | 383 ++++ .../Directions/DirectionsWaypointTest.php | 97 + .../DistanceMatrixElementTest.php | 113 + .../DistanceMatrixRequestTest.php | 320 +++ .../DistanceMatrixResponseTest.php | 186 ++ .../DistanceMatrix/DistanceMatrixRowTest.php | 86 + .../DistanceMatrix/DistanceMatrixTest.php | 286 +++ .../Geocoder/GeocoderAddressComponentTest.php | 115 + .../Service/Geocoder/GeocoderGeometryTest.php | 132 ++ .../Service/Geocoder/GeocoderProviderTest.php | 293 +++ .../Service/Geocoder/GeocoderRequestTest.php | 225 ++ .../Service/Geocoder/GeocoderResponseTest.php | 106 + tests/Service/Geocoder/GeocoderResultTest.php | 213 ++ tests/Service/ServiceTest.php | 166 ++ tests/Service/Utility/XmlParserTest.php | 58 + tests/Services/AbstractServiceTest.php | 195 -- tests/Services/Base/DistanceTest.php | 65 - tests/Services/Base/DurationTest.php | 65 - tests/Services/Base/TravelModeTest.php | 34 - tests/Services/Base/UnitSystemTest.php | 32 - tests/Services/BusinessAccountTest.php | 96 - .../Services/Directions/DirectionsLegTest.php | 132 -- .../Directions/DirectionsRequestTest.php | 535 ----- .../Directions/DirectionsResponseTest.php | 73 - .../Directions/DirectionsRouteTest.php | 138 -- .../Directions/DirectionsStatusTest.php | 38 - .../Directions/DirectionsStepTest.php | 121 -- tests/Services/Directions/DirectionsTest.php | 285 --- .../Directions/DirectionsWaypointTest.php | 122 -- .../DistanceMatrixElementStatusTest.php | 33 - .../DistanceMatrixRequestTest.php | 351 --- .../DistanceMatrixResponseElementTest.php | 84 - .../DistanceMatrixResponseRowTest.php | 56 - .../DistanceMatrixResponseTest.php | 90 - .../DistanceMatrixStatusTest.php | 37 - .../DistanceMatrix/DistanceMatrixTest.php | 256 --- .../Geocoding/GeocoderProviderTest.php | 275 --- .../Geocoding/GeocoderRequestTest.php | 261 --- tests/Services/Geocoding/GeocoderTest.php | 94 - .../Result/GeocoderAddressComponentTest.php | 117 - .../Geocoding/Result/GeocoderGeometryTest.php | 114 - .../Result/GeocoderLocationTypeTest.php | 34 - .../Geocoding/Result/GeocoderResponseTest.php | 93 - .../Geocoding/Result/GeocoderResultTest.php | 181 -- .../Geocoding/Result/GeocoderStatusTest.php | 37 - tests/Services/Utils/XmlParserTest.php | 62 - tests/Utility/OptionsAwareTest.php | 91 + tests/Utility/VariableAwareTest.php | 74 + tests/{bootstrap.php => autoload.php} | 6 +- 741 files changed, 42420 insertions(+), 33915 deletions(-) delete mode 100644 .coveralls.yml create mode 100644 .php_cs rename UPGRADE.md => UPGRADE-1.0.md (99%) create mode 100644 UPGRADE-2.0.md create mode 100644 doc/control/index.md create mode 100644 doc/control/map_type.md create mode 100644 doc/control/rotate.md create mode 100644 doc/control/scale.md create mode 100644 doc/control/street_view.md create mode 100644 doc/control/zoom.md create mode 100644 doc/event.md create mode 100644 doc/helper/api.md create mode 100644 doc/helper/index.md create mode 100644 doc/helper/map.md create mode 100644 doc/helper/place_autocomplete.md create mode 100644 doc/layer/index.md create mode 100644 doc/layer/kml_layer.md create mode 100644 doc/map.md create mode 100644 doc/overlay/circle.md create mode 100644 doc/overlay/encoded_polyline.md create mode 100644 doc/overlay/ground_overlay.md create mode 100644 doc/overlay/icon.md create mode 100644 doc/overlay/index.md create mode 100644 doc/overlay/info_box.md create mode 100644 doc/overlay/info_window.md create mode 100644 doc/overlay/marker.md create mode 100644 doc/overlay/marker_clusterer.md rename doc/{usage/overlays => overlay}/marker_shape.md (53%) create mode 100644 doc/overlay/polygon.md create mode 100644 doc/overlay/polyline.md create mode 100644 doc/overlay/rectangle.md create mode 100644 doc/place/autocomplete.md rename doc/{usage/places => place}/index.md (72%) create mode 100644 doc/service/business_account.md create mode 100644 doc/service/directions/directions.md create mode 100644 doc/service/directions/directions_request.md rename doc/{usage/services/directions/directions.md => service/directions/directions_response.md} (52%) create mode 100644 doc/service/distance_matrix/distance_matrix.md create mode 100644 doc/service/distance_matrix/distance_matrix_request.md create mode 100644 doc/service/distance_matrix/distance_matrix_response.md create mode 100644 doc/service/geocoder/geocoder.md create mode 100644 doc/service/geocoder/geocoder_request.md create mode 100644 doc/service/geocoder/geocoder_response.md create mode 100644 doc/service/index.md create mode 100644 doc/service/service.md delete mode 100644 doc/usage/controls/index.md delete mode 100644 doc/usage/controls/map_type.md delete mode 100644 doc/usage/controls/overview.md delete mode 100644 doc/usage/controls/pan.md delete mode 100644 doc/usage/controls/rotate.md delete mode 100644 doc/usage/controls/scale.md delete mode 100644 doc/usage/controls/street_view.md delete mode 100644 doc/usage/controls/zoom.md delete mode 100644 doc/usage/events.md delete mode 100644 doc/usage/helper/container.md delete mode 100644 doc/usage/helper/extension.md delete mode 100644 doc/usage/layers/index.md delete mode 100644 doc/usage/layers/kml_layer.md delete mode 100644 doc/usage/map.md delete mode 100644 doc/usage/overlays/circle.md delete mode 100644 doc/usage/overlays/encoded_polyline.md delete mode 100644 doc/usage/overlays/ground_overlay.md delete mode 100644 doc/usage/overlays/index.md delete mode 100644 doc/usage/overlays/info_box.md delete mode 100644 doc/usage/overlays/info_window.md delete mode 100644 doc/usage/overlays/marker.md delete mode 100644 doc/usage/overlays/marker_cluster.md delete mode 100644 doc/usage/overlays/marker_image.md delete mode 100644 doc/usage/overlays/polygon.md delete mode 100644 doc/usage/overlays/polyline.md delete mode 100644 doc/usage/overlays/rectangle.md delete mode 100644 doc/usage/places/autocomplete.md delete mode 100644 doc/usage/services/business_account.md delete mode 100644 doc/usage/services/directions/directions_request.md delete mode 100644 doc/usage/services/distance_matrix/distance_matrix.md delete mode 100644 doc/usage/services/distance_matrix/distance_matrix_request.md delete mode 100644 doc/usage/services/geocoding/geocoder.md delete mode 100644 doc/usage/services/geocoding/geocoder_request.md delete mode 100644 doc/usage/services/geocoding/ivory_geocoder.md delete mode 100644 doc/usage/services/index.md create mode 100644 phpunit.travis.xml delete mode 100644 src/Assets/AbstractJavascriptVariableAsset.php delete mode 100644 src/Assets/AbstractOptionsAsset.php create mode 100644 src/Control/ControlManager.php rename src/{Controls => Control}/ControlPosition.php (53%) create mode 100644 src/Control/MapTypeControl.php rename src/{Controls => Control}/MapTypeControlStyle.php (51%) create mode 100644 src/Control/RotateControl.php create mode 100644 src/Control/ScaleControl.php rename src/{Controls => Control}/ScaleControlStyle.php (51%) create mode 100644 src/Control/StreetViewControl.php create mode 100644 src/Control/ZoomControl.php rename src/{Controls => Control}/ZoomControlStyle.php (51%) delete mode 100644 src/Controls/MapTypeControl.php delete mode 100644 src/Controls/OverviewMapControl.php delete mode 100644 src/Controls/PanControl.php delete mode 100644 src/Controls/RotateControl.php delete mode 100644 src/Controls/ScaleControl.php delete mode 100644 src/Controls/StreetViewControl.php delete mode 100644 src/Controls/ZoomControl.php create mode 100644 src/Event/Event.php create mode 100644 src/Event/EventManager.php rename src/{Events => Event}/MouseEvent.php (50%) delete mode 100644 src/Events/Event.php delete mode 100644 src/Events/EventManager.php delete mode 100644 src/Exception/AssetException.php delete mode 100644 src/Exception/BaseException.php delete mode 100644 src/Exception/ControlException.php delete mode 100644 src/Exception/DirectionsException.php delete mode 100644 src/Exception/DistanceMatrixException.php delete mode 100644 src/Exception/EventException.php delete mode 100644 src/Exception/GeocodingException.php delete mode 100644 src/Exception/HelperException.php delete mode 100644 src/Exception/LayerException.php delete mode 100644 src/Exception/MapException.php delete mode 100644 src/Exception/OverlayException.php delete mode 100644 src/Exception/PlaceException.php delete mode 100644 src/Exception/ServiceException.php delete mode 100644 src/Helper/Base/BoundHelper.php delete mode 100644 src/Helper/Base/SizeHelper.php create mode 100644 src/Helper/Builder/AbstractHelperBuilder.php create mode 100644 src/Helper/Builder/ApiHelperBuilder.php create mode 100644 src/Helper/Builder/MapHelperBuilder.php create mode 100644 src/Helper/Builder/PlaceAutocompleteHelperBuilder.php create mode 100644 src/Helper/Collector/AbstractCollector.php create mode 100644 src/Helper/Collector/Base/BoundCollector.php create mode 100644 src/Helper/Collector/Base/CoordinateCollector.php create mode 100644 src/Helper/Collector/Base/PointCollector.php create mode 100644 src/Helper/Collector/Base/SizeCollector.php create mode 100644 src/Helper/Collector/Event/DomEventCollector.php create mode 100644 src/Helper/Collector/Event/DomEventOnceCollector.php create mode 100644 src/Helper/Collector/Event/EventCollector.php create mode 100644 src/Helper/Collector/Event/EventOnceCollector.php create mode 100644 src/Helper/Collector/Layer/KmlLayerCollector.php create mode 100644 src/Helper/Collector/Overlay/CircleCollector.php create mode 100644 src/Helper/Collector/Overlay/DefaultInfoWindowCollector.php create mode 100644 src/Helper/Collector/Overlay/EncodedPolylineCollector.php create mode 100644 src/Helper/Collector/Overlay/ExtendableCollector.php create mode 100644 src/Helper/Collector/Overlay/GroundOverlayCollector.php create mode 100644 src/Helper/Collector/Overlay/IconCollector.php create mode 100644 src/Helper/Collector/Overlay/InfoBoxCollector.php create mode 100644 src/Helper/Collector/Overlay/InfoWindowCollector.php create mode 100644 src/Helper/Collector/Overlay/MarkerCollector.php create mode 100644 src/Helper/Collector/Overlay/PolygonCollector.php create mode 100644 src/Helper/Collector/Overlay/PolylineCollector.php create mode 100644 src/Helper/Collector/Overlay/RectangleCollector.php create mode 100644 src/Helper/Collector/Place/AutocompleteBoundCollector.php create mode 100644 src/Helper/Collector/Place/AutocompleteCoordinateCollector.php delete mode 100644 src/Helper/Controls/ControlPositionHelper.php delete mode 100644 src/Helper/Controls/MapTypeControlHelper.php delete mode 100644 src/Helper/Controls/MapTypeControlStyleHelper.php delete mode 100644 src/Helper/Controls/OverviewMapControlHelper.php delete mode 100644 src/Helper/Controls/PanControlHelper.php delete mode 100644 src/Helper/Controls/RotateControlHelper.php delete mode 100644 src/Helper/Controls/ScaleControlHelper.php delete mode 100644 src/Helper/Controls/ScaleControlStyleHelper.php delete mode 100644 src/Helper/Controls/StreetViewControlHelper.php delete mode 100644 src/Helper/Controls/ZoomControlHelper.php delete mode 100644 src/Helper/Controls/ZoomControlStyleHelper.php create mode 100644 src/Helper/Event/AbstractEvent.php create mode 100644 src/Helper/Event/ApiEvent.php create mode 100644 src/Helper/Event/ApiEvents.php create mode 100644 src/Helper/Event/MapEvent.php create mode 100644 src/Helper/Event/MapEvents.php create mode 100644 src/Helper/Event/PlaceAutocompleteEvent.php create mode 100644 src/Helper/Event/PlaceAutocompleteEvents.php delete mode 100644 src/Helper/Events/EventManagerHelper.php delete mode 100644 src/Helper/Extension/AbstractExtensionHelper.php delete mode 100644 src/Helper/Extension/CoreExtensionHelper.php delete mode 100644 src/Helper/Extension/ExtensionHelperInterface.php delete mode 100644 src/Helper/Extension/InfoBoxExtensionHelper.php create mode 100644 src/Helper/Formatter/Formatter.php delete mode 100644 src/Helper/Geometry/EncodingHelper.php delete mode 100644 src/Helper/Layers/KMLLayerHelper.php delete mode 100644 src/Helper/MapTypeIdHelper.php delete mode 100644 src/Helper/Overlays/AnimationHelper.php delete mode 100644 src/Helper/Overlays/CircleHelper.php delete mode 100644 src/Helper/Overlays/EncodedPolylineHelper.php delete mode 100644 src/Helper/Overlays/GroundOverlayHelper.php delete mode 100644 src/Helper/Overlays/InfoBoxHelper.php delete mode 100644 src/Helper/Overlays/InfoWindowHelper.php delete mode 100644 src/Helper/Overlays/MarkerCluster/AbstractMarkerClusterHelper.php delete mode 100644 src/Helper/Overlays/MarkerCluster/DefaultMarkerClusterHelper.php delete mode 100644 src/Helper/Overlays/MarkerCluster/JsMarkerClusterHelper.php delete mode 100644 src/Helper/Overlays/MarkerCluster/MarkerClusterHelper.php delete mode 100644 src/Helper/Overlays/MarkerCluster/MarkerClusterHelperInterface.php delete mode 100644 src/Helper/Overlays/MarkerHelper.php delete mode 100644 src/Helper/Overlays/MarkerImageHelper.php delete mode 100644 src/Helper/Overlays/MarkerShapeHelper.php delete mode 100644 src/Helper/Overlays/PolygonHelper.php delete mode 100644 src/Helper/Overlays/PolylineHelper.php delete mode 100644 src/Helper/Overlays/RectangleHelper.php create mode 100644 src/Helper/PlaceAutocompleteHelper.php delete mode 100644 src/Helper/Places/AutocompleteHelper.php create mode 100644 src/Helper/Renderer/AbstractJsonRenderer.php create mode 100644 src/Helper/Renderer/AbstractRenderer.php create mode 100644 src/Helper/Renderer/ApiInitRenderer.php create mode 100644 src/Helper/Renderer/ApiRenderer.php create mode 100644 src/Helper/Renderer/Base/BoundRenderer.php rename src/Helper/{Base/CoordinateHelper.php => Renderer/Base/CoordinateRenderer.php} (53%) rename src/Helper/{Base/PointHelper.php => Renderer/Base/PointRenderer.php} (53%) create mode 100644 src/Helper/Renderer/Base/SizeRenderer.php create mode 100644 src/Helper/Renderer/Control/ControlManagerRenderer.php create mode 100644 src/Helper/Renderer/Control/ControlPositionRenderer.php rename src/{Overlays/ExtendableInterface.php => Helper/Renderer/Control/ControlRendererInterface.php} (59%) create mode 100644 src/Helper/Renderer/Control/MapTypeControlRenderer.php create mode 100644 src/Helper/Renderer/Control/MapTypeControlStyleRenderer.php create mode 100644 src/Helper/Renderer/Control/RotateControlRenderer.php create mode 100644 src/Helper/Renderer/Control/ScaleControlRenderer.php create mode 100644 src/Helper/Renderer/Control/ScaleControlStyleRenderer.php create mode 100644 src/Helper/Renderer/Control/StreetViewControlRenderer.php create mode 100644 src/Helper/Renderer/Control/ZoomControlRenderer.php create mode 100644 src/Helper/Renderer/Control/ZoomControlStyleRenderer.php create mode 100644 src/Helper/Renderer/Event/AbstractEventRenderer.php create mode 100644 src/Helper/Renderer/Event/DomEventOnceRenderer.php create mode 100644 src/Helper/Renderer/Event/DomEventRenderer.php create mode 100644 src/Helper/Renderer/Event/EventOnceRenderer.php create mode 100644 src/Helper/Renderer/Event/EventRenderer.php create mode 100644 src/Helper/Renderer/Geometry/EncodingRenderer.php create mode 100644 src/Helper/Renderer/Html/AbstractTagRenderer.php create mode 100644 src/Helper/Renderer/Html/JavascriptTagRenderer.php create mode 100644 src/Helper/Renderer/Html/StylesheetRenderer.php create mode 100644 src/Helper/Renderer/Html/StylesheetTagRenderer.php create mode 100644 src/Helper/Renderer/Html/TagRenderer.php create mode 100644 src/Helper/Renderer/Layer/KmlLayerRenderer.php create mode 100644 src/Helper/Renderer/LoaderRenderer.php create mode 100644 src/Helper/Renderer/MapBoundRenderer.php create mode 100644 src/Helper/Renderer/MapCenterRenderer.php create mode 100644 src/Helper/Renderer/MapContainerRenderer.php create mode 100644 src/Helper/Renderer/MapHtmlRenderer.php create mode 100644 src/Helper/Renderer/MapRenderer.php create mode 100644 src/Helper/Renderer/MapTypeIdRenderer.php create mode 100644 src/Helper/Renderer/Overlay/AbstractInfoWindowRenderer.php rename tests/Controls/ScaleControlStyleTest.php => src/Helper/Renderer/Overlay/AnimationRenderer.php (51%) create mode 100644 src/Helper/Renderer/Overlay/CircleRenderer.php create mode 100644 src/Helper/Renderer/Overlay/DefaultInfoWindowRenderer.php create mode 100644 src/Helper/Renderer/Overlay/EncodedPolylineRenderer.php create mode 100644 src/Helper/Renderer/Overlay/Extendable/ExtendableRenderer.php create mode 100644 src/Helper/Renderer/Overlay/Extendable/ExtendableRendererInterface.php create mode 100644 src/Helper/Renderer/Overlay/Extendable/PathExtendableRenderer.php create mode 100644 src/Helper/Renderer/Overlay/Extendable/PositionExtendableRenderer.php create mode 100644 src/Helper/Renderer/Overlay/Extendable/UnionExtendableRenderer.php create mode 100644 src/Helper/Renderer/Overlay/GroundOverlayRenderer.php create mode 100644 src/Helper/Renderer/Overlay/IconRenderer.php create mode 100644 src/Helper/Renderer/Overlay/InfoBoxRenderer.php create mode 100644 src/Helper/Renderer/Overlay/InfoWindowCloseRenderer.php create mode 100644 src/Helper/Renderer/Overlay/InfoWindowOpenRenderer.php create mode 100644 src/Helper/Renderer/Overlay/InfoWindowRendererInterface.php create mode 100644 src/Helper/Renderer/Overlay/MarkerClustererRenderer.php create mode 100644 src/Helper/Renderer/Overlay/MarkerRenderer.php create mode 100644 src/Helper/Renderer/Overlay/MarkerShapeRenderer.php create mode 100644 src/Helper/Renderer/Overlay/PolygonRenderer.php create mode 100644 src/Helper/Renderer/Overlay/PolylineRenderer.php create mode 100644 src/Helper/Renderer/Overlay/RectangleRenderer.php create mode 100644 src/Helper/Renderer/Place/AutocompleteContainerRenderer.php create mode 100644 src/Helper/Renderer/Place/AutocompleteHtmlRenderer.php create mode 100644 src/Helper/Renderer/Place/AutocompleteRenderer.php create mode 100644 src/Helper/Renderer/Utility/CallbackRenderer.php create mode 100644 src/Helper/Renderer/Utility/ObjectToArrayRenderer.php create mode 100644 src/Helper/Renderer/Utility/RequirementLoaderRenderer.php create mode 100644 src/Helper/Renderer/Utility/RequirementRenderer.php create mode 100644 src/Helper/Renderer/Utility/SourceRenderer.php create mode 100644 src/Helper/Subscriber/AbstractDelegateSubscriber.php create mode 100644 src/Helper/Subscriber/AbstractSubscriber.php create mode 100644 src/Helper/Subscriber/ApiJavascriptSubscriber.php create mode 100644 src/Helper/Subscriber/Base/BaseSubscriber.php create mode 100644 src/Helper/Subscriber/Base/BoundSubscriber.php create mode 100644 src/Helper/Subscriber/Base/CoordinateSubscriber.php create mode 100644 src/Helper/Subscriber/Base/PointSubscriber.php create mode 100644 src/Helper/Subscriber/Base/SizeSubscriber.php create mode 100644 src/Helper/Subscriber/DelegateSubscriberInterface.php create mode 100644 src/Helper/Subscriber/Event/DomEventOnceSubscriber.php create mode 100644 src/Helper/Subscriber/Event/DomEventSubscriber.php create mode 100644 src/Helper/Subscriber/Event/EventOnceSubscriber.php create mode 100644 src/Helper/Subscriber/Event/EventSubscriber.php create mode 100644 src/Helper/Subscriber/Event/SimpleEventSubscriber.php create mode 100644 src/Helper/Subscriber/Layer/KmlLayerSubscriber.php create mode 100644 src/Helper/Subscriber/Layer/LayerSubscriber.php create mode 100644 src/Helper/Subscriber/MapBoundSubscriber.php create mode 100644 src/Helper/Subscriber/MapCenterSubscriber.php create mode 100644 src/Helper/Subscriber/MapContainerSubscriber.php create mode 100644 src/Helper/Subscriber/MapHtmlSubscriber.php create mode 100644 src/Helper/Subscriber/MapInitSubscriber.php create mode 100644 src/Helper/Subscriber/MapJavascriptSubscriber.php create mode 100644 src/Helper/Subscriber/MapStylesheetSubscriber.php create mode 100644 src/Helper/Subscriber/MapSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/AbstractInfoWindowSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/AbstractMarkerSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/CircleSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/DefaultInfoWindowSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/EncodedPolylineSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/ExtendableSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/GroundOverlaySubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/InfoBoxSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/InfoWindowCloseSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/InfoWindowOpenSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/MarkerClustererSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/MarkerInfoWindowOpenSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/MarkerSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/OverlaySubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/PolygonSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/PolylineSubscriber.php create mode 100644 src/Helper/Subscriber/Overlay/RectangleSubscriber.php create mode 100644 src/Helper/Subscriber/Place/AutocompleteContainerSubscriber.php create mode 100644 src/Helper/Subscriber/Place/AutocompleteHtmlSubscriber.php create mode 100644 src/Helper/Subscriber/Place/AutocompleteInitSubscriber.php create mode 100644 src/Helper/Subscriber/Place/AutocompleteJavascriptSubscriber.php create mode 100644 src/Helper/Subscriber/Place/AutocompleteSubscriber.php create mode 100644 src/Helper/Subscriber/Place/Base/AutocompleteBaseSubscriber.php create mode 100644 src/Helper/Subscriber/Place/Base/AutocompleteBoundSubscriber.php create mode 100644 src/Helper/Subscriber/Place/Base/AutocompleteCoordinateSubscriber.php create mode 100644 src/Helper/Subscriber/Utility/ObjectToArraySubscriber.php create mode 100644 src/Layer/KmlLayer.php create mode 100644 src/Layer/LayerManager.php delete mode 100644 src/Layers/KMLLayer.php rename src/{Overlays => Overlay}/Animation.php (54%) create mode 100644 src/Overlay/Circle.php create mode 100644 src/Overlay/EncodedPolyline.php rename src/{Exception/Exception.php => Overlay/ExtendableInterface.php} (66%) create mode 100644 src/Overlay/GroundOverlay.php create mode 100644 src/Overlay/Icon.php create mode 100644 src/Overlay/InfoWindow.php create mode 100644 src/Overlay/InfoWindowType.php create mode 100644 src/Overlay/Marker.php create mode 100644 src/Overlay/MarkerCluster.php create mode 100644 src/Overlay/MarkerClusterType.php create mode 100644 src/Overlay/MarkerShape.php create mode 100644 src/Overlay/MarkerShapeType.php create mode 100644 src/Overlay/OverlayManager.php create mode 100644 src/Overlay/Polygon.php create mode 100644 src/Overlay/Polyline.php create mode 100644 src/Overlay/Rectangle.php delete mode 100644 src/Overlays/Circle.php delete mode 100644 src/Overlays/EncodedPolyline.php delete mode 100644 src/Overlays/GroundOverlay.php delete mode 100644 src/Overlays/InfoWindow.php delete mode 100644 src/Overlays/Marker.php delete mode 100644 src/Overlays/MarkerCluster.php delete mode 100644 src/Overlays/MarkerImage.php delete mode 100644 src/Overlays/MarkerShape.php delete mode 100644 src/Overlays/Polygon.php delete mode 100644 src/Overlays/Polyline.php delete mode 100644 src/Overlays/Rectangle.php create mode 100644 src/Place/Autocomplete.php create mode 100644 src/Place/AutocompleteComponentRestriction.php create mode 100644 src/Place/AutocompleteType.php delete mode 100644 src/Places/Autocomplete.php delete mode 100644 src/Places/AutocompleteComponentRestriction.php delete mode 100644 src/Places/AutocompleteType.php create mode 100644 src/Service/AbstractService.php create mode 100644 src/Service/Base/Distance.php create mode 100644 src/Service/Base/Duration.php rename src/{Services => Service}/Base/TravelMode.php (53%) rename src/{Services => Service}/Base/UnitSystem.php (53%) create mode 100644 src/Service/BusinessAccount.php create mode 100644 src/Service/Directions/Directions.php create mode 100644 src/Service/Directions/DirectionsLeg.php create mode 100644 src/Service/Directions/DirectionsRequest.php create mode 100644 src/Service/Directions/DirectionsResponse.php create mode 100644 src/Service/Directions/DirectionsRoute.php rename src/{Services => Service}/Directions/DirectionsStatus.php (53%) create mode 100644 src/Service/Directions/DirectionsStep.php create mode 100644 src/Service/Directions/DirectionsWaypoint.php create mode 100644 src/Service/DistanceMatrix/DistanceMatrix.php create mode 100644 src/Service/DistanceMatrix/DistanceMatrixElement.php create mode 100644 src/Service/DistanceMatrix/DistanceMatrixElementStatus.php create mode 100644 src/Service/DistanceMatrix/DistanceMatrixRequest.php create mode 100644 src/Service/DistanceMatrix/DistanceMatrixResponse.php create mode 100644 src/Service/DistanceMatrix/DistanceMatrixRow.php rename src/{Services => Service}/DistanceMatrix/DistanceMatrixStatus.php (50%) create mode 100644 src/Service/Geocoder/GeocoderAddressComponent.php create mode 100644 src/Service/Geocoder/GeocoderGeometry.php rename src/{Services/Geocoding/Result => Service/Geocoder}/GeocoderLocationType.php (51%) create mode 100644 src/Service/Geocoder/GeocoderProvider.php create mode 100644 src/Service/Geocoder/GeocoderRequest.php create mode 100644 src/Service/Geocoder/GeocoderResponse.php create mode 100644 src/Service/Geocoder/GeocoderResult.php rename src/{Services/Geocoding/Result => Service/Geocoder}/GeocoderStatus.php (52%) create mode 100644 src/Service/Utility/XmlParser.php delete mode 100644 src/Services/AbstractService.php delete mode 100644 src/Services/Base/Distance.php delete mode 100644 src/Services/Base/Duration.php delete mode 100644 src/Services/BusinessAccount.php delete mode 100644 src/Services/Directions/Directions.php delete mode 100644 src/Services/Directions/DirectionsLeg.php delete mode 100644 src/Services/Directions/DirectionsRequest.php delete mode 100644 src/Services/Directions/DirectionsResponse.php delete mode 100644 src/Services/Directions/DirectionsRoute.php delete mode 100644 src/Services/Directions/DirectionsStep.php delete mode 100644 src/Services/Directions/DirectionsWaypoint.php delete mode 100644 src/Services/DistanceMatrix/DistanceMatrix.php delete mode 100644 src/Services/DistanceMatrix/DistanceMatrixElementStatus.php delete mode 100644 src/Services/DistanceMatrix/DistanceMatrixRequest.php delete mode 100644 src/Services/DistanceMatrix/DistanceMatrixResponse.php delete mode 100644 src/Services/DistanceMatrix/DistanceMatrixResponseElement.php delete mode 100644 src/Services/DistanceMatrix/DistanceMatrixResponseRow.php delete mode 100644 src/Services/Geocoding/Geocoder.php delete mode 100644 src/Services/Geocoding/GeocoderProvider.php delete mode 100644 src/Services/Geocoding/GeocoderRequest.php delete mode 100644 src/Services/Geocoding/Result/GeocoderAddressComponent.php delete mode 100644 src/Services/Geocoding/Result/GeocoderGeometry.php delete mode 100644 src/Services/Geocoding/Result/GeocoderResponse.php delete mode 100644 src/Services/Geocoding/Result/GeocoderResult.php delete mode 100644 src/Services/Utils/XmlParser.php create mode 100644 src/Utility/OptionsAwareInterface.php create mode 100644 src/Utility/OptionsAwareTrait.php create mode 100644 src/Utility/VariableAwareInterface.php create mode 100644 src/Utility/VariableAwareTrait.php delete mode 100644 tests/Assets/JavascriptVariableAssetTest.php delete mode 100644 tests/Assets/OptionsAssetTest.php create mode 100644 tests/Control/ControlManagerTest.php create mode 100644 tests/Control/MapTypeControlTest.php create mode 100644 tests/Control/RotateControlTest.php create mode 100644 tests/Control/ScaleControlTest.php create mode 100644 tests/Control/StreetViewControlTest.php create mode 100644 tests/Control/ZoomControlTest.php delete mode 100644 tests/Controls/ControlPositionTest.php delete mode 100644 tests/Controls/MapTypeControlStyleTest.php delete mode 100644 tests/Controls/MapTypeControlTest.php delete mode 100644 tests/Controls/OverviewMapControlTest.php delete mode 100644 tests/Controls/PanControlTest.php delete mode 100644 tests/Controls/RotateControlTest.php delete mode 100644 tests/Controls/ScaleControlTest.php delete mode 100644 tests/Controls/StreetViewControlTest.php delete mode 100644 tests/Controls/ZoomControlStyleTest.php delete mode 100644 tests/Controls/ZoomControlTest.php create mode 100644 tests/Event/EventManagerTest.php create mode 100644 tests/Event/EventTest.php delete mode 100644 tests/Events/EventManagerTest.php delete mode 100644 tests/Events/EventTest.php delete mode 100644 tests/Events/MouseEventTest.php delete mode 100644 tests/Helper/AbstractHelperTest.php delete mode 100644 tests/Helper/ApiHelperTest.php delete mode 100644 tests/Helper/Base/BoundHelperTest.php delete mode 100644 tests/Helper/Base/CoordinateHelperTest.php delete mode 100644 tests/Helper/Base/PointHelperTest.php delete mode 100644 tests/Helper/Base/SizeHelperTest.php create mode 100644 tests/Helper/Builder/ApiHelperBuilderTest.php create mode 100644 tests/Helper/Builder/HelperBuilderTest.php create mode 100644 tests/Helper/Builder/MapHelperBuilderTest.php create mode 100644 tests/Helper/Builder/PlaceAutocompleteHelperBuilderTest.php create mode 100644 tests/Helper/Collector/Base/BoundCollectorTest.php create mode 100644 tests/Helper/Collector/Base/CoordinateCollectorTest.php create mode 100644 tests/Helper/Collector/Base/PointCollectorTest.php create mode 100644 tests/Helper/Collector/Base/SizeCollectorTest.php create mode 100644 tests/Helper/Collector/Event/DomEventCollectorTest.php create mode 100644 tests/Helper/Collector/Event/DomEventOnceCollectorTest.php create mode 100644 tests/Helper/Collector/Event/EventCollectorTest.php create mode 100644 tests/Helper/Collector/Event/EventOnceCollectorTest.php create mode 100644 tests/Helper/Collector/Layer/KmlLayerCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/CircleCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/DefaultInfoWindowCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/EncodedPolylineCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/ExtendableCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/GroundOverlayCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/IconCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/InfoBoxCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/InfoWindowCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/MarkerCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/PolygonCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/PolylineCollectorTest.php create mode 100644 tests/Helper/Collector/Overlay/RectangleCollectorTest.php create mode 100644 tests/Helper/Collector/Place/AutocompleteBoundCollectorTest.php create mode 100644 tests/Helper/Collector/Place/AutocompleteCoordinateCollectorTest.php delete mode 100644 tests/Helper/Controls/ControlPositionHelperTest.php delete mode 100644 tests/Helper/Controls/MapTypeControlHelperTest.php delete mode 100644 tests/Helper/Controls/MapTypeControlStyleHelperTest.php delete mode 100644 tests/Helper/Controls/OverviewMapControlHelperTest.php delete mode 100644 tests/Helper/Controls/PanControlHelperTest.php delete mode 100644 tests/Helper/Controls/RotateControlHelperTest.php delete mode 100644 tests/Helper/Controls/ScaleControlHelperTest.php delete mode 100644 tests/Helper/Controls/ScaleControlStyleHelperTest.php delete mode 100644 tests/Helper/Controls/StreetViewControlHelperTest.php delete mode 100644 tests/Helper/Controls/ZoomControlHelperTest.php delete mode 100644 tests/Helper/Controls/ZoomControlStyleHelperTest.php create mode 100644 tests/Helper/Event/ApiEventTest.php create mode 100644 tests/Helper/Event/EventTest.php create mode 100644 tests/Helper/Event/MapEventTest.php create mode 100644 tests/Helper/Event/PlaceAutocompleteEventTest.php delete mode 100644 tests/Helper/Events/EventManagerHelperTest.php delete mode 100644 tests/Helper/Extension/CoreExtensionHelperTest.php delete mode 100644 tests/Helper/Extension/InfoBoxExtensionHelperTest.php create mode 100644 tests/Helper/Formatter/FormatterTest.php create mode 100644 tests/Helper/Functional/AbstractApiFunctionalTest.php create mode 100644 tests/Helper/Functional/AbstractFunctionalTest.php create mode 100644 tests/Helper/Functional/AbstractMapFunctionalTest.php create mode 100644 tests/Helper/Functional/CompoundFunctionalTest.php create mode 100644 tests/Helper/Functional/Control/MapTypeControlFunctionalTest.php create mode 100644 tests/Helper/Functional/Control/RotateControlFunctionalTest.php create mode 100644 tests/Helper/Functional/Control/ScaleControlFunctionalTest.php create mode 100644 tests/Helper/Functional/Control/StreetViewControlFunctionalTest.php create mode 100644 tests/Helper/Functional/Control/ZoomControlFunctionalTest.php create mode 100644 tests/Helper/Functional/Layer/KmlLayerFunctionalTest.php create mode 100644 tests/Helper/Functional/MapFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/CircleFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/EncodedPolylineFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/GroundOverlayFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/InfoBoxFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/InfoWindowFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/MarkerClustererFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/MarkerFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/MarkerInfoWindowFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/MixedInfoWindowFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/PolygonFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/PolylineFunctionalTest.php create mode 100644 tests/Helper/Functional/Overlay/RectangleFunctionalTest.php create mode 100644 tests/Helper/Functional/Place/AbstractAutocompleteFunctionalTest.php create mode 100644 tests/Helper/Functional/Place/AutocompleteFunctionalTest.php delete mode 100644 tests/Helper/Geometry/EncodingHelperTest.php delete mode 100644 tests/Helper/Layers/KMLLayerHelperTest.php delete mode 100644 tests/Helper/MapHelperTest.php delete mode 100644 tests/Helper/MapTypeIdHelperTest.php delete mode 100644 tests/Helper/Overlays/AnimationHelperTest.php delete mode 100644 tests/Helper/Overlays/CircleHelperTest.php delete mode 100644 tests/Helper/Overlays/EncodedPolylineHelperTest.php delete mode 100644 tests/Helper/Overlays/GroundOverlayHelperTest.php delete mode 100644 tests/Helper/Overlays/InfoBoxHelperTest.php delete mode 100644 tests/Helper/Overlays/InfoWindowHelperTest.php delete mode 100644 tests/Helper/Overlays/MarkerCluster/AbstractMarkerClusterHelperTest.php delete mode 100644 tests/Helper/Overlays/MarkerCluster/DefaultMarkerClusterHelperTest.php delete mode 100644 tests/Helper/Overlays/MarkerCluster/JsMarkerClusterHelperTest.php delete mode 100644 tests/Helper/Overlays/MarkerCluster/MarkerClusterHelperTest.php delete mode 100644 tests/Helper/Overlays/MarkerHelperTest.php delete mode 100644 tests/Helper/Overlays/MarkerImageHelperTest.php delete mode 100644 tests/Helper/Overlays/MarkerShapeHelperTest.php delete mode 100644 tests/Helper/Overlays/PolygonHelperTest.php delete mode 100644 tests/Helper/Overlays/PolylineHelperTest.php delete mode 100644 tests/Helper/Overlays/RectangleHelperTest.php delete mode 100644 tests/Helper/Places/AutocompleteHelperTest.php create mode 100644 tests/Helper/Renderer/ApiInitRendererTest.php create mode 100644 tests/Helper/Renderer/ApiRendererTest.php create mode 100644 tests/Helper/Renderer/Base/BoundRendererTest.php create mode 100644 tests/Helper/Renderer/Base/CoordinateRendererTest.php create mode 100644 tests/Helper/Renderer/Base/PointRendererTest.php create mode 100644 tests/Helper/Renderer/Base/SizeRendererTest.php create mode 100644 tests/Helper/Renderer/Control/ControlManagerRendererTest.php create mode 100644 tests/Helper/Renderer/Control/ControlPositionRendererTest.php create mode 100644 tests/Helper/Renderer/Control/MapTypeControlRendererTest.php create mode 100644 tests/Helper/Renderer/Control/MapTypeControlStyleRendererTest.php create mode 100644 tests/Helper/Renderer/Control/RotateControlRendererTest.php create mode 100644 tests/Helper/Renderer/Control/ScaleControlRendererTest.php create mode 100644 tests/Helper/Renderer/Control/ScaleControlStyleRendererTest.php create mode 100644 tests/Helper/Renderer/Control/StreetViewControlRendererTest.php create mode 100644 tests/Helper/Renderer/Control/ZoomControlRendererTest.php create mode 100644 tests/Helper/Renderer/Control/ZoomControlStyleRendererTest.php create mode 100644 tests/Helper/Renderer/Event/AbstractEventRendererTest.php create mode 100644 tests/Helper/Renderer/Event/DomEventOnceRendererTest.php create mode 100644 tests/Helper/Renderer/Event/DomEventRendererTest.php create mode 100644 tests/Helper/Renderer/Event/EventOnceRendererTest.php create mode 100644 tests/Helper/Renderer/Event/EventRendererTest.php create mode 100644 tests/Helper/Renderer/Geometry/EncodingRendererTest.php create mode 100644 tests/Helper/Renderer/Html/AbstractTagRendererTest.php create mode 100644 tests/Helper/Renderer/Html/JavascriptTagRendererTest.php create mode 100644 tests/Helper/Renderer/Html/StylesheetRendererTest.php create mode 100644 tests/Helper/Renderer/Html/StylesheetTagRendererTest.php create mode 100644 tests/Helper/Renderer/Html/TagRendererTest.php create mode 100644 tests/Helper/Renderer/JsonRendererTest.php create mode 100644 tests/Helper/Renderer/Layer/KmlLayerRendererTest.php create mode 100644 tests/Helper/Renderer/LoaderRendererTest.php create mode 100644 tests/Helper/Renderer/MapBoundRendererTest.php create mode 100644 tests/Helper/Renderer/MapCenterRendererTest.php create mode 100644 tests/Helper/Renderer/MapContainerRendererTest.php create mode 100644 tests/Helper/Renderer/MapHtmlRendererTest.php create mode 100644 tests/Helper/Renderer/MapRendererTest.php create mode 100644 tests/Helper/Renderer/MapTypeIdRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/AnimationRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/CircleRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/DefaultInfoWindowRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/EncodedPolylineRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/Extendable/ExtendableRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/Extendable/PathExtendableRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/Extendable/PositionExtendableRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/Extendable/UnionExtendableRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/GroundOverlayRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/IconRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/InfoBoxRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/InfoWindowCloseRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/InfoWindowOpenRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/InfoWindowRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/MarkerClustererRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/MarkerRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/MarkerShapeRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/PolygonRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/PolylineRendererTest.php create mode 100644 tests/Helper/Renderer/Overlay/RectangleRendererTest.php create mode 100644 tests/Helper/Renderer/Place/AutocompleteContainerRendererTest.php create mode 100644 tests/Helper/Renderer/Place/AutocompleteHtmlRendererTest.php create mode 100644 tests/Helper/Renderer/Place/AutocompleteRendererTest.php create mode 100644 tests/Helper/Renderer/RendererTest.php create mode 100644 tests/Helper/Renderer/Utility/CallbackRendererTest.php create mode 100644 tests/Helper/Renderer/Utility/ObjectToArrayRendererTest.php create mode 100644 tests/Helper/Renderer/Utility/RequirementLoaderRendererTest.php create mode 100644 tests/Helper/Renderer/Utility/SourceRendererTest.php create mode 100644 tests/Layer/KmlLayerTest.php create mode 100644 tests/Layer/LayerManagerTest.php delete mode 100644 tests/Layers/KMLLayerTest.php delete mode 100644 tests/MapTypeIdTest.php create mode 100644 tests/Overlay/CircleTest.php create mode 100644 tests/Overlay/EncodedPolylineTest.php create mode 100644 tests/Overlay/GroundOverlayTest.php create mode 100644 tests/Overlay/IconTest.php create mode 100644 tests/Overlay/InfoWindowTest.php create mode 100644 tests/Overlay/MarkerClusterTest.php create mode 100644 tests/Overlay/MarkerShapeTest.php create mode 100644 tests/Overlay/MarkerTest.php create mode 100644 tests/Overlay/OverlayManagerTest.php create mode 100644 tests/Overlay/PolygonTest.php create mode 100644 tests/Overlay/PolylineTest.php create mode 100644 tests/Overlay/RectangleTest.php delete mode 100644 tests/Overlays/AnimationTest.php delete mode 100644 tests/Overlays/CircleTest.php delete mode 100644 tests/Overlays/EncodedPolylineTest.php delete mode 100644 tests/Overlays/GroundOverlayTest.php delete mode 100644 tests/Overlays/InfoWindowTest.php delete mode 100644 tests/Overlays/MarkerClusterTest.php delete mode 100644 tests/Overlays/MarkerImageTest.php delete mode 100644 tests/Overlays/MarkerShapeTest.php delete mode 100644 tests/Overlays/MarkerTest.php delete mode 100644 tests/Overlays/PolygonTest.php delete mode 100644 tests/Overlays/PolylineTest.php delete mode 100644 tests/Overlays/RectangleTest.php create mode 100644 tests/Place/AutocompleteTest.php delete mode 100644 tests/Places/AutocompleteComponentRestrictionTest.php delete mode 100644 tests/Places/AutocompleteTest.php delete mode 100644 tests/Places/AutocompleteTypeTest.php create mode 100644 tests/Service/.cache/0/G/+GzvChCNKC3DaLz2oxPg create mode 100644 tests/Service/.cache/1/J/ofymTyre3fHTOJ1NdqkQ create mode 100644 tests/Service/.cache/3/j/tedxvL8kjLkHVEVUVzJg create mode 100644 tests/Service/.cache/6/W/0NC+6QA9PyiUswxLXrlg create mode 100644 tests/Service/.cache/A/l/PchupASIKWubyOo44B3A create mode 100644 tests/Service/.cache/A/y/OYhD4u1fh4kR7UkMEE6A create mode 100644 tests/Service/.cache/B/0/JlpD73RFxlhSBl5v8GpA create mode 100644 tests/Service/.cache/C/6/BkdZWhu17mUUfJfJ99Og create mode 100644 tests/Service/.cache/L/B/IG6IT4HHJzhrGCF8jbEA create mode 100644 tests/Service/.cache/M/X/Idjx5HZUUigUg2-PS0kQ create mode 100644 tests/Service/.cache/N/G/WjiVLJAzRsi8tdJXKgow create mode 100644 tests/Service/.cache/O/+/eEdAvTWtWvIQWFIstqLw create mode 100644 tests/Service/.cache/O/3/Z11lXG43qQ14lYU0JXtA create mode 100644 tests/Service/.cache/O/v/P5LtIbOLpceRXfKhOCWw create mode 100644 tests/Service/.cache/P/B/IavO8VJ5AzalRMSw6juA create mode 100644 tests/Service/.cache/S/R/SCHdwMXvr81IgBFn3SYA create mode 100644 tests/Service/.cache/S/y/ALbZbs-ES8zgvfPbpbFA create mode 100644 tests/Service/.cache/V/J/S7lTw55ItQnE++nJlxNQ create mode 100644 tests/Service/.cache/Z/y/k-471oym0TOSmHsBQALQ create mode 100644 tests/Service/.cache/d/-/dv8bvFVsoGcE21e2n4PA create mode 100644 tests/Service/.cache/d/k/I1UGOZB79LQiK0GlapLA create mode 100644 tests/Service/.cache/g/i/R724U9mpkjhZuwoQvgHg create mode 100644 tests/Service/.cache/h/H/+7II4g5fdI92KaPhDoSA create mode 100644 tests/Service/.cache/h/I/0RzQt4n60sUFmL-7xk0g create mode 100644 tests/Service/.cache/i/5/dXZUYxu+wzMxvCYhvVlQ create mode 100644 tests/Service/.cache/m/1/NYlgc92PLB+CHQxyMyAg create mode 100644 tests/Service/.cache/n/u/wnUryzMtlAq1P2MDMNSw create mode 100644 tests/Service/.cache/o/s/cWZEtDFEJNKdDr-9rElA create mode 100644 tests/Service/.cache/q/T/qlAToFSNCJ-FOlkd4sNw create mode 100644 tests/Service/.cache/q/Z/P3l5MZYvMpMfDXGpD9+A create mode 100644 tests/Service/.cache/r/+/W4JvLH5KNZM1m-qw2EUg create mode 100644 tests/Service/.cache/v/E/KKeEAYnZW+G+uOVxSZaA create mode 100644 tests/Service/.cache/v/v/bru-4eLCrJjT4fi3aj9w create mode 100644 tests/Service/.cache/x/k/zk2vyqdID0wC23yca6vQ create mode 100644 tests/Service/.cache/y/P/lKyR4+cjcCGyJ49zN02A create mode 100644 tests/Service/.cache/z/A/syfS2Tia0KK6N8wqlhRA create mode 100644 tests/Service/AbstractServiceTest.php create mode 100644 tests/Service/Base/DistanceTest.php create mode 100644 tests/Service/Base/DurationTest.php create mode 100644 tests/Service/BusinessAccountTest.php create mode 100644 tests/Service/Directions/DirectionsLegTest.php create mode 100644 tests/Service/Directions/DirectionsRequestTest.php create mode 100644 tests/Service/Directions/DirectionsResponseTest.php create mode 100644 tests/Service/Directions/DirectionsRouteTest.php create mode 100644 tests/Service/Directions/DirectionsStepTest.php create mode 100644 tests/Service/Directions/DirectionsTest.php create mode 100644 tests/Service/Directions/DirectionsWaypointTest.php create mode 100644 tests/Service/DistanceMatrix/DistanceMatrixElementTest.php create mode 100644 tests/Service/DistanceMatrix/DistanceMatrixRequestTest.php create mode 100644 tests/Service/DistanceMatrix/DistanceMatrixResponseTest.php create mode 100644 tests/Service/DistanceMatrix/DistanceMatrixRowTest.php create mode 100644 tests/Service/DistanceMatrix/DistanceMatrixTest.php create mode 100644 tests/Service/Geocoder/GeocoderAddressComponentTest.php create mode 100644 tests/Service/Geocoder/GeocoderGeometryTest.php create mode 100644 tests/Service/Geocoder/GeocoderProviderTest.php create mode 100644 tests/Service/Geocoder/GeocoderRequestTest.php create mode 100644 tests/Service/Geocoder/GeocoderResponseTest.php create mode 100644 tests/Service/Geocoder/GeocoderResultTest.php create mode 100644 tests/Service/ServiceTest.php create mode 100644 tests/Service/Utility/XmlParserTest.php delete mode 100644 tests/Services/AbstractServiceTest.php delete mode 100644 tests/Services/Base/DistanceTest.php delete mode 100644 tests/Services/Base/DurationTest.php delete mode 100644 tests/Services/Base/TravelModeTest.php delete mode 100644 tests/Services/Base/UnitSystemTest.php delete mode 100644 tests/Services/BusinessAccountTest.php delete mode 100644 tests/Services/Directions/DirectionsLegTest.php delete mode 100644 tests/Services/Directions/DirectionsRequestTest.php delete mode 100644 tests/Services/Directions/DirectionsResponseTest.php delete mode 100644 tests/Services/Directions/DirectionsRouteTest.php delete mode 100644 tests/Services/Directions/DirectionsStatusTest.php delete mode 100644 tests/Services/Directions/DirectionsStepTest.php delete mode 100644 tests/Services/Directions/DirectionsTest.php delete mode 100644 tests/Services/Directions/DirectionsWaypointTest.php delete mode 100644 tests/Services/DistanceMatrix/DistanceMatrixElementStatusTest.php delete mode 100644 tests/Services/DistanceMatrix/DistanceMatrixRequestTest.php delete mode 100644 tests/Services/DistanceMatrix/DistanceMatrixResponseElementTest.php delete mode 100644 tests/Services/DistanceMatrix/DistanceMatrixResponseRowTest.php delete mode 100644 tests/Services/DistanceMatrix/DistanceMatrixResponseTest.php delete mode 100644 tests/Services/DistanceMatrix/DistanceMatrixStatusTest.php delete mode 100644 tests/Services/DistanceMatrix/DistanceMatrixTest.php delete mode 100644 tests/Services/Geocoding/GeocoderProviderTest.php delete mode 100644 tests/Services/Geocoding/GeocoderRequestTest.php delete mode 100644 tests/Services/Geocoding/GeocoderTest.php delete mode 100644 tests/Services/Geocoding/Result/GeocoderAddressComponentTest.php delete mode 100644 tests/Services/Geocoding/Result/GeocoderGeometryTest.php delete mode 100644 tests/Services/Geocoding/Result/GeocoderLocationTypeTest.php delete mode 100644 tests/Services/Geocoding/Result/GeocoderResponseTest.php delete mode 100644 tests/Services/Geocoding/Result/GeocoderResultTest.php delete mode 100644 tests/Services/Geocoding/Result/GeocoderStatusTest.php delete mode 100644 tests/Services/Utils/XmlParserTest.php create mode 100644 tests/Utility/OptionsAwareTest.php create mode 100644 tests/Utility/VariableAwareTest.php rename tests/{bootstrap.php => autoload.php} (61%) diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index bc71b4e4..00000000 --- a/.coveralls.yml +++ /dev/null @@ -1,3 +0,0 @@ -service_name: travis-ci -coverage_clover: clover.xml -json_path: coveralls.json diff --git a/.gitignore b/.gitignore index 2823a707..ced28111 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,5 @@ -# Composer -/bin +/.php_cs.cache +/build /composer.lock -/vendor - -# PHPUnit /phpunit.xml -/clover.xml -/report - -# Coveralls -/coveralls.json +/vendor diff --git a/.php_cs b/.php_cs new file mode 100644 index 00000000..7eed9e2c --- /dev/null +++ b/.php_cs @@ -0,0 +1,20 @@ +in([ + __DIR__.'/src', + __DIR__.'/tests', + ]); + +return Config::create() + ->setUsingCache(true) + ->fixers([ + 'align_double_arrow', + 'short_array_syntax', + 'ordered_use', + '-psr0', + ]) + ->finder($finder); diff --git a/.travis.yml b/.travis.yml index 6ca3218e..137b79c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,18 @@ language: php php: - - 5.3.3 - - 5.3 - - 5.4 - - 5.5 - 5.6 + - 7.0 - hhvm - - hhvm-nightly -before_script: composer install --prefer-source +before_script: + - export DISPLAY=:99 + - /sbin/start-stop-daemon -Sbmq -p /tmp/xvfb_99.pid -x /usr/bin/Xvfb -- ${DISPLAY} -ac -screen 0, 1600x1200x24 + - curl http://selenium-release.storage.googleapis.com/2.48/selenium-server-standalone-2.48.0.jar > selenium.jar + - curl http://chromedriver.storage.googleapis.com/2.12/chromedriver_linux64.zip > chromedriver.zip + - unzip chromedriver.zip + - java -jar selenium.jar -Dwebdriver.chrome.driver=./chromedriver > /dev/null 2>&1 & + - composer self-update + - composer install --prefer-source -script: bin/phpunit --coverage-clover clover.xml - -after_script: bin/coveralls - -matrix: - allow_failures: - - php: hhvm - - php: hhvm-nightly - -notifications: - email: geloen.eric@gmail.com +script: vendor/bin/phpunit --configuration phpunit.travis.xml diff --git a/LICENSE b/LICENSE index f3225e32..77c443ae 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011-2014 Eric GELOEN +Copyright (c) 2011-2016 Eric GELOEN Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the diff --git a/README.md b/README.md index 04b3d85d..13974384 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,65 @@ # README -[![Build Status](https://secure.travis-ci.org/egeloen/ivory-google-map.png?branch=master)](http://travis-ci.org/egeloen/ivory-google-map) -[![Coverage Status](https://coveralls.io/repos/egeloen/ivory-google-map/badge.png?branch=master)](https://coveralls.io/r/egeloen/ivory-google-map?branch=master) +[![Build Status](https://travis-ci.org/egeloen/ivory-google-map.svg?branch=master)](http://travis-ci.org/egeloen/ivory-google-map) +[![Code Coverage](https://scrutinizer-ci.com/g/egeloen/ivory-google-map/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/egeloen/ivory-google-map/?branch=master) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/egeloen/ivory-google-map/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/egeloen/ivory-google-map/?branch=master) +[![Dependency Status](http://www.versioneye.com/php/egeloen:ckeditor-bundle/badge.svg)](http://www.versioneye.com/php/egeloen:ckeditor-bundle) -The Ivory Google Map project provides a Google Map integration for your PHP 5.3+ Project. It allows you to manage map, +[![Latest Stable Version](https://poser.pugx.org/egeloen/google-map/v/stable.svg)](https://packagist.org/packages/egeloen/google-map) +[![Latest Unstable Version](https://poser.pugx.org/egeloen/google-map/v/unstable.svg)](https://packagist.org/packages/egeloen/google-map) +[![Total Downloads](https://poser.pugx.org/egeloen/google-map/downloads.svg)](https://packagist.org/packages/egeloen/google-map) +[![License](https://poser.pugx.org/egeloen/google-map/license.svg)](https://packagist.org/packages/egeloen/google-map) + +The Ivory Google Map project provides a Google Map integration for your PHP 5.6+ project. It allows you to manage map, controls, overlays, events & services through the Google Map API v3. ## Documentation - 1. [Installation](http://github.com/egeloen/ivory-google-map/blob/master/doc/installation.md) - 2. [Usage](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage.md) - - [Map](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/map.md) - - [Overlays](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/index.md) - - [Marker](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker.md) - - [Info window](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/info_window.md) - - [Info box](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/info_box.md) - - [Polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polyline.md) - - [Encoded Polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/encoded_polyline.md) - - [Polygon](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polygon.md) - - [Rectangle](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/rectangle.md) - - [Circle](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/circle.md) - - [Ground overlay](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/ground_overlay.md) - - [Marker cluster](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker_cluster.md) - - [Controls](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/index.md) - - [Map type](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/map_type.md) - - [Overview](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/overview.md) - - [Pan](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/pan.md) - - [Rotate](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/rotate.md) - - [Scale](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/scale.md) - - [Street view](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/street_view.md) - - [Zoom](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/zoom.md) - - [Layers](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/layers/index.md) - - [KML Layer](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/layers/kml_layer.md) - - [Events](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/events.md) - - [Places](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/places/index.md) - - [Autocomplete](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/places/autocomplete.md) - - [Services](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/index.md) - - [Geocoding API](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/geocoding/geocoder.md) - - [Directions API](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/directions/directions.md) - - [Distance Matrix API](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/distance_matrix/distance_matrix.md) - - [Business Account](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/business_account.md) + - [Installation](/doc/installation.md) + - [Usage](/doc/usage.md) + - [Map](/doc/map.md) + - [Controls](/doc/control/index.md) + - [Map type](/doc/control/map_type.md) + - [Rotate](/doc/control/rotate.md) + - [Scale](/doc/control/scale.md) + - [Street view](/doc/control/street_view.md) + - [Zoom](/doc/control/zoom.md) + - [Events](/doc/event.md) + - [Layers](/doc/layer/index.md) + - [Kml Layer](/doc/layer/kml_layer.md) + - [Overlays](/doc/overlay/index.md) + - [Marker](/doc/overlay/marker.md) + - [Info Window](/doc/overlay/info_window.md) + - [Info Box](/doc/overlay/info_box.md) + - [Polyline](/doc/overlay/polyline.md) + - [Encoded Polyline](/doc/overlay/encoded_polyline.md) + - [Polygon](/doc/overlay/polygon.md) + - [Rectangle](/doc/overlay/rectangle.md) + - [Circle](/doc/overlay/circle.md) + - [Ground Overlay](/doc/overlay/ground_overlay.md) + - [Marker Clusterer](/doc/overlay/marker_clusterer.md) + - [Places](/doc/place/index.md) + - [Autocomplete](/doc/place/autocomplete.md) + - [Rendering](/doc/helper/index.md) + - [Map Rendering](/doc/helper/map.md) + - [Places Autocomplete Rendering](/doc/helper/place_autocomplete.md) + - [API Rendering](/doc/helper/api.md) + - [Services](/doc/service/index.md) + - [Directions](/doc/service/directions/directions.md) + - [Distance Matrix](/doc/service/distance_matrix/distance_matrix.md) + - [Geocoder](/doc/service/geocoder/geocoder.md) + - [Business Account](/doc/service/business_account.md) ## Testing -The library is fully unit tested by [PHPUnit](http://www.phpunit.de/) with a code coverage close to **100%**. To execute -the test suite, check the travis [configuration](https://github.com/egeloen/ivory-google-map/blob/master/.travis.yml). +The bundle is fully unit tested by [PHPUnit](http://www.phpunit.de/) with a code coverage close to **100%**. To +execute the test suite, check the travis [configuration](/.travis.yml). -## Contribution +## Contribute -We love contributors! Ivory is an open source project. If you'd like to contribute, feel free to propose a PR! +We love contributors! Ivory is an open source project. If you'd like to contribute, feel free to propose a PR!. ## License The Ivory Google Map is under the MIT license. For the full copyright and license information, please read the -[LICENSE](https://github.com/egeloen/ivory-google-map/blob/master/LICENSE) file that was distributed with this source -code. +[LICENSE](/LICENSE) file that was distributed with this source code. diff --git a/UPGRADE.md b/UPGRADE-1.0.md similarity index 99% rename from UPGRADE.md rename to UPGRADE-1.0.md index 656932f5..cbe83084 100644 --- a/UPGRADE.md +++ b/UPGRADE-1.0.md @@ -1,4 +1,4 @@ -# UPGRADE +# UPGRADE 1.0 ### 1.3 to 1.4 diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md new file mode 100644 index 00000000..7fdb6194 --- /dev/null +++ b/UPGRADE-2.0.md @@ -0,0 +1,6 @@ +# UPGRADE 2.0 + +### 1.x to 2.x + +The library has mostly been rewrite, so please consider re-reading the documentation for the potential BC breaks in +your code. diff --git a/composer.json b/composer.json index c8181ac8..8fa8d738 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "egeloen/google-map", - "description": "Google Map API v3 integration for PHP 5.3+", - "keywords": [ "google map" ], + "description": "Google Map API v3 integration for PHP 5.6+", + "keywords": [ "google", "map" ], "license": "MIT", "authors": [ { @@ -10,28 +10,42 @@ } ], "require": { - "php": ">=5.3.0", - "egeloen/json-builder": "~1.0.0" + "php": "^5.6|^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.0", - "widop/http-adapter": "~1.1.0", - "willdurand/geocoder": "~2.0", - "satooshi/php-coveralls": "~0.6" + "egeloen/json-builder": "^2.0", + "friendsofphp/php-cs-fixer": "^1.11", + "php-http/cache-plugin": "dev-respect-headers", + "php-http/guzzle6-adapter": "^1.1", + "php-http/message": "^1.3", + "phpunit/phpunit": "^5.0", + "phpunit/phpunit-selenium": "^3.0", + "symfony/cache": "^3.0", + "symfony/event-dispatcher": "^2.0|^3.0", + "willdurand/geocoder": "^3.0" }, "suggest": { - "widop/http-adapter": "Allows to use services", - "willdurand/geocoder": "Allows to use geocoding service" + "egeloen/json-builder": "Allows to use map service", + "php-http/client-implementation": "Allows to use http services", + "php-http/message": "Allows to use http services", + "symfony/event-dispatcher": "Allow to use map service", + "willdurand/geocoder": "Allows to use geocoder service" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/egeloen/cache-plugin.git" + } + ], "autoload": { "psr-4": { "Ivory\\GoogleMap\\": "src/" } }, - "config": { - "bin-dir": "bin/" + "autoload-dev": { + "psr-4": { "Ivory\\Tests\\GoogleMap\\": "tests/" } }, "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } } } diff --git a/doc/control/index.md b/doc/control/index.md new file mode 100644 index 00000000..65b476b5 --- /dev/null +++ b/doc/control/index.md @@ -0,0 +1,11 @@ +# Controls + +The maps on Google Maps contain UI elements for allowing user interaction through the map. These elements are known as +controls and you can include variations of these controls in your Google Maps API application. Alternatively, you can +do nothing and let the Google Maps API handle all control behavior. + + - [Map Type](/doc/control/map_type.md) + - [Rotate](/doc/control/rotate.md) + - [Scale](/doc/control/scale.md) + - [Street View](/doc/control/street_view.md) + - [Zoom](/doc/control/zoom.md) diff --git a/doc/control/map_type.md b/doc/control/map_type.md new file mode 100644 index 00000000..1baaa4d3 --- /dev/null +++ b/doc/control/map_type.md @@ -0,0 +1,69 @@ +# Map type control + +The map type control lets the user toggle between map types (such as ROADMAP and SATELLITE). This control appears by +default in the top right corner of the map. + +## Build + +First of all, if you want to render a map type control, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Control\MapTypeControl; + +$mapTypeControl = new MapTypeControl(); +``` + +The map type control constructor does not require anything but it accepts parameters such as ids (default roadmap, +satellite), position (default top right) and style (default default): + +``` php +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\MapTypeControl; +use Ivory\GoogleMap\Control\MapTypeControlStyle; +use Ivory\GoogleMap\MapTypeId; + +$mapTypeControl = new MapTypeControl( + [MapTypeId::ROADMAP, MapTypeId::SATELLITE], + ControlPosition::TOP_RIGHT, + MapTypeControlStyle::DEFAULT_ +); +``` + +## Configure ids + +If you want to update ids, you can use: + +``` php +use Ivory\GoogleMap\MapTypeId; + +$mapTypeControl->setIds([MapTypeId::ROADMAP, MapTypeId::SATELLITE]); +``` + +## Configure position + +If you want to update position, you can use: + +``` php +use Ivory\GoogleMap\Control\ControlPosition; + +$mapTypeControl->setPosition(ControlPosition::TOP_RIGHT); +``` + +## Configure style + +If you want to update the style, you can use: + +``` php +use Ivory\GoogleMap\Control\MapTypeControlStyle; + +$mapTypeControl->setStyle(MapTypeControlStyle::DEFAULT_); +``` + + +## Append to a map + +After building your map type control, you need to add it to a map with: + +``` php +$map->getControlManager()->setMapTypeControl($mapTypeControl); +``` diff --git a/doc/control/rotate.md b/doc/control/rotate.md new file mode 100644 index 00000000..0c0ac8e9 --- /dev/null +++ b/doc/control/rotate.md @@ -0,0 +1,41 @@ +# Rotate control + +The Rotate control contains a small circular icon which allows you to rotate maps containing oblique imagery. This +control appears by default in the top left corner of the map. + +## Build + +First of all, if you want to render a rotate control, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Control\RotateControl; + +$rotateControl = new RotateControl(); +``` + +The rotate control constructor does not require anything but it accepts parameters such as position (default top left): + +``` php +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\RotateControl; + +$rotateControl = new RotateControl(ControlPosition::TOP_LEFT); +``` + +## Configure position + +If you want to update the rotate control position, you can use: + +``` php +use Ivory\GoogleMap\Control\ControlPosition; + +$rotateControl->setPosition(ControlPosition::TOP_RIGHT); +``` + +## Append to a map + +After building your rotate control, you need to add it to a map with: + +``` php +$map->getControlManager()->setRotateControl($rotateControl); +``` diff --git a/doc/control/scale.md b/doc/control/scale.md new file mode 100644 index 00000000..b57e9936 --- /dev/null +++ b/doc/control/scale.md @@ -0,0 +1,55 @@ +# Scale control + +The Scale control displays a map scale element. This control is not enabled by default. + +## Build + +First of all, if you want to render a scale control, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Control\ScaleControl; + +$scaleControl = new ScaleControl(); +``` + +The scale control constructor does not require anything but it accepts parameters such as position (default bottom +left) and style (default default): + +``` php +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\ScaleControl; +use Ivory\GoogleMap\Control\ScaleControlStyle; + +$scaleControl = new ScaleControl( + ControlPosition::BOTTOM_LEFT, + ScaleControlStyle::DEFAULT_ +); +``` + +## Configure position + +If you want to update the scale control position, you can use: + +``` php +use Ivory\GoogleMap\Control\ControlPosition; + +$scaleControl->setPosition(ControlPosition::BOTTOM_RIGHT); +``` + +## Configure style + +If you want to update the scale control style, you can use: + +``` php +use Ivory\GoogleMap\Control\ScaleControlStyle; + +$scaleControl->setStyle(ScaleControlStyle::DEFAULT_); +``` + +## Append to a map + +After building your scale control, you need to add it to a map with: + +``` php +$map->getControlManager()->setScaleControl($scaleControl); +``` diff --git a/doc/control/street_view.md b/doc/control/street_view.md new file mode 100644 index 00000000..5cdd6dda --- /dev/null +++ b/doc/control/street_view.md @@ -0,0 +1,40 @@ +# Street view control + +The Street View control contains a Pegman icon which can be dragged onto the map to enable Street View. This control +appears by default in the top left corner of the map. + +## Build + +First of all, if you want to render a street view control, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Control\StreetViewControl; + +$streetViewControl = new StreetViewControl(); +``` + +The street view control constructor does not require anything but it accepts parameters such as position (default top +left): + +``` php +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\StreetViewControl; + +$streetViewControl = new StreetViewControl(ControlPosition::TOP_LEFT); +``` + +## Configure position + +If you want to update the street view control position, you can use: + +``` php +use Ivory\GoogleMap\Control\ControlPosition; + +$streetViewControl->setPosition(ControlPosition::TOP_RIGHT); +``` + +## Append to a map + +``` php +$map->getControlManager()->setStreetViewControl($streetViewControl); +``` diff --git a/doc/control/zoom.md b/doc/control/zoom.md new file mode 100644 index 00000000..31925292 --- /dev/null +++ b/doc/control/zoom.md @@ -0,0 +1,53 @@ +# Zoom control + +The Zoom control displays a slider (for large maps) or small "+/-" buttons (for small maps) to control the zoom level +of the map. This control appears by default in the top left corner of the map on non-touch devices or in the bottom +left corner on touch devices. + +## Build + +First of all, if you want to render a zoom control, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Control\ZoomControl; + +$zoomControl = new ZoomControl(); +``` + +The zoom control constructor does not require anything but it accepts parameters such as position (default top left) +and style (default default): + +``` php +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\ZoomControl; +use Ivory\GoogleMap\Control\ZoomControlStyle; + +$zoomControl = new ZoomControl( + ControlPosition::TOP_LEFT, + ZoomControlStyle::DEFAULT_ +); +``` + +## Configure position + +If you want to update th zoom control position, you can use: + +``` php +$zoomControl->setControlPosition(ControlPosition::TOP_LEFT); +``` + +## Configure style + +If you want to update the zoom control style, you can use: + +``` php +$zoomControl->setZoomControlStyle(ZoomControlStyle::DEFAULT_); +``` + +## Append to a map + +After building your zoom control, you need to add it to a map with: + +``` php +$map->getControlManager()->setZoomControl($zoomControl); +``` diff --git a/doc/event.md b/doc/event.md new file mode 100644 index 00000000..ea7f108e --- /dev/null +++ b/doc/event.md @@ -0,0 +1,88 @@ +# Events + +JavaScript within the browser is event driven, meaning that JavaScript responds to interactions by generating events, +and expects a program to listen to interesting events. The event model for the Google Maps API V3 is similar to that +used in V2 of the API, though much has changed under the hood. There are two types of events: + + - User events (such as "click" mouse events) are propagated from the DOM to the Google Maps API. These events are + separate and distinct from standard DOM events. + - MVC state change notifications reflect changes in Maps API objects and are named using a property_changed convention. + +## Build + +First of all, if you want to render a event, you will need to build one. Here, we create an event handling a marker +click. So, let's go: + +``` php +use Ivory\GoogleMap\Event\Event; + +$event = new Event( + $marker->getVariable(), + 'click', + 'function(){alert("Marker clicked!");}' +); +``` + +The event constructor requires an instance as first argument, an event name as second argument and the handle as +third argument. It also accepts additional parameters such as capture (default false): + +``` php +use Ivory\GoogleMap\Event\Event; + +$event = new Event( + $marker->getVariable(), + 'click', + 'function(){alert("Marker clicked!");}', + true +); +``` + +## Configure instance + +If you want to configure the event instance, you can use: + +``` php +$event->setInstance($instance); +``` + +## Configure event name + +If you want to configure the event name, you can use: + +``` php +$event->setEventName($eventName); +``` + +## Configure handle + +If you want to configure the event handle, you can use: + +``` php +$event->setHandle($handle); +``` + +## Configure capture + +If you want to configure the event capture, you can use: + +``` php +$event->setCapture(true); +``` + +Be aware the capture flag is only used with a DOM event. + +## Append to a map + +As explained in the overview, there are two types of event: DOM & MVC. For each of these types, you can register the +event as "regular" event meaning it will fired each time the event is trigger or you can register it "once" meaning +after the first execution, it is removed. + +``` php +// DOM +$map->getEventManager()->addDomEvent($event); +$map->getEventManager()->addDomEventOnce($event); + +// MVC +$map->getEventManager()->addEvent($event); +$map->getEventManager()->addEventOnce($event); +``` diff --git a/doc/helper/api.md b/doc/helper/api.md new file mode 100644 index 00000000..74240f1e --- /dev/null +++ b/doc/helper/api.md @@ -0,0 +1,54 @@ +# API Rendering + +The API rendering only allows you to render the Google API loader and trigger the previously defined maps or place +autocompletes. So, **the API rendering must always be done after all objects (maps and place autocompletes) have been +rendered.** This rendering is basically what starts and triggers the rendering of all objects. + +## Build + +First of all, if you want to render the API, you will need to build an API helper. So, let's go: + +``` php +use Ivory\GoogleMap\Helper\Builder\ApiHelperBuilder; + +$apiHelper = ApiHelperBuilder::create()->build(); +``` + +The api helper is built via a builder. The builder allows you to configure the helper json builder, formatter and +subscribers. The json builder allows to build advanced JSON, the formatter allows to format the generated code and the +subscribers allow you to attach additional code to the API. + +``` php +use Ivory\GoogleMap\Helper\Builder\ApiHelperBuilder; + +$apiHelperBuilder = ApiHelperBuilder::create(); + +$apiHelperBuilder->getFormatter()->setDebug(true); +$apiHelperBuilder->getFormatter()->setIndentationStep(4); +$apiHelperBuilder->getFormatter()->setDefaultIndentation(0); + +$apiHelperBuilder->addSubscriber(/* ... */); + +$apiHelper = $apiHelperBuilder->build(); +``` + +Here, I configure the formatter in debug mode (meaning that the code will be nicely formatted) with an indentation of +four spaces and a default/initial indentation of zero. I additionally attach a custom subscriber which will allow to +hook into the code generation. + +## Render + +For rendering the API, you need javascript code. To render it, you can use: + +``` +echo $apiHelper->render([$object1, $object2]); +``` + +Here, `$object1` and `$object2` can refer to maps or place autocompletes. The, this method renders an html javascript +block with all code needed for loading the API. + +``` html + +``` diff --git a/doc/helper/index.md b/doc/helper/index.md new file mode 100644 index 00000000..219d9d00 --- /dev/null +++ b/doc/helper/index.md @@ -0,0 +1,77 @@ +# Rendering (Helper) + +Rendering maps or place autocompletes is very simple but need to be well understood. When you render something, it is +always in two steps. In the first step, we render maps and place autocompletes javascript code. Each rendering is +automatically wrapped into a unique named functions meaning maps and place autocompletes have not been instantiated at +this state (only defined). Then, at the second step, we render the API javascript code which loads the Google API and +automatically calls all map and place autocomplete functions previously defined (only when the required libraries +have been loaded). + +**The API rendering must always be done after all objects (maps and place autocompletes) have been rendered.** + +If you want to learn more about each rendering, you can read the following: + + - [Map Rendering](/doc/helper/map.md) + - [Place Autocomplete Rendering](/doc/helper/place_autocomplete.md) + - [API Rendering](/doc/helper/api.md) + +## Render Map + +Here, an example rendering a map: + +``` php +use Ivory\GoogleMap\Helper\Builder\ApiHelperBuilder; +use Ivory\GoogleMap\Helper\Builder\MapHelperBuilder; +use Ivory\GoogleMap\Map; + +$map = new Map(); + +$mapHelper = MapHelperBuilder::create()->build(); +$apiHelper = ApiHelperBuilder::create()->build(); + +echo $mapHelper->render($map); +echo $apiHelper->render([$map]); +``` + +## Render Place Autocomplete + +Here, an example rendering a place autocomplete: + +``` php +use Ivory\GoogleMap\Helper\Builder\ApiHelperBuilder; +use Ivory\GoogleMap\Helper\Builder\PlaceAutocompleteHelperBuilder; +use Ivory\GoogleMap\Place\Autocomplete; + +$autocomplete = new Autocomplete(); + +$autocompleteHelper = PlaceAutocompleteHelperBuilder::create()->build(); +$apiHelper = ApiHelperBuilder::create()->build(); + +echo $autocompleteHelper->render($autocomplete); +echo $apiHelper->render([$autocomplete]); +``` + +## Render Multiple Objects + +Here, an example rendering multiple maps and place autocompletes: + +``` php +use Ivory\GoogleMap\Helper\Builder\ApiHelperBuilder; +use Ivory\GoogleMap\Helper\Builder\MapHelperBuilder; +use Ivory\GoogleMap\Helper\Builder\PlaceAutocompleteHelperBuilder; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Place\Autocomplete; + +$autocomplete = new Autocomplete(); +$mapHeader = new Map(); +$mapFooter = new Map(); + +$autocompleteHelper = PlaceAutocompleteHelperBuilder::create()->build(); +$mapHelper = MapHelperBuilder::create()->build(); +$apiHelper = ApiHelperBuilder::create()->build(); + +echo $mapHelper->render($mapHeader); +echo $autocompleteHelper->render($autocomplete); +echo $mapHelper->render($mapFooter); +echo $apiHelper->render([$autocomplete, $mapHeader, $mapFooter]); +``` diff --git a/doc/helper/map.md b/doc/helper/map.md new file mode 100644 index 00000000..8ee7b96f --- /dev/null +++ b/doc/helper/map.md @@ -0,0 +1,171 @@ +# Map Rendering + +The map rendering only allows you to render a map. The javascript map code will be wrapped into a unique named function. + +## Build + +First of all, if you want to render a map, you will need to build a map helper. So, let's go: + +``` php +use Ivory\GoogleMap\Helper\Builder\MapHelperBuilder; + +$mapHelper = MapHelperBuilder::create()->build(); +``` + +The map helper is built via a builder. The builder allows you to configure the helper json builder, formatter and +subscribers. The json builder allows to build advanced JSON, the formatter allows to format the generated code and the +subscribers allow you to attach additional code to the map. + +``` php +use Ivory\GoogleMap\Helper\Builder\MapHelperBuilder; + +$mapHelperBuilder = MapHelperBuilder::create(); + +$mapHelperBuilder->getFormatter()->setDebug(true); +$mapHelperBuilder->getFormatter()->setIndentationStep(4); +$mapHelperBuilder->getFormatter()->setDefaultIndentation(0); + +$mapHelperBuilder->addSubscriber(/* ... */); + +$mapHelper = $mapHelperBuilder->build(); +``` + +Here, I configure the formatter in debug mode (meaning that the code will be nicely formatted) with an indentation of +four spaces and a default/initial indentation of zero. I additionally attach a custom subscriber which will allow to +hook into the code generation. + +## Render html container + +For rendering a map, you need an html container. To render it, you can use: + +``` +echo $mapHelper->renderHtml($map); +``` + +This method renders an html div block with the html id, the width and the height configured: + +``` html +
+``` + +## Render javascript + +For rendering a map, you need javascript code. To render it, you can use: + +``` +echo $mapHelper->renderJavascript($map); +``` + +This method renders an html javascript block with all code needed for displaying your map. + +``` html + +``` + +### Use objects on client side + +Being able to reuse objects on the client side is a must have. Hopefully, the library supports it natively. Basically, +all objects implementing the `VariableAwareInterface` have a javascript variable. When rendering you code, the helper +will attach the object to its variable. Given you have a marker which uses `my_marker` as variable, then the generated +code is: + +``` js +my_marker = new google.maps.Marker({ /* ... */ }); +``` + +Then, you can access the marker everywhere in your code by relying on `my_marker`: + +``` js +var position = my_marker.getPosition(); +``` + +The helper also organizes all objects under a container. That allows you to easily retrieve everything linked to a +specific map. Given you have a map which uses `my_map` as variable. Then, the generated container is: + +``` json +my_map_container = { + "base": { + "coordinates": [], + "bounds": [], + "points: [], + "sizes": [] + }, + "map": null, + "overlays": { + "circles": [], + "encoded_polylines": [], + "ground_overlays": [], + "polygons": [], + "polylines": [], + "rectangles": [], + "info_windows": [], + "markers": [], + "marker_cluster": null, + }, + "layers": { + "kml_layers": [] + }, + "events": { + "dom_events": [], + "dom_events_once": [], + "events": [], + "events_once": [] + }, + "functions": { + "info_windows_close": function { /* ... */}, + "to_array": function { /* ... */ } + } +} +``` + +With the container, you can easily iterate over any collections int the map. For example, iterating over makers is as +simple as: + +``` js +for (var marker in my_map.overlays.markers) { + // ... +} +``` + +## Render stylesheet + +A map can have optional stylesheet. If you want to render it, you can use: + +``` +echo $mapHelper->renderStylesheet($map); +``` + +This methods renders an html style block with the CSS configured: + +``` html + +``` + +## Render all + +If you want to render everything (stylesheet + html container + javascript), you can use: + +``` +echo $mapHelper->render($map); +``` + +This methods renders all: + +``` html + +
+ +``` + +## What Next? + +Since the map rendering is the first step in the rendering process, you should be interested into rendering the +[API](/doc/helper/api.doc). diff --git a/doc/helper/place_autocomplete.md b/doc/helper/place_autocomplete.md new file mode 100644 index 00000000..05fc329e --- /dev/null +++ b/doc/helper/place_autocomplete.md @@ -0,0 +1,125 @@ +# Place Autocomplete Rendering + +The place autocomplete rendering only allows you to render a place autocomplete. The javascript place autocomplete +code will be wrapped into a unique named function. + +## Build + +First of all, if you want to render a place autocomplete, you will need to build a place autocomplete helper. So, let's +go: + +``` php +use Ivory\GoogleMap\Helper\Builder\PlaceAutocompleteHelperBuilder; + +$placeAutocompleteHelper = PlaceAutocompleteHelperBuilder::create()->build(); +``` + +The place autocomplete helper is built via a builder. The builder allows you to configure the helper json builder, +formatter and subscribers. The json builder allows to build advanced JSON, the formatter allows to format the generated +code and the subscribers allow you to attach additional code to the place autocomplete. + +``` php +use Ivory\GoogleMap\Helper\Builder\PlaceAutocompleteHelperBuilder; + +$placeAutocompleteHelperBuilder = PlaceAutocompleteHelperBuilder::create(); + +$placeAutocompleteHelperBuilder->getFormatter()->setDebug(true); +$placeAutocompleteHelperBuilder->getFormatter()->setIndentationStep(4); +$placeAutocompleteHelperBuilder->getFormatter()->setDefaultIndentation(0); + +$placeAutocompleteHelperBuilder->addSubscriber(/* ... */); + +$placeAutocompleteHelper = $placeAutocompleteHelperBuilder->build(); +``` + +Here, I configure the formatter in debug mode (meaning that the code will be nicely formatted) with an indentation of +four spaces and a default/initial indentation of zero. I additionally attach a custom subscriber which will allow to +hook into the code generation. + +## Render html input + +``` +echo $placeAutocompleteHelper->renderHtml($autocomplete); +``` + +This methods renders an html input with the input id, the value and input attributes configured: + +``` html + +``` + +## Render javascript + +``` +echo $placeAutocompleteHelper->renderJavascript($autocomplete); +``` + +This methods renders an html javascript block with all code needed for displaying your autocomplete. + +``` html + +``` + +### Use objects on client side + +Being able to reuse objects on the client side is a must have. Hopefully, the library supports it natively. Basically, +all objects implementing the `VariableAwareInterface` have a javascript variable. When rendering you code, the helper +will attach the object to its variable. Given you have a place autocomplete which uses `my_autocomplete` as variable, +then the generated code is: + +``` js +my_autocomplete = new google.maps.places.Autocomplete({ /* ... */ }); +``` + +Then, you can access the autocomplete everywhere in your code by relying on `my_autocomplete`: + +``` js +var place = my_autocomplete.getPlace(); +``` + +The helper also organizes all objects under a container. That allows you to easily retrieve everything linked to a +specific place autocomplete. Given you have a place autocomplete which uses `my_autocomplete` as variable. Then, the +generated container is: + +``` json +my_autocomplete_container = { + "base": { + "coordinates": [], + "bounds": [] + }, + "autocomplete": null +} +``` + +With the container, you can easily iterate over any collections int the map. For example, iterating over makers is as +simple as: + +``` js +for (var coordinate in my_autocomplete.base.coordinates) { + // ... +} +``` + +## Render all + +If you want to render everything (html input + javascript), you can use: + +``` +echo $placeAutocompleteHelper->render($autocomplete); +``` + +This methods renders all: + +``` html + + +``` + +## What Next? + +Since the place autocomplete rendering is the first step in the rendering process, you should be interested into +rendering the [API](/doc/helper/api.doc). diff --git a/doc/installation.md b/doc/installation.md index 028a0fab..48054d76 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -1,65 +1,53 @@ # Installation -To install the Ivory Google Map library, you will need [Composer](http://getcomposer.org). It's a PHP 5.3+ dependency -manager which allows you to declare the dependent libraries your project needs and it will install & autoload them for +To install the Ivory Google Map library, you will need [Composer](http://getcomposer.org). It's a PHP 5.3+ dependency +manager which allows you to declare the dependent libraries your project needs and it will install & autoload them for you. ## Set up Composer Composer comes with a simple phar file. To easily access it from anywhere on your system, you can execute: -``` +``` bash $ curl -s https://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer ``` -## Define dependencies - -### Mandatories dependencies +## Download the library -Create a ``composer.json`` file at the root directory of your project and simply require the -``egeloen/google-map`` package: +Require the library in your `composer.json` file: -``` -{ - "require": { - "egeloen/google-map": "dev-master" - } -} +``` bash +$ composer require egeloen/google-map ``` -### Optional dependencies +## Download additional libraries -If you want to use Geocoding stuff, you will need [Geocoder](http://github.com/willdurand/Geocoder): +If you want to render maps or place autocompletes , you will need the `egeloen/json-builder` and +`symfony/event-dispatcher` packages: -``` -{ - "require": { - "willdurand/geocoder": "*" - } -} +``` bash +$ composer require egeloen/json-builder +$ composer require symfony/event-dispatcher ``` -If you want to use Directions or Distance Matrix stuff, you will need an -[http adapter](http://github.com/widop/http-adapter): +If you want to use the Geocoder service, you will need [Geocoder](http://github.com/willdurand/Geocoder): +``` bash +$ composer require willdurand/geocoder ``` -{ - "require": { - "widop/http-adapter": "1.0.*" - } -} -``` - -## Install dependencies -Now, you have define your dependencies, you can install them: +If you want to use the [Directions](/doc/service/geocoder/directions.md), +[Distance Matrix](/doc/service/geocoder/distance-matrix.md) or +[Geocoder](/doc/service/geocoder/geocoder.md) services, you will need an http client and message factory via +[Httplug](http://httplug.io/) which is an http client abstraction library: -``` -$ composer install +``` bash +$ composer require php-http/guzzle6-adapter ``` -Composer will automatically download your dependencies & create an autoload file in the ``vendor`` directory. +Here, I have chosen to use [Guzzle6](http://docs.guzzlephp.org/en/latest/psr7.html) but since Httplug supports the +most popular http clients, you can install your preferred one instead. ## Autoload @@ -75,5 +63,5 @@ use Ivory\GoogleMap; // ... ``` -The Ivory Google Map library follows the [PSR-4 Standard](http://www.php-fig.org/psr/psr-4/). If you prefer install it -manually, it can be autoload by any convenient autoloader. +The Ivory Google Map library follows the [PSR-4 Standard](http://www.php-fig.org/psr/psr-4/). +If you prefer install it manually, it can be autoload by any convenient autoloader. diff --git a/doc/layer/index.md b/doc/layer/index.md new file mode 100644 index 00000000..362cb99e --- /dev/null +++ b/doc/layer/index.md @@ -0,0 +1,8 @@ +# Layers + +Layers are objects on the map that consist of one or more separate items, but are manipulated as a single unit. Layers +generally reflect collections of objects that you add on top of the map to designate a common association. . Layers may +also alter the presentation layer of the map itself, slightly altering the base tiles in a fashion consistent with the +layer. + + - [Kml Layer](/doc/layer/kml_layer.md) diff --git a/doc/layer/kml_layer.md b/doc/layer/kml_layer.md new file mode 100644 index 00000000..923f3a10 --- /dev/null +++ b/doc/layer/kml_layer.md @@ -0,0 +1,52 @@ +# KML Layer + +The Google Maps API supports the KML and GeoRSS data formats for displaying geographic information. For more +information, read the official [documentation](http://code.google.com/apis/maps/documentation/javascript/layer.html#KMLLayers). + +## Build + +First of all, if you want to render a kml layer, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Layer\KmlLayer; + +$kmlLayer = new KmlLayer('http://www.domain.com/kml_layer.kml'); +``` + +The kml layer constructor requires an url as first argument. It also accepts additional parameters such as options +(default empty): + +``` php +use Ivory\GoogleMap\Layer\KmlLayer; + +$kmlLayer = new KmlLayer( + 'http://www.domain.com/kml_layer.kml', + ['suppressInfoWindows' => true] +); +``` + +## Configure url + +If you want to update the kml layer url, you can use: + +``` php +$kmlLayer->setUrl('http://www.domain.com/kml_layer.kml'); +``` + +## Configure options + +The kml layer options allows you to configure additional kml layer aspects. See the list of available options in the +official [documentation](https://developers.google.com/maps/documentation/javascript/reference#KmlLayerOptions). Then, +to configure them, you can use: + +``` php +$kmlLayer->setOption('suppressInfoWindows', true); +``` + +## Append to a map + +After building your kml layer, you need to add it to a map with: + +``` php +$map->getLayerManager()->addKmlLayer($kmlLayer); +``` diff --git a/doc/map.md b/doc/map.md new file mode 100644 index 00000000..d324e4ff --- /dev/null +++ b/doc/map.md @@ -0,0 +1,135 @@ +# Map + +## Build + +First of all, if you want to render a map, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Map; + +$map = new Map(); +``` + +## Configure variable + +A variable is automatically generated when creating a map but if you want to update it, you can use: + +``` php +$map->setVariable('map'); +``` + +## Configure html id + +If you want to update the default html id (map_canvas) used for the map div container, you can use: + +``` php +$map->setHtmlId('map_canvas'); +``` + +## Configure center & zoom + +For configuring the map center & zoom, you have three possibilities: + + 1. Standard center coordinate & zoom + 2. Fitting a bound + 3. Fitting a bound which extends overlays + +### Standard center coordinate & zoom + +To use the standard center coordinate & zoom, you need to disable the auto zoom flag (disabled by default) & configure +the center/zoom. + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; + +$map = new Map(); + +// Disable the auto zoom flag (disabled by default) +$map->setAutoZoom(false); + +// Sets the center +$map->setCenter(new Coordinate(0, 0)); + +// Sets the zoom +$map->setMapOption('zoom', 3); +``` + +### Fitting a bound + +For fitting a bound, you need to enable the auto zoom flag & configure bound south west & north east coordinates. +If you extend overlays with the bound, the map will fit the overlays coordinate instead of the bound coordinates. + +``` php +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; + +$map = new Map(); + +// Enable the auto zoom flag (disabled by default) +$map->setAutoZoom(true); + +// Sets the bound coordinates +$map->setBound(new Bound(new Coordinate(-2.1, -3.9), new Coordinate(2.6, 1.4)); +``` + +### Fitting a bound which extends overlays + +For fitting a bound which extends overlays, you need to enable the auto zoom flag & add overlays to the bound. +In the [Overlays documentation](/doc/overlay/index.md), you learn how you can add overlays to the map. If the +auto zoom flag is enabled and you add some overlays to the map, the map bound will automatically extends the added +overlay. So, at the end, all your overlays will be visible on your screen. + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Marker; + +$map = new Map(); + +// Enable the auto zoom flag (disabled by default) +$map->setAutoZoom(true); + +// Add a marker to your map +$map->getOverlayManager()->addMarker(new Marker(new Coordinate())); +``` + +That's it. The map will be automatically centered on your marker. + +## Configure libraries + +Sometimes, you want to use the map & other Google Map related libraries. The library provides many integrations but not +all of them. If you need a custom library (for example `drawing`), you can use: + +``` +$map->addLibrary('drawing'); +``` + +## Configure language + +If you want to use your own language when displaying your map, you can use: + +``` +$map->setLanguage('fr'); +``` + +## Configure options + +The map options allows you to configure additional map aspects. See the list of available options in the Google Map +[documentation](https://developers.google.com/maps/documentation/javascript/reference#MapOptions). Then, to configure +them, you can use: + +``` php +use Ivory\GoogleMap\MapTypeId; + +$map->setMapOption('mapTypeId', MapTypeId::HYBRID); +``` + +## Configure stylesheets + +If you want to configure map stylesheets, you can use: + +``` php +$map->setStylesheet('position', 'absolute'); +``` diff --git a/doc/overlay/circle.md b/doc/overlay/circle.md new file mode 100644 index 00000000..62d08aac --- /dev/null +++ b/doc/overlay/circle.md @@ -0,0 +1,71 @@ +# Circle + +A Circle is similar to a Polygon in that you can define custom colors, weights, and opacities for the edge of the +circle (the "stroke") and custom colors and opacities for the area within the enclosed region (the "fill"). Unlike a +Polygon, you do not define paths for a Circle. Instead, a circle has two additional properties which define its shape: +center of the circle, radius of the circle, in meters. + +## Build + +First of all, if you want to render a circle, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Circle; + +$circle = new Circle(new Coordinate()); +``` + +The circle constructor requires a coordinate as first argument which represents the center of the circle. It also +accepts additional parameters such as radius (default 1.0) and options (default empty): + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Circle; + +$circle = new Circle(new Coordinate(), 10, ['clickable' => false]); +``` + +## Configure variable + +A variable is automatically generated when creating a circle but if you want to update it, you can use: + +``` php +$circle->setVariable('circle'); +``` + +## Configure center + +If you want to update the center, you can use: + +``` php +use Ivory\GoogleMap\Base\Coordinate; + +$circle->setCenter(new Coordinate(1, 1)); +``` + +## Configure radius + +If you want to update the radius, you can use: + +``` php +$circle->setRadius(10); +``` + +## Configure options + +The circle options allows you to configure additional circle aspects. See the list of available options in the official +[documentation](https://developers.google.com/maps/documentation/javascript/reference#CircleOptions). Then, to +configure them, you can use: + +``` php +$circle->setOption('clickable', false); +``` + +## Append to a map + +After building your circle, you need to add it to a map with: + +``` php +$map->getOverlayManager()->addCircle($circle); +``` diff --git a/doc/overlay/encoded_polyline.md b/doc/overlay/encoded_polyline.md new file mode 100644 index 00000000..3887bd65 --- /dev/null +++ b/doc/overlay/encoded_polyline.md @@ -0,0 +1,57 @@ +# Encoded Polyline + +The Encoded Polyline class defines a [Polyline](/doc/overlay/polyline.md) which has been encoded using the +algorithm described [here](http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html). + +## Build + +First of all, if you want to render an encoded polyline, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Overlay\EncodedPolyline; + +$encodedPolyline = new EncodedPolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@'); +``` + +The circle constructor requires a encoded value as first argument. It also accepts additional parameters such as +options (default empty): + +``` php +use Ivory\GoogleMap\Overlay\EncodedPolyline; + +$encodedPolyline = new EncodedPolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@', ['geodesic' => true]); +``` + +## Configure variable + +A variable is automatically generated when creating an encoded polyline but if you want to update it, you can use: + +``` php +$encodedPolyline->setVariable('encoded_polyline'); +``` + +## Configure value + +If you want to update the encoded polyline value, you can use: + +``` php +$encodedPolyline->setValue('encoded_polyline_value'); +``` + +## Configure options + +The encoded polyline options allows you to configure additional circle aspects. See the list of available options in +the official [documentation](https://developers.google.com/maps/documentation/javascript/reference#PolylineOptions). +Then, to configure them, you can use: + +``` php +$polyline->setOption('geodesic', true); +``` + +## Append to a map + +After building your encoded polyline, you need to add it to a map with: + +``` php +$map->getOverlayManager()->addEncodedPolyline($encodedPolyline); +``` diff --git a/doc/overlay/ground_overlay.md b/doc/overlay/ground_overlay.md new file mode 100644 index 00000000..b22dd4cb --- /dev/null +++ b/doc/overlay/ground_overlay.md @@ -0,0 +1,72 @@ +# Ground Overlay + +Polygons are useful overlays to represent arbitrarily-sized areas, but they cannot display images. If you have an image +that you wish to place on a map, you can use a GroundOverlay object. + +## Build + +First of all, if you want to render a ground overlay, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Overlay\GroundOverlay; + +$groundOverlay = new GroundOverlay( + 'https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', + new Bound(new Coordinate(40.712216, -74.22655), new Coordinate(40.773941, -74.12544)) +); +``` + +The ground overlay constructor requires an url as first argument and a bound as second argument which represents the +image area. It also accepts additional parameters such as options (default empty): + +``` php +use Ivory\GoogleMap\Overlay\GroundOverlay; + +$groundOverlay = new GroundOverlay( + 'https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', + new Bound(new Coordinate(40.712216, -74.22655), new Coordinate(40.773941, -74.12544)), + ['clickable' => false] +); +``` + +## Configure variable + +A variable is automatically generated when creating a ground overlay but if you want to update it, you can use: + +``` php +$groundOverlay->setVariable('ground_overlay'); +``` + +## Configure url + +If you want to update the ground overlay url, you can use: + +``` php +$groundOverlay->setUrl('url'); +``` + +## Configure bound + +If you want to update the ground overlay bound, you can use: + +``` php +$groundOverlay->setBound(-1, -1, 1, 1, true, true); +``` + +## Configure options + +The ground overlay options allows you to configure additional circle aspects. See the list of available options in the +official [documentation](https://developers.google.com/maps/documentation/javascript/reference#GroundOverlayOptions). +Then, to configure them, you can use: + +``` php +$groundOverlay->setOption('clickable', false); +``` + +## Append to a map + +After building your ground overlay, you need to add it to a map with: + +``` php +$map->getOverlayManager()->addGroundOverlay($groundOverlay); +``` diff --git a/doc/overlay/icon.md b/doc/overlay/icon.md new file mode 100644 index 00000000..1cc09a7f --- /dev/null +++ b/doc/overlay/icon.md @@ -0,0 +1,80 @@ +# Icon + +Markers may define an icon to show in place of the default icon. Defining an icon involves setting a number of +properties that define the visual behavior of the marker. + +## Build + +First of all, if you want to render an icon, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Overlay\Icon; + +$icon = new Icon(); +``` + +The icon constructor does not require anything but It accepts parameters such as the url +(default https://maps.gstatic.com/mapfiles/markers/marker.png), anchor (default null), origin (default null), +scaled size (default null) and size (default null): + +``` php +use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Overlay\Icon; + +$icon = new Icon( + 'https://maps.gstatic.com/mapfiles/markers/marker.png', + new Point(20, 34), + new Point(0, 0), + new Size(20, 34), + new Size(40, 68) +); +``` + +## Configure url + +If you want to update thr url, you can use: + +``` php +$icon->setUrl('https://maps.gstatic.com/mapfiles/markers/marker.png'); +``` + +## Configure anchor + +If you want to update the anchor, you can use: + +``` php +use Ivory\GoogleMap\Base\Point; + +$icon->setAnchor(new Point(20, 34)); +``` + +## Configure origin + +If you want to update the origin, you can use: + +``` php +use Ivory\GoogleMap\Base\Point; + +$icon->setOrigin(new Point(0, 0)); +``` + +## Configure size + +If you want to update the size, you can use: + +``` php +use Ivory\GoogleMap\Base\Size; + +$icon->setSize(new Size(20, 34)); +``` + +## Configure scaled size + +If you want to update the scaled size, you can use: + +``` php +use Ivory\GoogleMap\Base\Size; + +$icon->setScaledSize(new Size(20, 34)); +``` diff --git a/doc/overlay/index.md b/doc/overlay/index.md new file mode 100644 index 00000000..1d84c1d2 --- /dev/null +++ b/doc/overlay/index.md @@ -0,0 +1,15 @@ +# Overlays + +Overlays are objects on the map that are tied to latitude/longitude coordinates, so they move when you drag or zoom the +map. Overlays reflect objects that you "add" to the map to designate points, lines, areas, or collections of objects. + + - [Marker](/doc/overlay/marker.md) + - [Info Window](/doc/overlay/info_window.md) + - [Info Box](/doc/overlay/info_box.md) + - [Polyline](/doc/overlay/polyline.md) + - [Encoded Polyline](/doc/overlay/encoded_polyline.md) + - [Polygon](/doc/overlay/polygon.md) + - [Rectangle](/doc/overlay/rectangle.md) + - [Circle](/doc/overlay/circle.md) + - [Ground Overlay](/doc/overlay/ground_overlay.md) + - [Marker Clusterer](/doc/overlay/marker_clusterer.md) diff --git a/doc/overlay/info_box.md b/doc/overlay/info_box.md new file mode 100644 index 00000000..56cc0ad0 --- /dev/null +++ b/doc/overlay/info_box.md @@ -0,0 +1,15 @@ +# InfoBox + +The library natively supports [InfoBox](https://github.com/kangaroo5383/google-maps-utility-library-v3/tree/master/infobox) +(a info window-like implementation). In order to render an info box instead of an info window, you just need to +specify it on the info window: + +``` php +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; + +$infoWindow = new InfoWindow('content'); +$infoWindow->setType(InfoWindowType::INFO_BOX); +``` + +Then, add it to your map and you're done! diff --git a/doc/overlay/info_window.md b/doc/overlay/info_window.md new file mode 100644 index 00000000..711b40dc --- /dev/null +++ b/doc/overlay/info_window.md @@ -0,0 +1,122 @@ +# Info window + +Info window displays content in a floating window above the map. The info window looks a little like a comic-book word +balloon. It has a content area and a tapered stem, where the tip of the stem is at a specified location on the map. + +## Build + +First of all, if you want to render an info window, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Overlay\InfoWindow; + +$infoWindow = new InfoWindow('content'); +``` + +The info window constructor requires a content as first argument. It also accepts additional parameters such as the type +(default default), position (default null): + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; + +$infoWindow = new InfoWindow('content', InfoWindowType::INFO_BOX, new Coordinate()); +``` + +## Configure variable + +A variable is automatically generated when creating an info window but if you want to update it, you can use: + +``` php +$infoWindow->setVariable('info_window'); +``` + +## Configure content + +If you want to update the info window content, you cant use: + +``` php +$infoWindow->setContent('

Default content

'); +``` + +## Configure position + +If you want to update the info window position, you can use: + +``` php +use Ivory\GoogleMap\Base\Coordinate; + +$infoWindow->setPosition(new Coordinate(0, 0)); +``` + +## Configure pixel offset + +if you want to update the pixel offset (default null), you can use: + +``` php +use Ivory\GoogleMap\Base\Size; + +$infoWindow->setPixelOffset(new Size(1.1, 2.1)); +``` + +## Configure default open state + +By default, the info window is not visible on a map because its default open state is false. That does not mean the +info window is not created, it just means it is not visible when the map is initially displayed. If you want to display +it, you can use: + +``` php +$infoWindow->setOpen(true); +``` + +## Configure auto open + +The auto open flag is useful when linking an info window to a marker. Basically, if you link an info window to a +marker, then, when triggering an event on the marker (default click), the linked info window will be automatically +opened. + +To enable this feature (disabled by default), you can use: + +``` php +$infoWindow->setAutoOpen(true); +``` + +## Configure auto open event + +The auto open event represents the event triggering the automatic info window opening. If you want to update it, you +can use: + +``` php +$infoWindow->setOpenEvent(MouseEvent::DBLCLICK); +``` + +## Configure auto close + +The auto close flag is the opposite of the auto open flag. Basically, if an auto open event is triggered, then, the +info windows configured with the auto close flag are all closed. + +To enable this feature (disabled by default), you can use: + +``` php +$infoWindow->setAutoClose(true); +``` + +## Configure options + +The info window options allows you to configure additional circle aspects. See the list of available options in the +official [documentation](https://developers.google.com/maps/documentation/javascript/reference#InfoWindowOptions). +Then, to configure them, you can use: + +``` php +$infoWindow->setOption('zIndex', 10); +``` + +## Append to a map/marker + +After building your info window, you need to add it to a map/marker with: + +``` php +$map->getOverlayManager()->addInfoWindow($infoWindow); +$marker->setInfoWindow($infoWindow); +``` diff --git a/doc/overlay/marker.md b/doc/overlay/marker.md new file mode 100644 index 00000000..1960d932 --- /dev/null +++ b/doc/overlay/marker.md @@ -0,0 +1,102 @@ +# Marker + +Markers identify locations on the map. By default, they use a standard icon. + +## Build + +First of all, if you want to render a marker, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Marker; + +$marker = new Marker(new Coordinate()); +``` + +The marker constructor requires a coordinate as first argument which represents the marker position. It also accepts +additional parameters such as the animation (default null), icon (default null), shape (default null) and +options (default empty): + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Animation; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Overlay\MarkerShapeType; + +$marker = new Marker( + new Coordinate(), + Animation::BOUNCE, + new Icon(), + new MarkerShape(MarkerShapeType::CIRCLE, [1.1, 2.1, 1.4]) + ['clickable' => false] +); +``` + +## Configure variable + +A variable is automatically generated when creating a marker but if you want to update it, you can use: + +``` php +$marker->setVariable('marker'); +``` + +## Configure position + +If you want to update the marker position, you can use: + +``` php +use Ivory\GoogleMap\Base\Coordinate; + +$marker->setPosition(new Coordinate(1, 1)); +``` + +## Configure animation + +If you want to add animation on marker, you can use: + +``` php +$marker->setAnimation(Animation::DROP); +``` + +## Configure icon + +If you want to update the marker icon, you can use: + +``` php +use Ivory\GoogleMap\Overlay\Icon; + +$marker->setIcon(new Icon()); +``` + +If you want to learn more about icon, you can read its [documentation](/doc/overlay/icon.md). + +## Configure shape + +If you want to update the marker shape, you can use: + +``` php +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Overlay\MarkerShapeType; + +$marker->setIcon(new MarkerShape(MarkerShapeType::CIRCLE, [1.1, 2.1, 1.4])); +``` + +## Configure options + +The marker options allows you to configure additional marker aspects. See the list of available options in the +official [documentation](https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions). +Then, to configure them, you can use: + +``` php +$marker->setOption('flat', true); +``` + +If you want to learn more about marker shape, you can read its [documentation](/doc/overlay/marker_shape.md). + +## Append to a map + +``` php +$map->getOverlayManager()->addMarker($marker); +``` diff --git a/doc/overlay/marker_clusterer.md b/doc/overlay/marker_clusterer.md new file mode 100644 index 00000000..3845b9ed --- /dev/null +++ b/doc/overlay/marker_clusterer.md @@ -0,0 +1,13 @@ +# Marker Clusterer + +Some applications are required to display a large number of locations or markers. Despite the v3 JavaScript API's +significant improvement to performance, naively plotting thousands of markers on a map can quickly lead to to a +degraded user experience. Too many markers on the map cause both visual overload and sluggish interaction with the map. +To overcome this poor performance, the information displayed on the map needs to be simplified, we need a marker +clustering solution. The library supports the most popular solution: [MarkerClusterer](https://github.com/googlemaps/js-marker-clusterer). + +``` php +use Ivory\GoogleMap\Overlay\MarkerClusterType; + +$map->getOverlayManager()->getMarkerCluster()->setType(MarkerClusterType::MARKER_CLUSTERER); +``` diff --git a/doc/usage/overlays/marker_shape.md b/doc/overlay/marker_shape.md similarity index 53% rename from doc/usage/overlays/marker_shape.md rename to doc/overlay/marker_shape.md index c4a382e5..f070784e 100644 --- a/doc/usage/overlays/marker_shape.md +++ b/doc/overlay/marker_shape.md @@ -1,8 +1,8 @@ -# Marker shape +# Marker Shape -This object defines the marker shape to use in determination of a marker's clickable region. -The shape consists of two properties "type" and "coordinates" which define the general type of marker and coordinates -specific to that type of marker. +This object defines the marker shape to use in determination of a marker's clickable region. The shape consists of two +properties "type" and "coordinates" which define the general type of marker and coordinates specific to that type of +marker. The format of this attribute depends on the value of the type and follows the w3 AREA coords specification found at http://www.w3.org/TR/REC-html40/struct/objects.html#adef-coords. The coordinates attribute is an array of integers that @@ -16,31 +16,29 @@ the value of type as follows: - rect: coordinates is [x1, y1, x2, y2] where x1, y1 are the coordinates of the upper-left corner of the rectangle and x2, y2 are the coordinates of the lower-right coordinates of the rectangle. -## Build your marker shape +## Build -``` php -use Ivory\GoogleMap\Overlays\MarkerShape; - -$markerShape = new MarkerShape(); +First of all, if you want to render a marker shape, you will need to build one. So let's go: -// Configure your marker shape options -$markerShape->setPrefixJavascriptVariable('marker_shape_'); -$markerShape->setType('poly'); -$markerShape->setCoordinates(array(1, 1, 1, -1, -1, -1, -1, 1)); +``` php +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Overlay\MarkerShapeType; -// If the marker shape type is "poly", you can add coordinate one by one -$markerShape->addPolyCoordinates(1, 1); +$markerShape = new MarkerShape(MarkerShapeType::CIRCLE, [1.1, 2.0, 1.4]); ``` -## Add your marker shape to the marker +## Configure type -Now you have configurated your marker shape, you need to add it to your marker. +If you want to update the type, you can use: ``` php -use Ivory\GoogleMap\Overlays\MarkerShape; +$markerShape->setType('poly'); +``` -$markerShape = new MarkerShape(); +## Configure coordinates -// Add your marker shape to the marker -$marker->setShape($markerShape); +If you want to update the coordinate, you can use: + +``` php +$markerShape->setCoordinates([1.1, 2.0, 1.4]); ``` diff --git a/doc/overlay/polygon.md b/doc/overlay/polygon.md new file mode 100644 index 00000000..21fdc43b --- /dev/null +++ b/doc/overlay/polygon.md @@ -0,0 +1,66 @@ +# Polygon + +Polygon objects are similar to polyline objects in that they consist of a series of coordinates in an ordered sequence. +However, instead of being open-ended, polygons are designed to define regions within a closed loop. + +## Build + +First of all, if you want to render a polygon, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Overlay\Polygon; + +$polygon = new Polygon(); +``` + +The polygon constructor does not require anything but It accepts additional parameters such as coordinates (default +empty) and options (default empty): + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Polygon; + +$polygon = new Polygon( + [ + new Coordinate(25.774, -80.190), + new Coordinate(18.466, -66.118), + new Coordinate(32.321, -64.757), + new Coordinate(25.774, -80.190), + ], + ['fillOpacity' => 0.5] +); +``` + +## Configure variable + +A variable is automatically generated when creating a polygon but if you want to update it, you can use: + +``` php +$polygon->setVariable('polygon'); +``` + +## Configure coordinates + +If you want to update the polygon coordinates, you can use: + +``` php +$polygon->setCoordinates([]); +``` + +## Configure options + +The polygon options allows you to configure additional polygon aspects. See the list of available options in the +official [documentation](https://developers.google.com/maps/documentation/javascript/reference#PolygonOptions). Then, +to configure them, you can use: + +``` php +$polygon->setOption('fillOpacity', 0.5); +``` + +## Append to a map + +After building your polygon, you need to add it to a map with: + +``` php +$map->getOverlayManager()->addPolygon($polygon); +``` diff --git a/doc/overlay/polyline.md b/doc/overlay/polyline.md new file mode 100644 index 00000000..1aaddd56 --- /dev/null +++ b/doc/overlay/polyline.md @@ -0,0 +1,66 @@ +# Polyline + +Polyline objects are similar to polyline objects in that they consist of a series of coordinates in an ordered sequence. +However, instead of being open-ended, polylines are designed to define regions within a closed loop. + +## Build + +First of all, if you want to render a polyline, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Overlay\Polyline; + +$polyline = new Polyline(); +``` + +The polyline constructor does not require anything but It accepts additional parameters such as coordinates (default +empty) and options (default empty): + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Polyline; + +$polyline = new Polyline( + [ + new Coordinate(25.774, -80.190), + new Coordinate(18.466, -66.118), + new Coordinate(32.321, -64.757), + new Coordinate(25.774, -80.190), + ], + ['fillOpacity' => 0.5] +); +``` + +## Configure variable + +A variable is automatically generated when creating a polyline but if you want to update it, you can use: + +``` php +$polyline->setVariable('polyline'); +``` + +## Configure coordinates + +If you want to update the polyline coordinates, you can use: + +``` php +$polyline->setCoordinates([]); +``` + +## Configure options + +The polyline options allows you to configure additional polyline aspects. See the list of available options in the +official [documentation](https://developers.google.com/maps/documentation/javascript/reference#PolylineOptions). Then, +to configure them, you can use: + +``` php +$polyline->setOption('fillOpacity', 0.5); +``` + +## Append to a map + +After building your polyline, you need to add it to a map with: + +``` php +$map->getOverlayManager()->addPolyline($polyline); +``` diff --git a/doc/overlay/rectangle.md b/doc/overlay/rectangle.md new file mode 100644 index 00000000..0dae7f8b --- /dev/null +++ b/doc/overlay/rectangle.md @@ -0,0 +1,78 @@ +# Rectangle + +A Rectangle is similar to a Polygon in that you can define custom colors, weights, and opacities for the edge of the +rectangle (the "stroke") and custom colors and opacities for the area within the enclosed region (the "fill"). Unlike a +Polygon, you do not define paths for a Rectangle; instead, a rectangle has one additional property which defines its +shape : the bound. + +## Build + +First of all, if you want to render a circle, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Base\Base; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Rectangle; + +$rectangle = new Rectangle(new Bound( + new Coordinate(-1, -1), + new Coordinate(1, 1) +)); +``` + +The rectangle constructor requires a bound as first argument which represents its area. It also accepts additional +parameters such as options (default empty): + +``` php +use Ivory\GoogleMap\Base\Base; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Rectangle; + +$rectangle = new Rectangle( + new Bound( + new Coordinate(-1, -1), + new Coordinate(1, 1) + ), + ['clickable' => false] +); +``` + +## Configure variable + +A variable is automatically generated when creating a rectangle but if you want to update it, you can use: + +``` php +$rectangle->setVriable('rectangle'); +``` + +## Configure bound + +If you want to update the bound, you can use: + +``` php +use Ivory\GoogleMap\Base\Base; +use Ivory\GoogleMap\Base\Coordinate; + +$rectangle->setBound(new Bound( + new Coordinate(-1, -1), + new Coordinate(1, 1) +)); +``` + +## Configure options + +The rectangle options allows you to configure additional rectangle aspects. See the list of available options in the +official [documentation](https://developers.google.com/maps/documentation/javascript/reference#RectangleOptions). Then, +to configure them, you can use: + +``` php +$rectangle->setOption('clickable', false); +``` + +## Append to a map + +After building your rectangle, you need to add it to a map with: + +``` php +$map->getOverlayManager()->addRectangle($rectangle); +``` diff --git a/doc/place/autocomplete.md b/doc/place/autocomplete.md new file mode 100644 index 00000000..bdf1adce --- /dev/null +++ b/doc/place/autocomplete.md @@ -0,0 +1,101 @@ +# Autocomplete + +The Places Autocomplete feature attaches to a text field on your web page, and monitors that field for character +entries. As text is entered, Autocomplete returns Place predictions to the application in the form of a drop-down pick +list. You can use the Places Autocomplete feature to help users find a specific location, or assist them with filling +out address fields in online forms. + +## Build + +``` php +use Ivory\GoogleMap\Place\Autocomplete; + +$autocomplete = new Autocomplete(); +``` + +## Configure variable + +A variable is automatically generated when creating an autocomplete but if you want to update it, you can use: + +``` php +$autocomplete->setVariable('place_autocomplete'); +``` + +## Configure input id + +If you want to update the default html id (places_autocomplete) used for the autocomplete input, you can use: + +``` php +$autocomplete->setInputId('place_input'); +``` + +## Configure value + +If you want to set default input value, you can use: + +``` pphp +$autocomplete->setValue('foo'); +``` + +## Configure types + +If you want to restrict places types, you can use: + +``` php +use Ivory\GoogleMap\Place\AutocompleteType; + +$autocomplete->setTypes([AutocompleteType::ESTABLISHMENT]); +``` + +## Configure component restrictions + +If you want to restrict the autocomplete to components, you can use: + +``` php +use Ivory\GoogleMap\Place\AutocompleteComponentRestriction; + +$autocomplete->setComponentRestrictions([AutocompleteComponentRestriction::COUNTRY => 'fr']); +``` + +## Configure bound + +If you want to restrict the search area, you can configure a bound: + +``` php +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; + +$autocomplete->setBound(new Bound( + new Coordinate(-2.1, -3.9), + new Coordinate(2.6, 1.4) +)); +``` + +## Configure language + +If you want to use your own language when displaying your autocomplete, you can use: + +``` php +$autocomplete->setLanguage('fr'); +``` + +## Configure libraries + +Sometimes, you want to use the autocomplete & other Google Map related libraries. The library provides many +integrations but not all of them. If you need a custom library (for example `drawing`), you can use: + +``` +$autocomplete->addLibrary('drawing'); +``` + +## Configure input attributes + +If you want to configure autocomplete input attributes, you can use: + +``` php +$autocomplete->setInputAttribute('class', 'my-class'); +``` + +## Render autocomplete + + diff --git a/doc/usage/places/index.md b/doc/place/index.md similarity index 72% rename from doc/usage/places/index.md rename to doc/place/index.md index 59f73411..5f60681e 100644 --- a/doc/usage/places/index.md +++ b/doc/place/index.md @@ -4,4 +4,4 @@ The Google Places JavaScript library's functions enable your application to sear establishments, geographic locations, or prominent points of interest) contained within a defined area, such as the bounds of a map, or around a fixed point. - 1. [Autocomplete](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/places/autocomplete.md) + - [Autocomplete](/place/autocomplete.md) diff --git a/doc/service/business_account.md b/doc/service/business_account.md new file mode 100644 index 00000000..be91b8e1 --- /dev/null +++ b/doc/service/business_account.md @@ -0,0 +1,95 @@ +# Business Account + +When using a service for business purpose, you will receive a business account from Google. This one allows you to +bypass Google limitation according to your billing plan. + +## Build + +First of all, if you want to use a business account, you will need to build one. So let's go: + +``` php +use Ivory\GoogleMap\Service\BusinessAccount; + +$businessAccount = new BusinessAccount('client_id', 'secret'); +``` + +The business account constructor requires a client id as first argument and a secret as second argument. It also +accepts additional parameters such as channel (default null): + +``` php +use Ivory\GoogleMap\Service\BusinessAccount; + +$businessAccount = new BusinessAccount('client_id', 'secret', 'channel'); +``` + +## Configure client id + +If you want to update the client id, you can use: + +``` php +$businessAccount->setClientId('client_id'); +``` + +The client id is not prefixed by `gme-` (it is automatically prepended by the library). + +## Configure secret + +If you want to update the secret, you can use: + +``` php +$businessAccount->setSecret('secret'); +``` + +## Configure channel + +If you want to update the channel, you can use: + +``` +$businessAccount->setChannel('channel'); +``` + +## Use with services + +When you have built you business account, you need to configure it on a service. + +### Directions + +If you want to use the directions service with a Google business account, you need to set it on the service: + +``` php +$directions->setBusinessAccount($businessAccount); +``` + +If you want to go back the normal behavior (anonymous), you need to reset the business account: + +``` php +$directions->setBusinessAccount(null); +``` + +### Distance Matrix + +If you want to use the distance matrix service with a Google business account, you need to set it on the service: + +``` php +$distanceMatrix->setBusinessAccount($businessAccount); +``` + +If you want to go back the normal behavior (anonymous), you need to reset the business account: + +``` php +$distanceMatrix->setBusinessAccount(null); +``` + +### Geocoder + +If you want to use the geocoder service with a Google business account, you need to set it on the provider: + +``` php +$geocoder->setBusinessAccount($businessAccount); +``` + +If you want to go back the normal behavior (anonymous), you need to reset the business account: + +``` php +$geocoder->setBusinessAccount(null); +``` diff --git a/doc/service/directions/directions.md b/doc/service/directions/directions.md new file mode 100644 index 00000000..ea21818b --- /dev/null +++ b/doc/service/directions/directions.md @@ -0,0 +1,48 @@ +# Directions API + +The Google Directions API is a service that calculates directions between locations using an HTTP request. You can +search for directions for several modes of transportation, include transit, driving, walking or cycling. Directions +may specify origins, destinations and waypoints either as text strings (e.g. "Chicago, IL" or "Darwin, NT, Australia") +or as latitude/longitude coordinates. The Directions API can return multi-part directions using a series of waypoints. + +## Dependencies + +The Directions API requires an http client and so, the library relies on [Httplug](http://httplug.io/) which is an http +client abstraction library. To install it, read this [documentation](/doc/installation.md). + +## Build + +First of all, if you want to route a direction, you will need to build a directions service. So let's go: + +``` php +use Ivory\GoogleMap\Service\Directions\Directions; +use Http\Adapter\Guzzle6\Client; +use Http\Message\MessageFactory\GuzzleMessageFactory; + +$directions = new Directions(new Client(), new GuzzleMessageFactory()); +``` + +The directions constructor requires an `HttpClient` as first argument and a `MessageFactory` as second argument. Here, +I have chosen to use the [Guzzle6](http://docs.guzzlephp.org/en/latest/psr7.html) client as well as the Guzzle message +factory. Httplug supports the most popular http clients, so, you can choose you preferred one instead. + +All services works the same way, so, if you want to learn more about it, you can read this common +[documentation](/doc/service/service.md) about services. + +## Request + +Once you have built you directions service, you can request a direction: + +``` php +use Ivory\GoogleMap\Service\Directions\DirectionsRequest; + +$response = $directions->route(new DirectionsRequest('New York', 'Washington')); +``` + +The directions service allows you to route a much more advance request. If you want to learn more about it, you can +read its [documentation](/doc/service/directions/directions_request.md). + +## Response + +When you have requested your direction, the service give you a response object. If you want to learn more about it, you +can read its [documentation](/doc/service/directions/directions_response.md). diff --git a/doc/service/directions/directions_request.md b/doc/service/directions/directions_request.md new file mode 100644 index 00000000..c12bc8cc --- /dev/null +++ b/doc/service/directions/directions_request.md @@ -0,0 +1,134 @@ +# Directions Request + +A directions request is the starting point when you want to request a direction. + +## Build + +First of all, if you want to route a direction, you will need to build a directions request. So let's go: + +``` php +use Ivory\GoogleMap\Service\Directions\DirectionsRequest; + +$request = new DirectionsRequest('New York', 'Washington'); +``` + +The directions request constructor requires an origin as first argument and a destination as second argument. + +## Configure origin + +If you want to update the origin, you can use: + +``` php +$request->setOrigin('New York'); +``` + +The origin also accepts a coordinate: + +``` php +use Ivory\GoogleMap\Base\Coordinate; + +$request->setOrigin(new Coordinate(1.1, 2.1)); +``` + +## Configure destination + +If you want to update the destination, you can use: + +``` php +$request->setDestination('Washington'); +``` + +The destination also accepts a coordinate: + +``` php +use Ivory\GoogleMap\Base\Coordinate; + +$request->setDestination(new Coordinate(2.1, 1.1)); +``` + +## Configure waypoints + +If you want to add waypoint to your direction, you can use: + +``` php +use Ivory\GoogleMap\Service\Directions\DirectionsWaypoint; + +$request->addWaypoint(new DirectionsWaypoint('Philadelphia')); +``` + +The waypoint also accepts a coordinate: + +``` php +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Directions\DirectionsWaypoint; + +$request->addWaypoint(new DirectionsWaypoint(new Coordinate(1.2, 2.2))); +``` + +## Configure waypoints optimization + +If you want to optimize waypoints, you can use: + +``` php +$request->setOptimizeWaypoints(true); +``` + +## Configure avoid highways + +If you want to avoid highways, you can use: + +``` php +$request->setAvoidHighways(true); +``` + +## Configure avoid tolls + +If you want to avoid tolls, you can use: + +``` php +$request->setAvoidTolls(true); +``` + +## Configure route alternatives + +If you want to have route alternatives, you can use: + +``` php +$request->setProvideRouteAlternatives(true); +``` + +## Configure travel mode + +If you want to define your travel mode, you can use: + +``` php +use Ivory\GoogleMap\Service\Base\TravelMode; + +$request->setTravelMode(TravelMode::DRIVING); +``` + +## Configure unit system + +If you want to update the unit system, you can use: + +``` php +use Ivory\GoogleMap\Service\Base\UnitSystem; + +$request->setUnitSystem(UnitSystem::METRIC); +``` + +## Configure region + +If you want to update the region, you can use: + +``` php +$request->setRegion('us'); +``` + +## Configure language + +If you want to update the language, you can use: + +``` php +$request->setLanguage('fr'); +``` diff --git a/doc/usage/services/directions/directions.md b/doc/service/directions/directions_response.md similarity index 52% rename from doc/usage/services/directions/directions.md rename to doc/service/directions/directions_response.md index e4515a69..f617720a 100644 --- a/doc/usage/services/directions/directions.md +++ b/doc/service/directions/directions_response.md @@ -1,70 +1,31 @@ -# Directions API +# Directions Response -The Directions API uses [widop/http-adapter](http://github.com/widop/http-adapter) which is a PHP 5.3 library for -issuing http requests. +When you have requested your direction, the returned object is a `DirectionsResponse`. It wraps a status & routes. -The Google Directions API is a service that calculates directions between locations using an HTTP request. You can -search for directions for several modes of transportation, include transit, driving, walking or cycling. Directions -may specify origins, destinations and waypoints either as text strings (e.g. "Chicago, IL" or "Darwin, NT, Australia") -or as latitude/longitude coordinates. The Directions API can return multi-part directions using a series of waypoints. +## Status -## Request the directions service +The available status are defined by the `DirectionsStatus` constants. ``` php -use Ivory\GoogleMap\Services\Directions\Directions; -use Widop\HttpAdapter\CurlHttpAdapter; - -$directions = new Directions(new CurlHttpAdapter()); -``` - -If you want to use it with a business account, you can read this -[documentation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/business_account.md). - -## Request a direction - -``` php -$response = $directions->route('New York', 'Washington'); -``` - -The directions service allows you to route a much more advance request. If you want to learn more, you can read this -[documentation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/directions/directions_request.md). - -## Directions response - -When you have requested your direction, the returned object is an ``Ivory\GoogleMap\Services\Directions\DirectionsResponse``. -It wraps a status & routes. - -### Directions status - -The available status are defined by the ``Ivory\GoogleMap\Services\Directions\DirectionsStatus`` constants. - -``` php -// Get the status $status = $response->getStatus(); ``` -### Directions routes +## Routes -A request can return many routes. The directions response wraps an array of -``Ivory\GoogleMap\Services\Directions\DirectionsRoute``. +A request can return many routes. The directions response wraps an array of `DirectionsRoute`. ``` php -// Get the routes $routes = $reponse->getRoutes(); ``` -## Directions route +## Route A directions route wraps a bound, a copyrights, legs, an overview polyline (encoded), a summary, warnings & waypoint order if you use it in your request. ``` php -// Get the routes -$routes = $reponse->getRoutes(); - -// Iterate each routes -foreach ($routes as $route) { - +foreach ($reponse->getRoutes() as $route) { + // ... } ``` @@ -73,7 +34,6 @@ foreach ($routes as $route) { The bound defines the viewport bounding box of this route. ``` php -// Get the bound $bound = $route->getBound(); ``` @@ -82,38 +42,33 @@ $bound = $route->getBound(); The copyrights defines the text to be displayed for this route. You must handle and display this information yourself. ``` php -// Get the copyrights $copyrights = $route->getCopyrights(); ``` -### Directions legs +### Legs -The directions legs defines an array which contains information about a leg of the route, between two locations within +The directions legs defines an array which contains information about a leg of the route between two locations within the given route. A separate leg will be present for each waypoint or destination specified. (A route with no waypoints will contain exactly one leg within the legs array.) Each leg consists of a series of steps. ``` php -// Get the legs $legs = $route->getLegs(); ``` -### Overview polyline +### Overview Polyline -The overview polyline is an [encoded polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/encoded_polyline.md) -which represents the route. +The overview polyline is an [encoded polyline](/doc/overlay/encoded_polyline.md) which represents the route. ``` php -// Get the overview polyline $overviewPolyline = $route->getOverviewPolyline(); ``` ### Summary -The summari is a short textual description for the route, suitable for naming and disambiguating the route from +The summary is a short textual description for the route, suitable for naming and disambiguating the route from alternatives. ``` php -// Get the summary $summary = $route->getSummary(); ``` @@ -123,72 +78,58 @@ It is an array of warnings to be displayed when showing these directions. You mu yourself. ``` php -// Get the warnings $warnings = $route->getWarnings(); ``` ### Waypoint order It contains an array indicating the order of any waypoints in the calculated route. This waypoints may be reordered if -the request was passed `optimize:true` within its `waypoints` parameter. +the request optimizes waypoints. ``` php -// Get the waypoint order -$waypointOrder = $route->getWaypointOrder(); +$waypointOrders = $route->getWaypointOrders(); ``` -## Directions leg +## Leg -A directions legs wraps a distance, a durations, a start location, an end location, a start address, an end address, +A directions leg wraps a distance, a durations, a start location, an end location, a start address, an end address and steps. ``` php -// Get the legs -$legs = $route->getLegs(); - -// Iterate each leg -foreach ($legs as $leg) { - +foreach ($route->getLegs() as $leg) { + // ... } ``` ### Distance -It indicates the total distance covered by this leg. It represented by the -`Ivory\GoogleMap\Services\Base\Distance`. +It indicates the total distance covered by this leg. It represented by the `Distance`. ``` php -// Gets the distance $duration = $leg->getDistance(); ``` ### Duration -It indicates the total duration of this leg. It is represented by the -`Ivory\GoogleMap\Services\Base\Duration`. +It indicates the total duration of this leg. It is represented by the `Duration`. ``` php -// Gets the duration $duration = $leg->getDuration(); ``` ### Start location -The start location is the coordinate of the start of this leg. It is represented by the -`Ivory\GoogleMap\Base\Coordinate`. +The start location is the coordinate of the start of this leg. It is represented by the `Coordinate`. ``` php -// Gets the start location $startLocation = $leg->getStartLocation(); ``` ### End location -The end location is the coordinate of the end of this leg. It is represented by the -`Ivory\GoogleMap\Base\Coordinate`. +The end location is the coordinate of the end of this leg. It is represented by the `Coordinate`. ``` php -// Gets the end location $endLocation = $leg->getEndLocation(); ``` @@ -197,7 +138,6 @@ $endLocation = $leg->getEndLocation(); It contains the human-readable address (typically a street address) reflecting the start location. ``` php -// Gets the start address $startAddress = $leg->getStartAddress(); ``` @@ -206,20 +146,18 @@ $startAddress = $leg->getStartAddress(); It contains the human-readable address (typically a street address) reflecting the end location. ``` php -// Gets the end address $endAddress = $leg->getEndAddress(); ``` -### Directions Steps +### Steps A leg contains an array of steps denoting information about each separate step of the leg of the journey. ``` php -// Gets the directions steps. $steps = $leg->getSteps(); ``` -## Directions step +## Step A step is the most atomic unit of a direction's route, containing a single step describing a specific, single instruction on the journey. E.g. "Turn left at W. 4th St." The step not only describes the instruction but also @@ -231,52 +169,42 @@ A step wraps a distance, a durations, a start location, an end location, instruc a travel mode. ``` php -// Gets the directions steps. -$steps = $leg->getSteps(); - -// Iterate each step -foreach ($steps as $step) { - +foreach ($leg->getSteps() as $step) { + // ... } ``` ### Distance -It contains the distance covered by this step until the next step. This field may be undefined if the distance is +It contains the distance covered by this step until the next step. This field may be null if the distance is unknown. ``` php -// Gets the distance. $distance = $step->getDistance(); ``` ### Duration -It contains the typical time required to perform the step, until the next step. This field may be undefined if the +It contains the typical time required to perform the step, until the next step. This field may be null if the duration is unknown. ``` php -// Gets the duration. $duration = $step->getDuration(); ``` ### Start Location -It contains the location of the starting point of this step. It is represented by the -`Ivory\GoogleMap\Base\Coordinate`. +It contains the location of the starting point of this step. It is represented by the `Coordinate`. ``` php -// Gets the start location. $startLocation = $step->getStartLocation(); ``` ### End Location -It contains the location of the ending point of this step. It is represented by the -`Ivory\GoogleMap\Base\Coordinate`. +It contains the location of the ending point of this step. It is represented by the Coordinate`. ``` php -// Gets the end location. $endLocation = $step->getEndLocation(); ``` @@ -285,25 +213,21 @@ $endLocation = $step->getEndLocation(); It contains formatted instructions for this step, presented as an HTML text string. ``` php -// Gets the instructions. $instructions = $step->getInstructions(); ``` ### Encoded polyline -It represents the step as an [encoded polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/encoded_polyline.md). +It represents the step as an [encoded polyline](/doc/overlay/encoded_polyline.md). ``` php -// Gets the encoded polyline. $encodedPolyline = $step->getEncodedPolyline(); ``` ### Travel Mode -It contains the travel mode of this step. it is represented by the `Ivory\GoogleMap\Services\Base\TravelMode` -constants. +It contains the travel mode of this step. it is represented by the `TravelMode` constants. ``` php -// Gets the travel mode. $travelMode = $step->getTravelMode(); ``` diff --git a/doc/service/distance_matrix/distance_matrix.md b/doc/service/distance_matrix/distance_matrix.md new file mode 100644 index 00000000..3d5df728 --- /dev/null +++ b/doc/service/distance_matrix/distance_matrix.md @@ -0,0 +1,51 @@ +# Distance Matrix API + +The Google Distance Matrix API is a service that provides travel distance and time for a matrix of origins and +destinations. The information returned is based on the recommended route between start and end points, as calculated +by the Google Maps API, and consists of rows containing duration and distance values for each pair. + +This service does not return detailed route information. Route information can be obtained by passing the desired +single origin and destination to the [Directions API](/doc/service/directions/directions.md). + +## Dependencies + +The Distance Matrix API requires an http client and so, the library relies on [Httplug](http://httplug.io/) which is an +http client abstraction library. To install it, read this [documentation](/doc/installation.md). + +## Build + +``` php +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrix; +use Http\Adapter\Guzzle6\Client; +use Http\Message\MessageFactory\GuzzleMessageFactory; + +$distanceMatrix = new DistanceMatrix(new Client(), new GuzzleMessageFactory()); +``` + +The distance matrix constructor requires an `HttpClient` as first argument and a `MessageFactory` as second argument. +Here, I have chosen to use the [Guzzle6](http://docs.guzzlephp.org/en/latest/psr7.html) client as well as the Guzzle +message factory. Httplug supports the most popular http clients, so, you can choose you preferred one instead. + +All services works the same way, so, if you want to learn more about it, you can read this common +[documentation](/doc/service/service.md) about services. + +## Request + +Once you have built you distance matrix service, you can process a matrix: + +``` php +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixRequest; + +$response = $distanceMatrix->process(new DistanceMatrixRequest( + ['Vancouver BC'], + ['San Francisco'] +)); +``` + +The distance matrix allows you to process a much more advanced request. If you want to lear more about it, you can read +its [documentation](/doc/service/distance_matrix/distance_matrix_request.md). + +## Response + +When you have requested your distance matrix, the service give you a response object. If you want to learn more about +it, you can read its [documentation](/doc/service/distance_matrix/distance_matrix_response.md). diff --git a/doc/service/distance_matrix/distance_matrix_request.md b/doc/service/distance_matrix/distance_matrix_request.md new file mode 100644 index 00000000..8e1b0bd0 --- /dev/null +++ b/doc/service/distance_matrix/distance_matrix_request.md @@ -0,0 +1,100 @@ +# Distance Matrix Request + +A distance matrix request is the starting point when you want to process a distance matrix. + +## Build + +First of all, if you want to process a distance matrix, you will need to build a distance matrix request. So let's go: + +``` php +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixRequest; + +$request = new DistanceMatrixRequest(['New York'], ['Washington']); +``` + +The distance matrix constructor requires an array of origins as first argument and an array of destinations as second +argument. + +## Configure origins + +If you want to update origins, you can use: + +``` php +$request->setOrigins(['New York']); +``` + +The origins also accepts coordinates: + +``` php +use Ivory\GoogleMap\Base\Coordinate; + +$request->setOrigins([new Coordinate(1.1, 2.1)]); +``` + +## Configure destinations + +If you want to update destinations, you can use: + +``` php +$request->setDestinations(['Washington']); +``` + +The destinations also accepts coordinates: + +``` php +use Ivory\GoogleMap\Base\Coordinate; + +$request->setDestinations([new Coordinate(2.1, 1.1)]); +``` + +## Configure avoid highways + +If you want to avoid highways, you can use: + +``` php +$request->setAvoidHighways(true); +``` + +## Configure avoid tolls + +If you want to avoid tolls, you can use: + +``` php +$request->setAvoidTolls(true); +``` + +## Configure travel mode + +If you want to choose a travel mode, you can use: + +``` php +use Ivory\GoogleMap\Service\Base\TravelMode; + +$request->setTravelMode(TravelMode::DRIVING); +``` + +## Configure unit system + +if you want to update the unit system, you can use: + +``` php +use Ivory\GoogleMap\Service\Base\UnitSystem; + +$request->setUnitSystem(UnitSystem::METRIC); +``` + +## Configure region + +If you want to update the region, you can use: + +``` php +$request->setRegion('us'); +``` + +## Configure language + +If you want to update the language, you can use: + +``` php +$request->setLanguage('fr'); +``` diff --git a/doc/service/distance_matrix/distance_matrix_response.md b/doc/service/distance_matrix/distance_matrix_response.md new file mode 100644 index 00000000..f026c123 --- /dev/null +++ b/doc/service/distance_matrix/distance_matrix_response.md @@ -0,0 +1,81 @@ +# Distance Matrix Response + +When you have requested your distance matrix, the returned object is an `DistanceMatrixResponse`. It wraps a status, +origins, destinations and rows. + +## Status + +The available status are defined by the `DistanceMatrixStatus` constants. + +``` php +$status = $response->getStatus(); +``` + +## Origins + +It contains an array of addresses as returned by the API from your original request. These are formatted by the +geocoder and localized according to the language parameter passed with the request. + +``` php +$origins = $response->getOrigins(); +``` + +## Destinations + +It contains an array of addresses as returned by the API from your original request. As with distance matrix origins, +these are localized if appropriate. + +``` php +$destinations = $response->getDestinations(); +``` + +## Rows + +When the Distance Matrix API returns results, it places them within a rows array. Even if no results are returned +(such as when the origins and/or destinations don't exist), it still returns an empty array. Rows are ordered according +to the values in the origin parameter of the request. Each row corresponds to an origin, and each element within that +row corresponds to a pairing of the origin with a destination value. + +Each row array contains one or more distance matrix element entries, which in turn contain the information about a +single origin-destination pairing. + +``` php +foreach ($response->getRows() as $row) { + // ... +} +``` + +## Element + +The information about each origin-destination pairing is represented by the `DistanceMatrixElement`. An element +contains a status, a duration and a distance. + +``` php +foreach ($row->getElements() as $element) { + // ... +} +``` + +### Status + +The available status are defined by the `DistanceMatrixElementStatus` constants. + +``` php +$status = $element->getStatus(); +``` + +### Distance + +The duration of this route represented by `Distance`. + +``` php +$distance = $element->getDistance(); +``` + +#### Duration + +The duration of this route represented by `Duration`. + +``` php +$duration = $element->getDuration(); +``` diff --git a/doc/service/geocoder/geocoder.md b/doc/service/geocoder/geocoder.md new file mode 100644 index 00000000..13566eef --- /dev/null +++ b/doc/service/geocoder/geocoder.md @@ -0,0 +1,55 @@ +# Geocoder API + +Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic +coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. +Additionally, the service allows you to perform the converse operation (turning coordinates into addresses). This +process is known as "reverse geocoding". + +## Dependencies + +The Geocoder API uses [Geocoder](http://github.com/willdurand/Geocoder) which is the most popular PHP Geocoder. So, +first, I recommend you to read its documentation. To install it, read this [documentation](/doc/installation.md). + +It also requires an http client and so, the library relies on [Httplug](http://httplug.io/) which is an http +client abstraction library. To install it, read this [documentation](/doc/installation.md). + +## Why an other Geocoder? + +The Geocoder shipped with the library is not an other Geocoder but an extension of the most popular +[Geocoder](http://github.com/willdurand/Geocoder). The main difference is instead of giving you a typical response, +it returns a custom once wrapping Ivory objects allowing you to more easily reuse them. + +## Build + +First of all, if you want to geocode a position, you will need to build a geocoder provider. So let's go: + +``` php +use Ivory\GoogleMap\Service\Geocoder\GeocoderProvider; +use Http\Adapter\Guzzle6\Client; +use Http\Message\MessageFactory\GuzzleMessageFactory; + +$geocoder = new GeocoderProvider(new Client(), new GuzzleMessageFactory()); +``` + +The geocoder provider constructor requires an `HttpClient` as first argument and a `MessageFactory` as second argument. +Here, I have chosen to use the [Guzzle6](http://docs.guzzlephp.org/en/latest/psr7.html) client as well as the Guzzle +message factory. Httplug supports the most popular http clients, so, you can choose you preferred one instead. + +All services works the same way, so, if you want to learn more about it, you can read this common +[documentation](/doc/service/service.md) about services. + +## Request + +Once you have built you geocoder provider, you can geocode a position: + +``` php +$response = $geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); +``` + +The geocoder provider allows you to geocoder a much more advance request. If you want to learn more about it, you can +read its [documentation](/doc/service/geocoder/geocoder_request.md). + +## Response + +When you have geocode your position, the provider give you a response object. If you want to learn more about it, you +can read its [documentation](/doc/service/geocoder/geocoder_response.md). diff --git a/doc/service/geocoder/geocoder_request.md b/doc/service/geocoder/geocoder_request.md new file mode 100644 index 00000000..4d43a204 --- /dev/null +++ b/doc/service/geocoder/geocoder_request.md @@ -0,0 +1,58 @@ +# Geocoder Request + +A geocoder request is the starting point when you want to geocode a position. + +## Build + +First of all, if you want to geocode a position, you will need to build a geocoder request. So let's go: + +``` php +use Ivory\GoogleMap\Service\Geocoder\GeocoderRequest; + +$request = new GeocoderRequest('1600 Amphitheatre Parkway, Mountain View, CA'); +``` + +The geocoder request constructor requires an address as first argument. + +## Configure address + +If you want to update the address, you can use: + +``` php +$request->setAddress('1600 Amphitheatre Parkway, Mountain View, CA'); +``` + +The address also accepts a coordinate: + +``` php +use Ivory\GoogleMap\Base\Coordinate: + +$request->setAddress(new Coordinate(1.1, 2.1)); +``` + +## Configure bound + +If you want to restrict the geocoder area, you can use a bound: + +``` php +$request->setBound(new Bound( + new Coordinate(-1.1, -2.1), + new Coordinate(2.1, 1.1) +)); +``` + +## Configure region + +If you want to update the region, you can use: + +``` php +$request->setRegion('en'); +``` + +## Configure language + +If you want to update the language, you can use: + +``` php +$request->setLanguage('fr'); +``` diff --git a/doc/service/geocoder/geocoder_response.md b/doc/service/geocoder/geocoder_response.md new file mode 100644 index 00000000..a9f5ee86 --- /dev/null +++ b/doc/service/geocoder/geocoder_response.md @@ -0,0 +1,108 @@ +# Geocoder Response + +When you have requested your position, the returned object is an `GeocoderResponse`. It wraps a geocoder status and +results. + +## Status + +The available status are defined by the `GeocoderStatus` constants. + +``` php +$status = $response->getStatus(); +``` + +## Results + +A request can return many results. The geocoder response wraps an array of `GeocoderResult`. + +``` php +$results = $response->getResults(); +``` + +## Result + +Each result wraps an human readable address, some address & geometry informations, a partial match flag & some result +types. + +``` php +foreach ($reponse->getResults() as $result) { + // ... +} +``` + +### Human readable address + +The method `getFormattedAddress` is a string containing the human-readable address of this location. Often this +address is equivalent to the "postal address," which sometimes differs from country to country. (Note that some +countries, such as the United Kingdom, do not allow distribution of true postal addresses due to licensing +restrictions). + +``` php +$formattedAddress = $result->getFormattedAddress(); +``` + +### Address informations + +The method `getAddressComponents` returns an array containing the separate address components. Each address_component +typically contains: + + - types which is an array indicating the type of the address component. + - long name which is the full text description or name of the address component as returned by the Geocoder. + - short name which is an abbreviated textual name for the address component, if available. For example, an address + component for the state of Alaska may have a long_name of "Alaska" and a short_name of "AK" using the 2-letter + postal abbreviation. + +``` php +foreach ($result->getAddressComponents() as $address) { + $longName = $address->getLongName(); + $shortName = $address->getShortName(); + $types = $address->getTypes(); +} +``` + +You can also filter the address components by type: + +``` php +foreach ($result->getAddressComponents('route') as $address) { + // ... +} +``` + +### Geometry informations + +Geometry contains the following information: + + - location which is an `Coordinate`. + - location type stores additional data about the specified location. The available possibilites are describes by the + `GeocoderLocationType` constants. + - viewport which contains the recommended viewport for displaying the returned result, specified as `Bound`. + - bounds (optionally returned) which stores the bounding box which can fully contain the returned result, specified as + `Bound`. Note that these bounds may not match the recommended viewport. + +``` php +$location = $result->getGeometry()->getLocation() +$locationType = $result->getGeometry()->getLocationType(); +$viewport = $result->getGeometry()->getViewport(); +$bound = $result->getGeometry()->getBound(); +``` + +### Partial match flag + +The partial match flag indicates that the geocoder did not return an exact match for the original request, though it +did match part of the requested address. You may wish to examine the original request for misspellings and/or an +incomplete address. Partial matches most often occur for street addresses that do not exist within the locality you +pass in the request. + +``` php +$partialMatch = $result->isPartialMatch(); +``` + +### Types + +The result types is an array indicates the type of the returned result. This array contains a set of one or more tags +identifying the type of feature returned in the result. For example, a geocode of "Chicago" returns "locality" which +indicates that "Chicago" is a city, and also returns "political" which indicates it is a political entity. + +``` php +$types = $result->getTypes(); +``` diff --git a/doc/service/index.md b/doc/service/index.md new file mode 100644 index 00000000..66a322ae --- /dev/null +++ b/doc/service/index.md @@ -0,0 +1,6 @@ +# Google Map API Services + + - [Directions](/doc/service/directions/directions.md) + - [Distance Matrix](/doc/service/directions/distance_matrix.md) + - [Geocoder](/doc/service/geocoder/geocoder.md) + - [Business Account](/doc/service/business_account.md) diff --git a/doc/service/service.md b/doc/service/service.md new file mode 100644 index 00000000..95a5bcc3 --- /dev/null +++ b/doc/service/service.md @@ -0,0 +1,51 @@ +# Services + +All services (directions, distance matrix, geocoder, ...) share common features. + +## Configure http client + +If you want to update the service http client, you can use: + +``` php +use Http\Adapter\Guzzle6\Client; + +$service->setClient(new Client()); +``` + +Here, I have chosen to use the [Guzzle6](http://docs.guzzlephp.org/en/latest/psr7.html) client but since +[Httplug](http://httplug.io/) supports the most popular http clients, you can choose you preferred one instead. + +## Configure message factory + +If you want to update the message factory, you can use: + +``` php +use Http\Message\MessageFactory\GuzzleMessageFactory; + +$service->setMessageFactory(new GuzzleMessageFactory()); +``` + +Here, I have chosen to use the [Guzzle6](http://docs.guzzlephp.org/en/latest/psr7.html) message factory but since +[Httplug](http://httplug.io/) supports the most popular http clients, you can choose you preferred one instead. + +## Configure https + +If you want to rely on http instead of https, you can use: + +``` php +$service->setHttps(false); +``` + +## Configure format + +If you want to rely on XML instead of JSON, you wan use: + +``` php +use Ivory\GoogleMap\Service\AbstractService; + +$service->setFormat(AbstractService::FORMAT_XML); +``` + +## Configure business account + +If you want to use a service with a business account, you can read this [documentation](/doc/service/business_account.md). diff --git a/doc/usage.md b/doc/usage.md index 0ae06012..06233808 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -1,150 +1,72 @@ # Usage -Before starting, I recommend you to read the google map API v3 documentation which is available -[here](http://code.google.com/apis/maps/documentation/javascript/reference.html). It will give you a better understand -for the next parts. +## Configure map -## Build your map +The Map is the central point of the library. It allows you to manipulate all available options. If you render the +default map, the library will generate a map of 300px by 300px, centered on the coordinate (0, 0), configured with +a zoom of 3 & using the default controls. -First of all, if you want to render a map, you will need to build one. So let's go: + - [Build a map](/doc/map.md#build) + - [Configure variable](/doc/map.md#configure-variable) + - [Configure html id](/doc/map.md#configure-html-id) + - [Configure center & zoom](/doc/map.md#configure-center-zoom) + - [Configure libraries](/doc/map.md#configure-libraries) + - [Configure language](/doc/map.md#configure-language) + - [Configure options](/doc/map.md#configure-otpions) + - [Configure stylesheets](/doc/map.md#configure-stylesheets) -``` php -use Ivory\GoogleMap\Map; +## Configure controls -$map = new Map(); -``` +The maps on Google Maps contain UI elements for allowing user interaction through the map. These elements are known as +controls and you can include variations of these controls in your Google Maps API application. Alternatively, you +can do nothing and let the Google Maps API handle all control behavior. -The Map is the central point of the library. It allows you to manipulate all available options. If you render the -default map, the library will generate a map of 300px by 300px, centered on the coordinate (0, 0), configured with a -zoom of 3 & using the default controls. + - [Map Type](/doc/control/map_type.md) + - [Rotate](/doc/control/rotate.md) + - [Scale](/doc/control/scale.md) + - [Street View](/doc/control/street_view.md) + - [Zoom](/doc/control/zoom.md) + +## Configure layers -## Configure your map +Layers are objects on the map that consist of one or more separate items, but are manipulated as a single unit. Layers +generally reflect collections of objects that you add on top of the map to designate a common association. Layers may +also alter the presentation layer of the map itself, slightly altering the base tiles in a fashion consistent with the +layer. -Now, you have a map, you can configure it easily. The complete map configuration is available -[here](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/map.md). + - [Kml Layer](/doc/layer/kml_layer.md) -### Configure overlays +## Configure overlays Overlays are objects on the map that are tied to latitude/longitude coordinates, so they move when you drag or zoom the map. Overlays reflect objects that you "add" to the map to designate points, lines, areas, or collections of objects. - 1. [Marker](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker.md) - 2. [Info window](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/info_window.md) - 3. [Info box](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/info_box.md) - 4. [Polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polyline.md) - 5. [Encoded Polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/encoded_polyline.md) - 6. [Polygon](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polygon.md) - 7. [Rectangle](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/rectangle.md) - 8. [Circle](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/circle.md) - 9. [Ground overlay](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/ground_overlay.md) - 10. [Marker cluster](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker_cluster.md) - -### Configure controls - -The maps on Google Maps contain UI elements for allowing user interaction through the map. These elements are known as -``controls`` and you can include variations of these controls in your Google Maps API application. Alternatively, you -can do nothing and let the Google Maps API handle all control behavior. - - 1. [Map type control](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/map_type.md) - 2. [Overview](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/overview.md) - 3. [Pan](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/pan.md) - 4. [Rotate](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/rotate.md) - 5. [Scale](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/scale.md) - 6. [Street view](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/street_view.md) - 7. [Zoom](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/zoom.md) - -### Configure events - -The complete events configuration is available -[here](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/events.md). - -### Configure additional libraries - -Sometimes, you want to use the map & other Google Map related libraries. The bundle provides many integrations but not -all of them. If you need a custom libraries, you can use the following API on your map: - -``` -$map->setLibraries(array('places', 'geometry')); -$libraries = $map->getLibraries(); -$hasLibraries = $map->hasLibraries(); -``` - -## Render your map - -Now, you have builded & configured your map, you can render it. For this purpose, you will need the -`Ivory\GoogleMap\Helper\MapHelper` which allows to render the map html container & some javascript for being -able to render it. - -``` -use Ivory\GoogleMap\Helper\MapHelper; - -$mapHelper = new MapHelper(); -``` - -### Render the HTML container - -``` -echo $mapHelper->renderHtmlContainer($map); -``` - -This function renders an html div block with the HTML container ID, the width & the height configured: - -``` html -
-``` - -### Render the javascript - -``` -echo $mapHelper->renderJavascripts($map); -``` - -This function renders an html javascript block with all code needed for displaying your map. - -``` html - -``` - -The generated code is organized to be reusable in the client side. If you want to learn more, you can read this -[documentation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/helper/container.md). - -Additionally, the library allows you to add/render your own javascript libraires and append some code just before or -after the generated code through extensions. If you want to learn more about that, you can read this -[documentation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/helper/extension.md). - -### Render the CSS (Optional) - -Additionally, you can configure some CSS directly on the map. - -``` -echo $mapHelper->renderStylesheets($map); -``` + - [Marker](/doc/overlay/marker.md) + - [Info Window](/doc/overlay/info_window.md) + - [Info Box](/doc/overlay/info_box.md) + - [Polyline](/doc/overlay/polyline.md) + - [Encoded Polyline](/doc/overlay/encoded_polyline.md) + - [Polygon](/doc/overlay/polygon.md) + - [Rectangle](/doc/overlay/rectangle.md) + - [Circle](/doc/overlay/circle.md) + - [Ground Overlay](/doc/overlay/ground_overlay.md) + - [Marker Clusterer](/doc/overlay/marker_clusterer.md) -This function renders an html style block with the CSS configured. +## Configure events -``` html - -``` +Javascript within the browser is event driven, meaning that Javascript responds to interactions by generating events, +and expects a program to listen to interesting events. -If you want to render all of them, you can use: + - [Build an avent](/doc/event.md#build) + - [Configure variable](/doc/event.md#configure-variable) + - [Configure instance](/doc/event.md#configure-instance) + - [Configure trigger](/doc/event.md#configure-trigger) + - [Configure handle](/doc/event.md#configure-handle) + - [Append to a map](/doc/event.md#append-to-a-map) -``` -echo $mapHelper->render($map); -``` +## Render map -``` html - -
- -``` +Once you have configured your map, you can render it: -There is many other methods you can use if you only render specific "parts" of the map. I let you read the class :) +- [Rendering](/doc/helper/index.md) diff --git a/doc/usage/controls/index.md b/doc/usage/controls/index.md deleted file mode 100644 index 0f709748..00000000 --- a/doc/usage/controls/index.md +++ /dev/null @@ -1,13 +0,0 @@ -# Controls - -The maps on Google Maps contain UI elements for allowing user interaction through the map. These elements are known as -controls and you can include variations of these controls in your Google Maps API application. Alternatively, you can -do nothing and let the Google Maps API handle all control behavior. - - 1. [Map type](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/map_type.md) - 2. [Overview](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/overview.md) - 3. [Pan](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/pan.md) - 4. [Rotate](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/rotate.md) - 5. [Scale](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/scale.md) - 6. [Street view](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/street_view.md) - 7. [Zoom](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/zoom.md) diff --git a/doc/usage/controls/map_type.md b/doc/usage/controls/map_type.md deleted file mode 100644 index 69071327..00000000 --- a/doc/usage/controls/map_type.md +++ /dev/null @@ -1,143 +0,0 @@ -# Map type control - -The map type control lets the user toggle between map types (such as ROADMAP and SATELLITE). This control appears by -default in the top right corner of the map. - -## Build your map type control - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControl; -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\MapTypeId; - -$mapTypeControl = new MapTypeControl(); - -// Configure your map type control -$mapTypeControl->setMapTypeIds(array(MapTypeId::ROADMAP, MapTypeId::SATELLITE)); - -$mapTypeControl->addMapTypeId(MapTypeId::ROADMAP); -$mapTypeControl->addMapTypeId(MapTypeId::SATELLITE); - -$mapTypeControl->setControlPosition(ControlPosition::TOP_RIGHT); - -$mapTypeControl->setMapTypeControlStyle(MapTypeControlStyle::DEFAULT_); -``` - -## Configure the map type control IDs - -For configurating the map type ids, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\MapTypeId`` is here. It allows you to access all constants which describe map types. If you don't -want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\MapTypeId; -use Ivory\GoogleMap\Controls\MapTypeControl; - -$mapTypeControl = new MapTypeControl(); - -// Add your map type -$mapTypeControl->addMapTypeId(MapTypeId::HYBRID); -$mapTypeControl->addMapTypeId('hybrid'); - -$mapTypeControl->addMapTypeId(MapTypeId::ROADMAP); -$mapTypeControl->addMapTypeId('roadmap'); - -$mapTypeControl->addMapTypeId(MapTypeId::SATELLITE); -$mapTypeControl->addMapTypeId('satellite'); - -$mapTypeControl->addMapTypeId(MapTypeId::TERRAIN); -$mapTypeControl->addMapTypeId('terrain'); -``` - -## Configure the map type control position - -For configurating the map type control position, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\ControlPosition`` is here. It allows you to access all constants which describe control -position. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControl; - -$mapTypeControl = new MapTypeControl(); - -// Sets your control position -$mapTypeControl->setControlPosition(ControlPosition::TOP_LEFT); -$mapTypeControl->setControlPosition('top_left'); - -$mapTypeControl->setControlPosition(ControlPosition::TOP_CENTER); -$mapTypeControl->setControlPosition('top_center'); - -$mapTypeControl->setControlPosition(ControlPosition::TOP_RIGHT); -$mapTypeControl->setControlPosition('top_right'); - -$mapTypeControl->setControlPosition(ControlPosition::LEFT_TOP); -$mapTypeControl->setControlPosition('left_top'); - -$mapTypeControl->setControlPosition(ControlPosition::LEFT_CENTER); -$mapTypeControl->setControlPosition('left_center'); - -$mapTypeControl->setControlPosition(ControlPosition::LEFT_BOTTOM); -$mapTypeControl->setControlPosition('left_bottom'); - -$mapTypeControl->setControlPosition(ControlPosition::RIGHT_TOP); -$mapTypeControl->setControlPosition('right_top'); - -$mapTypeControl->setControlPosition(ControlPosition::RIGHT_CENTER); -$mapTypeControl->setControlPosition('right_center'); - -$mapTypeControl->setControlPosition(ControlPosition::RIGHT_BOTTOM); -$mapTypeControl->setControlPosition('right_bottom'); - -$mapTypeControl->setControlPosition(ControlPosition::BOTTOM_LEFT); -$mapTypeControl->setControlPosition('bottom_left'); - -$mapTypeControl->setControlPosition(ControlPosition::BOTTOM_CENTER); -$mapTypeControl->setControlPosition('bottom_center'); - -$mapTypeControl->setControlPosition(ControlPosition::BOTTOM_RIGHT); -$mapTypeControl->setControlPosition('bottom_right'); -``` - -## Configure the map type control style - -For configurating the map type control style, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\MapTypeControlStyle`` is here. It allows you to access all constants which describe map type -control style. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\MapTypeControl; -use Ivory\GoogleMap\Controls\MapTypeControlStyle; - -$mapTypeControl = new MapTypeControl(); - -// Sets your map type control style -$mapTypeControl->setMapTypeControlStyle(MapTypeControlStyle::DEFAULT_); -$mapTypeControl->setMapTypeControlStyle('default'); - -$mapTypeControl->setMapTypeControlStyle(MapTypeControlStyle::DROPDOWN_MENU); -$mapTypeControl->setMapTypeControlStyle('dropdown_menu'); - -$mapTypeControl->setMapTypeControlStyle(MapTypeControlStyle::HORIZONTAL_BAR); -$mapTypeControl->setMapTypeControlStyle('horizontal_bar'); -``` - -## Add your map type control to the map - -``` php -use Ivory\GoogleMapBundle\Model\MapTypeId; -use Ivory\GoogleMapBundle\Model\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControl; -use Ivory\GoogleMapBundle\Model\Controls\MapTypeControlStyle; - -$mapTypeControl = new MapTypeControl(); - -// Add your map type control to the map -$map->setMapTypeControl($mapTypeControl); -$map->setMapTypeControl( - array(MapTypeId::ROADMAP, MapTypeId::SATELLITE), - ControlPosition::TOP_RIGHT, - MapTypeControlStyle::DEFAULT_ -); -``` diff --git a/doc/usage/controls/overview.md b/doc/usage/controls/overview.md deleted file mode 100644 index d3c20ee0..00000000 --- a/doc/usage/controls/overview.md +++ /dev/null @@ -1,27 +0,0 @@ -# Overview map control - -The overview map control displays a thumbnail overview map reflecting the current map viewport within a wider area. -This control appears by default in the bottom right corner of the map, and is by default shown in its collapsed state. - -## Build your overview map control - -``` php -use Ivory\GoogleMap\Controls\OverviewMapControl; - -$overviewMapControl = new OverviewMapControl(); - -// Configure your overview map control -$overviewMapControl->setOpened(false); -``` - -## Add your overview map control to the map - -``` php -use Ivory\GoogleMap\Controls\OverviewMapControl; - -$overviewMapControl = new OverviewMapControl(); - -// Add your overview map control to the map -$map->setOverviewMapControl($overviewMapControl); -$map->setOverviewMapControl(false); -``` diff --git a/doc/usage/controls/pan.md b/doc/usage/controls/pan.md deleted file mode 100644 index 0a8c1218..00000000 --- a/doc/usage/controls/pan.md +++ /dev/null @@ -1,79 +0,0 @@ -# Pan control - -The Pan control displays buttons for panning the map. This control appears by default in the top left corner of the -map on non-touch devices. The Pan control also allows you to rotate 45° imagery, if available. - -## Build your pan control - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\PanControl; - -$panControl = new PanControl(); - -// Configure your pan control -$panControl->setControlPosition(ControlPosition::TOP_LEFT); -``` - -## Configure the pan control position - -For configurating the pan control position, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\ControlPosition`` is here. It allows you to access all constants which describe control -position. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\PanControl; - -$panControl = new PanControl(); - -// Sets your control position -$panControl->setControlPosition(ControlPosition::TOP_LEFT); -$panControl->setControlPosition('top_left'); - -$panControl->setControlPosition(ControlPosition::TOP_CENTER); -$panControl->setControlPosition('top_center'); - -$panControl->setControlPosition(ControlPosition::TOP_RIGHT); -$panControl->setControlPosition('top_right'); - -$panControl->setControlPosition(ControlPosition::LEFT_TOP); -$panControl->setControlPosition('left_top'); - -$panControl->setControlPosition(ControlPosition::LEFT_CENTER); -$panControl->setControlPosition('left_center'); - -$panControl->setControlPosition(ControlPosition::LEFT_BOTTOM); -$panControl->setControlPosition('left_bottom'); - -$panControl->setControlPosition(ControlPosition::RIGHT_TOP); -$panControl->setControlPosition('right_top'); - -$panControl->setControlPosition(ControlPosition::RIGHT_CENTER); -$panControl->setControlPosition('right_center'); - -$panControl->setControlPosition(ControlPosition::RIGHT_BOTTOM); -$panControl->setControlPosition('right_bottom'); - -$panControl->setControlPosition(ControlPosition::BOTTOM_LEFT); -$panControl->setControlPosition('bottom_left'); - -$panControl->setControlPosition(ControlPosition::BOTTOM_CENTER); -$panControl->setControlPosition('bottom_center'); - -$panControl->setControlPosition(ControlPosition::BOTTOM_RIGHT); -$panControl->setControlPosition('bottom_right'); -``` - -## Add your pan control to the map - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\PanControl; - -$panControl = new PanControl(); - -// Add your pan control to the map -$map->setPanControl($panControl); -$map->setPanControl(ControlPosition::TOP_LEFT); -``` diff --git a/doc/usage/controls/rotate.md b/doc/usage/controls/rotate.md deleted file mode 100644 index 028b1c48..00000000 --- a/doc/usage/controls/rotate.md +++ /dev/null @@ -1,79 +0,0 @@ -# Rotate control - -The Rotate control contains a small circular icon which allows you to rotate maps containing oblique imagery. This -control appears by default in the top left corner of the map. - -## Build your rotate control - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\RotateControl; - -$rotateControl = new RotateControl(); - -// Configure your rotate control -$rotateControl->setControlPosition(ControlPosition::TOP_LEFT); -``` - -## Configure the rotate control position - -For configurating the rotate control position, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\ControlPosition`` is here. It allows you to access all constants which describe control -position. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\RotateControl; - -$rotateControl = new RotateControl(): - -// Sets your control position -$rotateControl->setControlPosition(ControlPosition::TOP_LEFT); -$rotateControl->setControlPosition('top_left'); - -$rotateControl->setControlPosition(ControlPosition::TOP_CENTER); -$rotateControl->setControlPosition('top_center'); - -$rotateControl->setControlPosition(ControlPosition::TOP_RIGHT); -$rotateControl->setControlPosition('top_right'); - -$rotateControl->setControlPosition(ControlPosition::LEFT_TOP); -$rotateControl->setControlPosition('left_top'); - -$rotateControl->setControlPosition(ControlPosition::LEFT_CENTER); -$rotateControl->setControlPosition('left_center'); - -$rotateControl->setControlPosition(ControlPosition::LEFT_BOTTOM); -$rotateControl->setControlPosition('left_bottom'); - -$rotateControl->setControlPosition(ControlPosition::RIGHT_TOP); -$rotateControl->setControlPosition('right_top'); - -$rotateControl->setControlPosition(ControlPosition::RIGHT_CENTER); -$rotateControl->setControlPosition('right_center'); - -$rotateControl->setControlPosition(ControlPosition::RIGHT_BOTTOM); -$rotateControl->setControlPosition('right_bottom'); - -$rotateControl->setControlPosition(ControlPosition::BOTTOM_LEFT); -$rotateControl->setControlPosition('bottom_left'); - -$rotateControl->setControlPosition(ControlPosition::BOTTOM_CENTER); -$rotateControl->setControlPosition('bottom_center'); - -$rotateControl->setControlPosition(ControlPosition::BOTTOM_RIGHT); -$rotateControl->setControlPosition('bottom_right'); -``` - -## Add your rotate control to the map - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\RotateControl; - -$rotateControl = new RotateControl(); - -// Add your rotate control to the map -$map->setRotateControl($rotateControl); -$map->setRotateControl(ControlPosition::TOP_LEFT); -``` diff --git a/doc/usage/controls/scale.md b/doc/usage/controls/scale.md deleted file mode 100644 index 2db0e804..00000000 --- a/doc/usage/controls/scale.md +++ /dev/null @@ -1,97 +0,0 @@ -# Scale control - -The Scale control displays a map scale element. This control is not enabled by default. - -## Build your scale control - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ScaleControl; -use Ivory\GoogleMap\Controls\ScaleControlStyle; - -$scaleControl = new ScaleControl(); - -// Configure your scale control -$scaleControl->setControlPosition(ControlPosition::BOTTOM_LEFT); -$scaleControl->setScaleControlStyle(ScaleControlStyle::DEFAULT_); -``` - -## Configure your scale control position - -For configurating the pan control position, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\ControlPosition`` is here. It allows you to access all constants which describe control -position. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ScaleControl; - -$scaleControl = new ScaleControl(); - -// Sets your control position -$scaleControl->setControlPosition(ControlPosition::TOP_LEFT); -$scaleControl->setControlPosition('top_left'); - -$scaleControl->setControlPosition(ControlPosition::TOP_CENTER); -$scaleControl->setControlPosition('top_center'); - -$scaleControl->setControlPosition(ControlPosition::TOP_RIGHT); -$scaleControl->setControlPosition('top_right'); - -$scaleControl->setControlPosition(ControlPosition::LEFT_TOP); -$scaleControl->setControlPosition('left_top'); - -$scaleControl->setControlPosition(ControlPosition::LEFT_CENTER); -$scaleControl->setControlPosition('left_center'); - -$scaleControl->setControlPosition(ControlPosition::LEFT_BOTTOM); -$scaleControl->setControlPosition('left_bottom'); - -$scaleControl->setControlPosition(ControlPosition::RIGHT_TOP); -$scaleControl->setControlPosition('right_top'); - -$scaleControl->setControlPosition(ControlPosition::RIGHT_CENTER); -$scaleControl->setControlPosition('right_center'); - -$scaleControl->setControlPosition(ControlPosition::RIGHT_BOTTOM); -$scaleControl->setControlPosition('right_bottom'); - -$scaleControl->setControlPosition(ControlPosition::BOTTOM_LEFT); -$scaleControl->setControlPosition('bottom_left'); - -$scaleControl->setControlPosition(ControlPosition::BOTTOM_CENTER); -$scaleControl->setControlPosition('bottom_center'); - -$scaleControl->setControlPosition(ControlPosition::BOTTOM_RIGHT); -$scaleControl->setControlPosition('bottom_right'); -``` - -## Configure your scale control style - -For configurating the scale control style, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\ScaleControlStyle`` is here. It allows you to access all constants which describe scale -control style. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\ScaleControl; -use Ivory\GoogleMap\Controls\ScaleControlStyle; - -$scaleControl = new ScaleControl(); - -// Sets your scale control style -$scaleControl->setScaleControlStyle(ScaleControlStyle::DEFAULT_); -``` - -## Add your scale control to the map - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ScaleControl; -use Ivory\GoogleMap\Controls\ScaleControlStyle; - -$scaleControl = new ScaleControl(); - -// Add your scale control to the map -$map->setScaleControl($scaleControl); -$map->setScaleControl(ControlPosition::BOTTOM_LEFT, ScaleControlStyle::DEFAULT_); -``` diff --git a/doc/usage/controls/street_view.md b/doc/usage/controls/street_view.md deleted file mode 100644 index 9101a3b0..00000000 --- a/doc/usage/controls/street_view.md +++ /dev/null @@ -1,79 +0,0 @@ -# Street view control - -The Street View control contains a Pegman icon which can be dragged onto the map to enable Street View. This control -appears by default in the top left corner of the map. - -## Build your street view control - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\StreetViewControl; - -$streetViewControl = new StreetViewControl(); - -// Configure your street view control -$streetViewControl->setControlPosition(ControlPosition::TOP_LEFT); -``` - -## Configure the street view control position - -For configurating the street view control position, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\ControlPosition`` is here. It allows you to access all constants which describe control -position. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\StreetViewControl; - -$streetViewControl = new StreetViewControl(); - -// Sets your control position -$streetViewControl->setControlPosition(ControlPosition::TOP_LEFT); -$streetViewControl->setControlPosition('top_left'); - -$streetViewControl->setControlPosition(ControlPosition::TOP_CENTER); -$streetViewControl->setControlPosition('top_center'); - -$streetViewControl->setControlPosition(ControlPosition::TOP_RIGHT); -$streetViewControl->setControlPosition('top_right'); - -$streetViewControl->setControlPosition(ControlPosition::LEFT_TOP); -$streetViewControl->setControlPosition('left_top'); - -$streetViewControl->setControlPosition(ControlPosition::LEFT_CENTER); -$streetViewControl->setControlPosition('left_center'); - -$streetViewControl->setControlPosition(ControlPosition::LEFT_BOTTOM); -$streetViewControl->setControlPosition('left_bottom'); - -$streetViewControl->setControlPosition(ControlPosition::RIGHT_TOP); -$streetViewControl->setControlPosition('right_top'); - -$streetViewControl->setControlPosition(ControlPosition::RIGHT_CENTER); -$streetViewControl->setControlPosition('right_center'); - -$streetViewControl->setControlPosition(ControlPosition::RIGHT_BOTTOM); -$streetViewControl->setControlPosition('right_bottom'); - -$streetViewControl->setControlPosition(ControlPosition::BOTTOM_LEFT); -$streetViewControl->setControlPosition('bottom_left'); - -$streetViewControl->setControlPosition(ControlPosition::BOTTOM_CENTER); -$streetViewControl->setControlPosition('bottom_center'); - -$streetViewControl->setControlPosition(ControlPosition::BOTTOM_RIGHT); -$streetViewControl->setControlPosition('bottom_right'); -``` - -## Add your street view control to the map - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\StreetViewControl; - -$streetViewControl = new StreetViewControl(); - -// Add your street view control to the map -$map->setStreetViewControl($streetViewControl); -$map->setStreetViewControl(ControlPosition::TOP_LEFT); -``` diff --git a/doc/usage/controls/zoom.md b/doc/usage/controls/zoom.md deleted file mode 100644 index e5cf2ec1..00000000 --- a/doc/usage/controls/zoom.md +++ /dev/null @@ -1,106 +0,0 @@ -# Zoom control - -The Zoom control displays a slider (for large maps) or small "+/-" buttons (for small maps) to control the zoom level -of the map. This control appears by default in the top left corner of the map on non-touch devices or in the bottom -left corner on touch devices. - -## Build your zoom control - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ZoomControl; -use Ivory\GoogleMap\Controls\ZoomControlStyle; - -$zoomControl = new ZoomControl(); - -// Configure your zoom control -$zoomControl->setControlPosition(ControlPosition::TOP_LEFT); -$zoomControl->setZoomControlStyle(ZoomControlStyle::DEFAULT_); -``` - -## Configure your zoom control position - -For configurating the zoom control position, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\ControlPosition`` is here. It allows you to access all constants which describe control -position. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ZoomControl; - -$zoomControl = new ZoomControl(); - -// Sets your control position -$zoomControl->setControlPosition(ControlPosition::TOP_LEFT); -$zoomControl->setControlPosition('top_left'); - -$zoomControl->setControlPosition(ControlPosition::TOP_CENTER); -$zoomControl->setControlPosition('top_center'); - -$zoomControl->setControlPosition(ControlPosition::TOP_RIGHT); -$zoomControl->setControlPosition('top_right'); - -$zoomControl->setControlPosition(ControlPosition::LEFT_TOP); -$zoomControl->setControlPosition('left_top'); - -$zoomControl->setControlPosition(ControlPosition::LEFT_CENTER); -$zoomControl->setControlPosition('left_center'); - -$zoomControl->setControlPosition(ControlPosition::LEFT_BOTTOM); -$zoomControl->setControlPosition('left_bottom'); - -$zoomControl->setControlPosition(ControlPosition::RIGHT_TOP); -$zoomControl->setControlPosition('right_top'); - -$zoomControl->setControlPosition(ControlPosition::RIGHT_CENTER); -$zoomControl->setControlPosition('right_center'); - -$zoomControl->setControlPosition(ControlPosition::RIGHT_BOTTOM); -$zoomControl->setControlPosition('right_bottom'); - -$zoomControl->setControlPosition(ControlPosition::BOTTOM_LEFT); -$zoomControl->setControlPosition('bottom_left'); - -$zoomControl->setControlPosition(ControlPosition::BOTTOM_CENTER); -$zoomControl->setControlPosition('bottom_center'); - -$zoomControl->setControlPosition(ControlPosition::BOTTOM_RIGHT); -$zoomControl->setControlPosition('bottom_right'); -``` - -## Configure your zoom control style - -For configurating the zoom control style, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Controls\ZoomControlStyle`` is here. It allows you to access all constants which describe zoom -control style. If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Controls\ZoomControl; -use Ivory\GoogleMap\Controls\ZoomControlStyle; - -$zoomControl = new ZoomControl(); - -// Sets your zoom control style -$zoomControl->setZoomControlStyle(ZoomControlStyle::DEFAULT_); -$zoomControl->setZoomControlStyle('default'); - -$zoomControl->setZoomControlStyle(ZoomControlStyle::LARGE); -$zoomControl->setZoomControlStyle('large'); - -$zoomControl->setZoomControlStyle(ZoomControlStyle::SMALL); -$zoomControl->setZoomControlStyle('small'); -``` - -## Add your zoom control to the map - -``` php -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ZoomControl; -use Ivory\GoogleMap\Controls\ZoomControlStyle; - -$zoomControl = new ZoomControl(); - -// Add your zoom control to the map -$map->setZoomControl($zoomControl); -$map->setZoomControl(ControlPosition::TOP_LEFT, ZoomControlStyle::DEFAULT_); -``` diff --git a/doc/usage/events.md b/doc/usage/events.md deleted file mode 100644 index 00e93f66..00000000 --- a/doc/usage/events.md +++ /dev/null @@ -1,76 +0,0 @@ -# Events - -JavaScript within the browser is event driven, meaning that JavaScript responds to interactions by generating events, -and expects a program to listen to interesting events. The event model for the Google Maps API V3 is similar to that -used in V2 of the API, though much has changed under the hood. There are two types of events: - - - User events (such as "click" mouse events) are propagated from the DOM to the Google Maps API. These events are - separate and distinct from standard DOM events. - - MVC state change notifications reflect changes in Maps API objects and are named using a property_changed convention. - -## Build your event - -``` php -use Ivory\GoogleMap\Events\Event; - -$event = new Event(); - -// Configure your event -$event->setInstance($instance); -$event->setEventName($eventName); -$event->setHandle($handle); - -// It can only be used with a DOM event -// By default, the capture flag is false -$event->setCapture(true); -``` - -### Instance - -The ``$instance`` variable describes the javascript variable which registers the event. Each Ivory google map objects -which can register an event have a method called ``getJavascriptVariable`` which identifies this variable. - -For example, in the case of an info window, it can be: - -``` php -$instance = $infoWindow->getJavascriptVariable(); -``` - -### Event name - -Each object has his own event name which are described in the google map documentation. - -### Handle - -The ``$handle`` is the javascript function which is executed when the event is triggered. - -For example, it can be: - -``` php -$handle = 'function(){alert("The event has been triggered");}' -``` - -## Add your event to the map - -The map wraps an event manager which allows you to add events. Like describes in the introduction, two differents type -of event can be used. - -### DOM event - -``` php -// Add a DOM event -$map->getEventManager()->addDomEvent($event); - -// Add a DOM event which will be triggered only one time -$map->getEventManager()->addDomEventOnce($event); -``` - -### MVC event - -``` php -// Add an event -$map->getEventManager()->addEvent($event); - -// Add an event which will be triggered only one time -$map->getEventManager()->addEventOnce($event); -``` diff --git a/doc/usage/helper/container.md b/doc/usage/helper/container.md deleted file mode 100644 index 604e8668..00000000 --- a/doc/usage/helper/container.md +++ /dev/null @@ -1,78 +0,0 @@ -# JS Container - -When you call `$mapHelper->renderJavascripts($map)`, the library will generate for you all needed JS code for -displaying your map. Obviously, it is not the anarchy, all the sheet is organized in order to reuse created objects in -the client side (your JS scripts). - -As explain in the doc, a map has a javascript variable which is used to render the code. For example, you have a -map with `my_map` as javascript variable, then the output will be: - -``` -my_map = new new google.maps.Map(/* ... */); -``` - -There is many objects which have a javascript variable (coordinates, markers, etc). All these objects are rendered like -a map (except for the instanciation part :)). So, you can use every objects though his javascript variable. - -Additionally, a container is builded for each map in order to more easily reuse all the related objects of a map -instead of directly relying on each javascript variable. For a map named `my_map`, the output will be: - -``` -my_map_container = { - // Base - "coordinates": {}, - "bounds": {}, - "points: {}, - "sizes": {}, - - // Map - map: null, - - // Overlays - "circles": {}, - "encoded_polylines": {}, - "ground_overlays": {}, - "polygons": {}, - "polylines": {}, - "rectangles": {}, - "info_windows": {}, - "marker_images": {}, - "marker_shapes": {}, - "markers": {}, - "marker_cluster": null, - - // Layers - "kml_layers": {}, - - // Event Manager - "event_manager": { - "dom_events": {}, - "dom_events_once": {}, - "events": {}, - "events_once": {} - }, - - // Internal - "closable_info_windows": {} - "functions": { - "to_array": function { /* ... */ } - } -} -``` - -Each objects is aliased by his javascript variable in the container. If you have a circle named "my_circle", then you -can access it like that: - -``` -var my_circle = my_map_container.circles.my_circle; -``` - -If you want to iterate all markers on you map, you can easily archieve it: - -``` -for (marker in my_map_container.markers) { - var my_marker = my_map_container.markers[marker]; - - // Do what you want with your marker... -} -``` diff --git a/doc/usage/helper/extension.md b/doc/usage/helper/extension.md deleted file mode 100644 index d6e22ebe..00000000 --- a/doc/usage/helper/extension.md +++ /dev/null @@ -1,70 +0,0 @@ -# Extension - -An extension helper allows you to add/render additional libraries and/or append some javascript code just before/after -the generated one. To understand how it works, you will dig into a simple example. - -First, you need to create your own extension: - -``` php -namespace My\Own\Helper\Extension; - -use Ivory\GoogleMap\Helper\Extension\ExtensionHelperInterface; -use Ivory\GoogleMap\Map; - -class MyExtensionHelper implements ExtensionHelperInterface -{ - /** - * {@inheritdoc} - */ - public function renderLibraries(Map $map) - { - // Here, we can render additional libraries... - return ''.PHP_EOL; - } - - /** - * {@inheritdoc} - */ - public function renderBefore(Map $map) - { - // Here, we can render js code just before the generated one. - return 'var before = \'before\''.PHP_EOL; - } - - /** - * {@inheritdoc} - */ - public function renderAfter(Map $map) - { - // Here, we can render js code just after the generated one. - return 'var after = \'after\''.PHP_EOL; - } -} -``` - -Then, you need to register you extension on the map helper & simply render your map: - -``` php -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Helper\MapHelper; -use My\Own\Helper\Extension\MyExtensionHelper; - -$mapHelper = new MapHelper(); -$mapHelper->setExtensionHelper('my_extension', new MyExtensionHelper()); - -$map = new Map(); - -$output = $mapHelper->renderJavascripts($map); -``` - -The output will be: - -``` html -// Google map loading... - - -``` diff --git a/doc/usage/layers/index.md b/doc/usage/layers/index.md deleted file mode 100644 index 723225dc..00000000 --- a/doc/usage/layers/index.md +++ /dev/null @@ -1,7 +0,0 @@ -# Google Map Layers - - 1. [KML Layer](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/layers/kml_layer.md) - 2. Fusion Table Layer - 3. Traffic Layer - 4. Bicycling Layer - 5. Panorama Layer diff --git a/doc/usage/layers/kml_layer.md b/doc/usage/layers/kml_layer.md deleted file mode 100644 index 6dfc4be4..00000000 --- a/doc/usage/layers/kml_layer.md +++ /dev/null @@ -1,33 +0,0 @@ -# KML Layer - -The Google Maps API supports the KML and GeoRSS data formats for displaying geographic information. For more -information, see official [documentation](http://code.google.com/apis/maps/documentation/javascript/layers.html#KMLLayers). - -## Build your KML layer - -``` php -use Ivory\GoogleMap\Layers\KMLLayer; - -$kmlLayer = new KMLLayer(); - -// Configure your KML layer options -$kmlLayer->setUrl('http://www.domain.com/kml_layer.kml'); - -$kmlLayer->setOption('clickable', true); -$kmlLayer->setOption('suppressInfoWindows', false); -$kmlLayer->setOptions(array( - 'clickable' => true, - 'suppressInfoWindows' => false, -)); -``` - -## Add your KML layer to the map - -``` php -use Ivory\GoogleMap\Layers\KMLLayer; - -$kmlLayer = new KMLLayer(); - -// Add your KML layer to the map -$map->addKMLLayer($kmlLayer); -``` diff --git a/doc/usage/map.md b/doc/usage/map.md deleted file mode 100644 index 78e46aa5..00000000 --- a/doc/usage/map.md +++ /dev/null @@ -1,184 +0,0 @@ -# Map - -## Build your map - -``` php -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\MapTypeId; - -$map = new Map(); - -$map->setPrefixJavascriptVariable('map_'); -$map->setHtmlContainerId('map_canvas'); - -$map->setAsync(false); -$map->setAutoZoom(false); - -$map->setCenter(0, 0, true); -$map->setMapOption('zoom', 3); - -$map->setBound(-2.1, -3.9, 2.6, 1.4, true, true); - -$map->setMapOption('mapTypeId', MapTypeId::ROADMAP); -$map->setMapOption('mapTypeId', 'roadmap'); - -$map->setMapOption('disableDefaultUI', true); -$map->setMapOption('disableDoubleClickZoom', true); -$map->setMapOptions(array( - 'disableDefaultUI' => true, - 'disableDoubleClickZoom' => true, -)); - -$map->setStylesheetOption('width', '300px'); -$map->setStylesheetOption('height', '300px'); -$map->setStylesheetOptions(array( - 'width' => '300px', - 'height' => '300px', -)); - -$map->setLanguage('en'); -``` - -## Configure map center & zoom - -For configurating the map center & zoom, you have three possibilities: - - 1. Standard center coordinate & zoom - 2. Fitting a bound - 3. Fitting a bound which extends overlays - -### Standard center coordinate & zoom - -To use the standard center coordinate & zoom, you need to disable the auto zoom flag & configure the center/zoom. - -``` php -use Ivory\GoogleMap\Map; - -$map = new Map(); - -// Disable the auto zoom flag -$map->setAutoZoom(false); - -// Sets the center -$map->setCenter(0, 0, true); - -// Sets the zoom -$map->setMapOption('zoom', 3); -``` - -### Fitting a bound - -For fitting a bound, you need to enable the auto zoom flag & configure bound south west & nort east coordinates. -If you extend overlays with the bound, the map will fit the overlays coordinate instead of bound coordinates. - -``` php -use Ivory\GoogleMap\Map; - -$map = new Map(); - -// Enable the auto zoom flag -$map->setAutoZoom(true); - -// Sets the bound coordinates -$map->setBound(-2.1, -3.9, 2.6, 1.4, true, true); -``` - -### Fitting a bound which extends overlays - -For fitting a bound which extends overlays, you need to enable the auto zoom flag & add overlays to the bound. -In the [overlays documentation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/index.md), -you learn how you can add overlays to the map. If the auto zoom flag is enabled and you add some overlays to the map, -the map bound will automatically extends your overlay. So, at the end, all your overlays will be visible on your sreen. - -``` php -use Ivory\GoogleMap\Map, - Ivory\GoogleMap\Overlays\Marker; - -$map = new Map(); - -// Enable the auto zoom flag -$map->setAutoZoom(true); - -// Add marker overlay to your map -$map->addMarker(new Marker()); -``` - -## Configure map type - -For configurating the map type, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\MapTypeId`` is here. It allows you to access all constants which describe map types. If you don't -want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\MapTypeId; - -$map = new Map(); - -// Sets your map type -$map->setMapOption('mapTypeId', MapTypeId::HYBRID); -$map->setMapOption('mapTypeId', 'hybrid'); - -$map->setMapOption('mapTypeId', MapTypeId::ROADMAP); -$map->setMapOption('mapTypeId', 'roadmap'); - -$map->setMapOption('mapTypeId', MapTypeId::SATELLITE); -$map->setMapOption('mapTypeId', 'satellite'); - -$map->setMapOption('mapTypeId', MapTypeId::TERRAIN); -$map->setMapOption('mapTypeId', 'terrain'); -``` - -## Loading map asynchronously - -For loading the map asynchronously, you need to set the async property to true. Enabling this feature the map will load -asynchronously, allowing you to load the map through AJAX. To do this, the javascript code is wrapped by a function -called ``load_ivory_google_map`` and the script responsible to load Google API adds the ``callback`` parameter with -this value. - -``` php -use Ivory\GoogleMap\Map; - -$map = new Map(); -$map->setAsync(true); -``` - -The helper renders an html javascript block with all code needed for displaying your map wrapped in the -``load_ivory_google_map`` function. - -``` html - -``` - -## Add overlays to your map - -Overlays are objects on the map that are tied to latitude/longitude coordinates, so they move when you drag or zoom the map. -Overlays reflect objects that you "add" to the map to designate points, lines, areas, or collections of objects. - - 1. [Marker](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker.md) - 2. [Info window](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/info_window.md) - 3. [Polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polyline.md) - 4. [EncodedPolyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/encoded_polyline.md) - 5. [Polygon](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polygon.md) - 6. [Rectangle](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/rectangle.md) - 7. [Circle](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/circle.md) - 8. [Ground overlay](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/ground_overlay.md) - 9. [Marker cluster](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker_cluster.md) - -## Configure map control options - -The maps on Google Maps contain UI elements for allowing user interaction through the map. -These elements are known as controls and you can include variations of these controls in your Google Maps API application. -Alternatively, you can do nothing and let the Google Maps API handle all control behavior. - - 1. [Map type](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/map_type.md) - 2. [Overview](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/overview.md) - 3. [Pan](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/pan.md) - 4. [Rotate](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/rotate.md) - 5. [Scale](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/scale.md) - 6. [Street view](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/street_view.md) - 7. [Zoom](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/controls/zoom.md) diff --git a/doc/usage/overlays/circle.md b/doc/usage/overlays/circle.md deleted file mode 100644 index 68440b1e..00000000 --- a/doc/usage/overlays/circle.md +++ /dev/null @@ -1,37 +0,0 @@ -# Circle - -A Circle is similar to a Polygon in that you can define custom colors, weights, and opacities for the edge of the -circle (the "stroke") and custom colors and opacities for the area within the enclosed region (the "fill"). Unlike a -Polygon, you do not define paths for a Circle. Instead, a circle has two additional properties which define its shape: -center of the circle, radius of the circle, in meters. - -## Build your circle - -``` php -use Ivory\GoogleMap\Overlays\Circle; - -$circle = new Circle(); - -// Configure your circle options -$circle->setPrefixJavascriptVariable('circle_'); -$circle->setCenter(0, 0, true); -$circle->setRadius(1); - -$circle->setOption('clickable', false); -$circle->setOption('strokeWeight', 2); -$circle->setOptions(array( - 'clickable' => false, - 'strokeWeight' => 2, -)); -``` - -## Add your circle to the map - -``` php -use Ivory\GoogleMap\Overlays\Circle; - -$circle = new Circle(); - -// Add your circle to the map -$map->addCircle($circle); -``` diff --git a/doc/usage/overlays/encoded_polyline.md b/doc/usage/overlays/encoded_polyline.md deleted file mode 100644 index 2a187aec..00000000 --- a/doc/usage/overlays/encoded_polyline.md +++ /dev/null @@ -1,36 +0,0 @@ -# Encoded Polyline - -The Encoded Polyline class defines a [Polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polyline.md) -which has been encoded using the algorithm described -[here](http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html). - -## Build your encoded polyline - -``` php -use Ivory\GoogleMap\Overlays\EncodedPolyline; - -$encodedPolyline = new EncodedPolyline(); - -// Configure your encoded polyline options -$polyline->setPrefixJavascriptVariable('polyline_'); - -$encodedPolyline->setValue('encoded_polyline_value'); - -$polyline->setOption('geodesic', true); -$polyline->setOption('strokeColor', '#ffffff'); -$polyline->setOptions(array( - 'geodesic' => true, - 'strokeColor' => '#ffffff', -)); -``` - -## Add your encoded polyline to the map - -``` php -use Ivory\GoogleMap\Overlays\EncodedPolyline; - -$encodedPolyline = new EncodedPolyline(); - -// Add your encoded polyline to the map -$map->addEncodedPolyline($encodedPolyline); -``` diff --git a/doc/usage/overlays/ground_overlay.md b/doc/usage/overlays/ground_overlay.md deleted file mode 100644 index 9078da75..00000000 --- a/doc/usage/overlays/ground_overlay.md +++ /dev/null @@ -1,31 +0,0 @@ -# Ground overlay - -Polygons are useful overlays to represent arbitrarily-sized areas, but they cannot display images. If you have an image -that you wish to place on a map, you can use a GroundOverlay object. - -## Build your ground overlay - -``` php -use Ivory\GoogleMap\Overlays\GroundOverlay; - -$groundOverlay = new GroundOverlay(); - -// Configure your ground overlay options -$groundOverlay->setPrefixJavascriptVariable('ground_overlay_'); -$groundOverlay->setUrl('url'); -$groundOverlay->setBound(-1, -1, 1, 1, true, true); - -$groundOverlay->setOption('clickable', false); -$groundOverlay->setOptions(array('clickable' => false)); -``` - -## Add your ground overlay to the map - -``` php -use Ivory\GoogleMap\Overlays\GroundOverlay; - -$groundOverlay = new GroundOverlay(); - -// Add your ground overlay to the map -$map->addGroundOverlay($groundOverlay); -``` diff --git a/doc/usage/overlays/index.md b/doc/usage/overlays/index.md deleted file mode 100644 index 4de369bd..00000000 --- a/doc/usage/overlays/index.md +++ /dev/null @@ -1,15 +0,0 @@ -# Overlays - -Overlays are objects on the map that are tied to latitude/longitude coordinates, so they move when you drag or zoom the -map. Overlays reflect objects that you "add" to the map to designate points, lines, areas, or collections of objects. - - 1. [Marker](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker.md) - 2. [Info window](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/info_window.md) - 3. [Info box](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/info_box.md) - 4. [Polyline](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polyline.md) - 5. [Encoded Polyline]((http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/encoded_polyline.md) - 6. [Polygon](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/polygon.md) - 7. [Rectangle](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/rectangle.md) - 8. [Circle](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/circle.md) - 9. [Ground overlay](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/ground_overlay.md) - 10. [Marker cluster](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker_cluster.md) diff --git a/doc/usage/overlays/info_box.md b/doc/usage/overlays/info_box.md deleted file mode 100644 index e85074dc..00000000 --- a/doc/usage/overlays/info_box.md +++ /dev/null @@ -1,39 +0,0 @@ -# Info box - -Info box displays content in a floating window above the map. Basically, it is the same as an -[info window](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/info_window.md) but through a -different implementation. The Ivory Google Map library allows you to easily use this implementation by simply replacing -the info window helper & registering a new [extension helper](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/helper/extension.md). - -So, on the map side, nothing change, you can still use an `InfoWindow`: - -``` php -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\InfoWindow; - -$map = new Map(); - -$infoWindow = new InfoWindow(); -$infoWindow->setPosition(1.1, 2.1); - -$map->addInfoWindow($infoWindow); -``` - -Now, to render the info window as info box, you need to replace the info window helper by the info box helper & -register the info box helper extension: - -``` php -use Ivory\GoogleMap\Helper\Extension\InfoBoxExtensionHelper; -use Ivory\GoogleMap\Helper\MapHelper; -use Ivory\GoogleMap\Helper\Overlays\InfoBoxHelper; - -// Configure your map... - -$mapHelper = new MapHelper(); -$mapHelper->setInfoWindowHelper(new InfoBoxHelper()); -$mapHelper->setExtensionHelper('info_box', new InfoBoxExtensionHelper()); - -$output = $mapHelper->render($map); -``` - -The map output will wrap InfoBox objects instead of the InfoWindow ones. diff --git a/doc/usage/overlays/info_window.md b/doc/usage/overlays/info_window.md deleted file mode 100644 index f73bed62..00000000 --- a/doc/usage/overlays/info_window.md +++ /dev/null @@ -1,82 +0,0 @@ -# Info window - -Info window displays content in a floating window above the map. The info window looks a little like a comic-book word -balloon. It has a content area and a tapered stem, where the tip of the stem is at a specified location on the map. - -## Build your info window - -``` php -use Ivory\GoogleMap\Overlays\InfoWindow; - -$infoWindow = new InfoWindow(); - -// Configure your info window options -$infoWindow->setPrefixJavascriptVariable('info_window_'); -$infoWindow->setPosition(0, 0, true); -$infoWindow->setPixelOffset(1.1, 2.1, 'px', 'pt'); -$infoWindow->setContent('

Default content

'); -$infoWindow->setOpen(false); -$infoWindow->setAutoOpen(true); -$infoWindow->setOpenEvent(MouseEvent::CLICK); -$infoWindow->setAutoClose(false); -$infoWindow->setOption('disableAutoPan', true); -$infoWindow->setOption('zIndex', 10); -$infoWindow->setOptions(array( - 'disableAutoPan' => true, - 'zIndex' => 10, -)); -``` - -## Add your info window to the map - -``` php -use Ivory\GoogleMap\Overlays\InfoWindow; - -$infoWindow = new InfoWindow(); - -// Add your info window to the map -$map->addInfoWindow($infoWindow); -``` - -## Add your info window to a marker - -``` php -use Ivory\GoogleMap\Overlays\InfoWindow; - -$infoWindow = new InfoWindow(); - -// Add your info window to the marker -$marker->setInfoWindow($infoWindow); -``` - -## Configure info window open event - -For configurating the info window open event, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Events\MouseEvent`` is here. It allows you to access all constants which describe open event. If you -don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Events\MouseEvent; -use Ivory\GoogleMap\Overlays\InfoWindow; - -$infoWindow = new InfoWindow(); - -// Sets your open event -$infoWindow->setOpenEvent(MouseEvent::CLICK); -$infoWindow->setOpenEvent('click'); - -$infoWindow->setOpenEvent(MouseEvent::DBLCLICK); -$infoWindow->setOpenEvent('dblclick'); - -$infoWindow->setOpenEvent(MouseEvent::MOUSEUP); -$infoWindow->setOpenEvent('mouseup'); - -$infoWindow->setOpenEvent(MouseEvent::MOUSEDOWN); -$infoWindow->setOpenEvent('mousedown'); - -$infoWindow->setOpenEvent(MouseEvent::MOUSEOVER); -$infoWindow->setOpenEvent('mouseover'); - -$infoWindow->setOpenEvent(MouseEvent::MOUSEOUT); -$infoWindow->setOpenEvent('mouseout'); -``` diff --git a/doc/usage/overlays/marker.md b/doc/usage/overlays/marker.md deleted file mode 100644 index b5af9679..00000000 --- a/doc/usage/overlays/marker.md +++ /dev/null @@ -1,126 +0,0 @@ -# Marker - -Markers identify locations on the map. By default, they use a standard icon. - -## Build your marker - -``` php -use Ivory\GoogleMap\Overlays\Animation; -use Ivory\GoogleMap\Overlays\Marker; - -$marker = new Marker(); - -// Configure your marker options -$marker->setPrefixJavascriptVariable('marker_'); -$marker->setPosition(0, 0, true); -$marker->setAnimation(Animation::DROP); - -$marker->setOption('clickable', false); -$marker->setOption('flat', true); -$marker->setOptions(array( - 'clickable' => false, - 'flat' => true, -)); -``` - -## Configure marker animation - -For configurating the marker animation, the better way is to follow the oriented object way. For that, the -``Ivory\GoogleMap\Overlays\Animation`` is here. It allows you to access all constants which describe marker animation. -If you don't want to use this class, you can directly use the constant value. - -``` php -use Ivory\GoogleMap\Overlays\Animation; -use Ivory\GoogleMap\Overlays\Marker; - -$marker = new Marker(); - -// Sets your marker animation -$marker->setAnimation(Animation::BOUNCE); -$marker->setAnimation('bounce'); - -$marker->setAnimation(Animation::DROP); -$marker->setAnimation('drop'); -``` - -## Configure marker icon - -By default, the marker uses a standard icon. If you want to change this icon, two ways are available. You can use an -icon url or a marker image. The first solution is appropriated if you build an icon which doesn't need any specific -configuration (anchor, origin, size or scaled size). If you want to build an advanced icon, you must use the marker -image. - -### Configure marker icon URL - -``` php -use Ivory\GoogleMap\Overlays\Marker; - -$marker = new Marker(); - -// Sets the icon URL -$marker->setIcon('http://maps.gstatic.com/mapfiles/markers/marker.png'); -``` - -### Configure marker image - -The complete marker image configuration is available -[here](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker_image.md). - -``` php -use Ivory\GoogleMap\Overlays\Marker; - -$marker = new Marker(); - -// Sets the marker image -$marker->setIcon($markerImage); -``` - -## Configure marker shadow - -Like marker icon, the marker uses a standard shadow but if you want to change this shadow, two ways are available. You -can use a shadow url or a marker image. The first solution is appropriated if you build a shadow which doesn't need any -specific configuration (anchor, origin, size or scaled size). If you want to build an advanced shadow, you must use the -marker image. - -### Configure shadow URL - -``` php -use Ivory\GoogleMap\Overlays\Marker; - -$marker = new Marker(); - -// Sets the shadow URL -$marker->setShadow('http://maps.gstatic.com/mapfiles/markers/marker.png'); -``` - -### Configure marker image - -The complete marker image configuration is available -[here](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker_image.md). - -``` php -use Ivory\GoogleMap\Overlays\Marker; - -$marker = new Marker(); - -// Sets the marker image -$marker->setShadow($markerImage); -``` - -## Configure marker shape - -The complete marker shape configuration is available -[here](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/overlays/marker_shape.md). - -## Add your marker to the map - -Now you have configurated your marker, you need to add it to the map. - -``` php -use Ivory\GoogleMap\Overlays\Marker; - -$marker = new Marker(); - -// Add your marker to the map -$map->addMarker($marker); -``` diff --git a/doc/usage/overlays/marker_cluster.md b/doc/usage/overlays/marker_cluster.md deleted file mode 100644 index 6e8657fa..00000000 --- a/doc/usage/overlays/marker_cluster.md +++ /dev/null @@ -1,116 +0,0 @@ -# Marker Cluster - -Some applications are required to display a large number of locations or markers. Despite the v3 JavaScript API's -significant improvement to performance, naively plotting thousands of markers on a map can quickly lead to to a -degraded user experience. Too many markers on the map cause both visual overload and sluggish interaction with the map. -To overcome this poor performance, the information displayed on the map needs to be simplified, we need a marker -clustering solution. - -The library provides one which can be easily used & extended :) - -In fact, when you use a marker in your map, internally, a marker cluster is used. A map always manages markers with a -marker cluster. Then, a marker cluster is a simple object which stores a type, markers & options: - -``` php -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\MarkerCluster; - -$map = new Map(); - -$markerCluster = $map->getMarkerCluster(); -$map->setMarkerCluster($markerCluster); - -$type = $markerCluster->getType(); -$markers = $markerCluster->getMarkers(); -$options = $markerCluster->getOptions(); -``` - -## Default Marker Cluster - -The default marker cluster is the marker cluster which does nothing... As a map has always a marker cluster, this -implementation allows to fallback on the default google map behavior. To enable it: - -``` php -use Ivory\GoogleMap\Overlays\MarkerCluster; - -$markerCluster->setType(MarkerCluster::_DEFAULT); -$markerCluster->setType('default'); -``` - -## Javascript Marker Cluster - -The javascript marker cluster provides a [MarkerCluster](http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html) -integration. To enable it: - -``` php -use Ivory\GoogleMap\Overlays\MarkerCluster; - -$markerCluster->setType(MarkerCluster::MARKER_CLUSTER); -$markerCluster->setType('marker_cluster'); -``` - -As this library can be configured, you can use options for that: - -``` php -$markerCluster->setOption('gridSize', 50); -$markerCluster->setOption('maxZoom', 15); -``` - -## Create your own marker cluster - -As explain in the introduction, the marker cluster can be easily extended, meaning your can manage yourself the -clustering. So, first step is create your own implementation: - -``` php -namespace Acme\GoogleMap; - -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Helper\Overlays\MarkerCluster\AbstractMarkerClusterHelper; -use Ivory\GoogleMap\Overlays\MarkerCluster; - -class MyFuckingMarkerClusterHelper extends AbstractMarkerClusterHelper -{ - /** - * {@inheritdoc} - */ - public function render(MarkerCluster $markerCluster, Map $map) - { - // Your implementation - } - - /** - * {@inheritdoc} - */ - public function renderMarkers(MarkerCluster $markerCluster, Map $map) - { - // Your implementation - } - - /** - * {@inheritdoc} - */ - public function renderLibraries(MarkerCluster $markerCluster, Map $map) - { - // Your implementation - } -} -``` - -After, you must register your marker cluster helper: - -``` php -use Acme\GoogleMap\MyFuckingMarkerClusterHelper; -use Ivory\GoogleMap\Helper\MapHelper; - -$mapHelper = new MapHelper(); -$markerClusterHelper = new MyFuckingMarkerClusterHelper(); - -$mapHelper->getMarkerClusterHelper()->addHelper('my_helper', $markerClusterHelper); -``` - -Then, just use it: - -``` php -$map = new Map(); -$map->getMarkerCluster()->setType('my_helper'); -``` diff --git a/doc/usage/overlays/marker_image.md b/doc/usage/overlays/marker_image.md deleted file mode 100644 index c067aede..00000000 --- a/doc/usage/overlays/marker_image.md +++ /dev/null @@ -1,46 +0,0 @@ -# Marker image (Equivalent to marker icon & marker shape) - -Markers may define an icon to show in place of the default icon or a shadow to shown in place of the default shadow. -Defining an icon or a shadow involves setting a number of properties that define the visual behavior of the marker. - -## Build your marker image - -``` php -use Ivory\GoogleMap\Overlays\MarkerImage; - -$markerImage = new MarkerImage(); - -// Configure your marker image options -$markerImage->setPrefixJavascriptVariable('marker_image_'); -$markerImage->setUrl('http://maps.gstatic.com/mapfiles/markers/marker.png'); -$markerImage->setAnchor(20, 34); -$markerImage->setOrigin(0, 0); -$markerImage->setSize(20, 34, "px", "px"); -$markerImage->setScaledSize(20, 34, "px", "px"); -``` - -## Add your marker image to a marker - -Now you have configurated your marker image, you need to add it like an icon or a shadow to your marker. - -### Adds the marker image to a marker as icon - -``` php -use Ivory\GoogleMap\Overlays\MarkerImage; - -$markerImage = new MarkerImage(); - -// Add your marker image to the marker like an icon -$marker->setIcon($markerImage); -``` - -### Add your marker image to the marker as shadow - -``` php -use Ivory\GoogleMap\Overlays\MarkerImage; - -$markerImage = new MarkerImage(); - -// Add your marker image to the marker like a shadow -$marker->setShadow($markerImage); -``` diff --git a/doc/usage/overlays/polygon.md b/doc/usage/overlays/polygon.md deleted file mode 100644 index 58e18489..00000000 --- a/doc/usage/overlays/polygon.md +++ /dev/null @@ -1,48 +0,0 @@ -# Polygon - -Polygon objects are similar to polyline objects in that they consist of a series of coordinates in an ordered sequence. -However, instead of being open-ended, polygons are designed to define regions within a closed loop. - -## Build your polygon - -``` php -use Ivory\GoogleMap\Overlays\Polygon; - -$polygon = new Polygon(); - -// Configure your polygon options -$polygon->setPrefixJavascriptVariable('polygon_'); - -$polygon->setOption('fillColor', '#000000'); -$polygon->setOption('fillOpacity', 0.5); -$polygon->setOptions(array( - 'fillColor' => '#000000', - 'fillOpacity' => 0.5, -)); -``` - -## Add coordinate to your polygon - -Like describe in the introduction, a polygon object consists of an array of coordinates. So, you need to add coordinate -to your polygon. - -``` php -use Ivory\GoogleMap\Overlays\Polygon; - -$polygon = new Polygon(); - -// Add coordinates to your polygon -$polygon->addCoordinate(0, 0, true); -$polygon->addCoordinate(1, 1, true); -``` - -## Add your polygon to the map - -``` php -use Ivory\GoogleMap\Overlays\Polygon; - -$polygon = new Polygon(); - -// Add your polygon to the map -$map->addPolygon($polygon); -``` diff --git a/doc/usage/overlays/polyline.md b/doc/usage/overlays/polyline.md deleted file mode 100644 index e10db35d..00000000 --- a/doc/usage/overlays/polyline.md +++ /dev/null @@ -1,48 +0,0 @@ -# Polyline - -The Polyline class defines a linear overlay of connected line segments on the map. A Polyline object consists of an -array of coordinates, and creates a series of line segments that connect those locations in an ordered sequence. - -## Build your polyline - -``` php -use Ivory\GoogleMap\Overlays\Polyline; - -$polyline = new Polyline(); - -// Configure your polyline options -$polyline->setPrefixJavascriptVariable('polyline_'); - -$polyline->setOption('geodesic', true); -$polyline->setOption('strokeColor', '#ffffff'); -$polyline->setOptions(array( - 'geodesic' => true, - 'strokeColor' => '#ffffff', -)); -``` - -## Add coordinate to your polyline - -Like describe in the introduction, a polyline object consists of an array of coordinates. So, you need to add -coordinate to your polyline. - -``` php -use Ivory\GoogleMap\Overlays\Polyline; - -$polyline = new Polyline(); - -// Add coordinates to your polyline -$polyline->addCoordinate(0, 0, true); -$polyline->addCoordinate(1, 1, true); -``` - -## Add your polyline to the map - -``` php -use Ivory\GoogleMap\Overlays\Polyline; - -$polyline = new Polyline(); - -// Add your polyline to the map -$map->addPolyline($polyline); -``` diff --git a/doc/usage/overlays/rectangle.md b/doc/usage/overlays/rectangle.md deleted file mode 100644 index cb6e8de8..00000000 --- a/doc/usage/overlays/rectangle.md +++ /dev/null @@ -1,36 +0,0 @@ -# Rectangle - -A Rectangle is similar to a Polygon in that you can define custom colors, weights, and opacities for the edge of the -rectangle (the "stroke") and custom colors and opacities for the area within the enclosed region (the "fill"). Unlike a -Polygon, you do not define paths for a Rectangle; instead, a rectangle has one additional property which defines its -shape : the bound. - -## Build your rectangle - -``` php -use Ivory\GoogleMap\Overlays\Rectangle; - -$rectangle = new Rectangle(); - -// Configure your rectangle options -$rectangle->setPrefixJavascriptVariable('rectangle_'); -$rectangle->setBound(-1, -1, 1, 1, true, true); - -$rectangle->setOption('clickable', false); -$rectangle->setOption('strokeColor', '#ffffff'); -$rectangle->setOptions(array( - 'clickable' => false, - 'strokeColor' => '#ffffff', -)); -``` - -## Add your rectangle to the map - -``` php -use Ivory\GoogleMap\Overlays\Rectangle; - -$rectangle = new Rectangle(); - -// Add your rectangle to the map -$map->addRectangle($rectangle); -``` diff --git a/doc/usage/places/autocomplete.md b/doc/usage/places/autocomplete.md deleted file mode 100644 index d3fcb292..00000000 --- a/doc/usage/places/autocomplete.md +++ /dev/null @@ -1,71 +0,0 @@ -# Autocomplete - -The Places Autocomplete feature attaches to a text field on your web page, and monitors that field for character -entries. As text is entered, Autocomplete returns Place predictions to the application in the form of a drop-down pick -list. You can use the Places Autocomplete feature to help users find a specific location, or assist them with filling -out address fields in online forms. - -## Build your autocomplete - -In order to use the Google Autocomplete feature, you need to build & configure it. - -``` php -use Ivory\GoogleMap\Places\Autocomplete; -use Ivory\GoogleMap\Places\AutocompleteComponentRestriction; -use Ivory\GoogleMap\Places\AutocompleteType; - -$autocomplete = new Autocomplete(); - -$autocomplete->setPrefixJavascriptVariable('place_autocomplete_'); -$autocomplete->setInputId('place_input'); - -$autocomplete->setInputAttributes(array('class' => 'my-class')); -$autocomplete->setInputAttribute('class', 'my-class'); - -$autocomplete->setValue('foo'); - -$autocomplete->setTypes(array(AutocompleteType::ESTABLISHMENT)); -$autocomplete->setComponentRestrictions(array(AutocompleteComponentRestriction::COUNTRY => 'fr')); -$autocomplete->setBound(-2.1, -3.9, 2.6, 1.4, true, true); - -$autocomplete->setAsync(false); -$autocomplete->setLanguage('en'); -``` - -## Render your autocomplete - -Now, you have builded & configured your autocomplete, you can render it. For this purpose, you will need the -`Ivory\GoogleMap\Helper\Places\AutocompleteHelper` which allows to render the autocomplete html container & some -javascript for being able to render it. - -``` php -use Ivory\GoogleMap\Helper\Places\AutocompleteHelper; - -$autocompleteHelper = new AutocompleteHelper(); -``` - -### Render the HTML container - -``` -echo $autocompleteHelper->renderHtmlContainer($autocomplete); -``` - -This function renders an html input with the ID, the value & the html attributes: - -``` html - -``` - -### Render the javascript - -``` -echo $autocompleteHelper->renderJavascripts($autocomplete); -``` - -This function renders an html javascript block with all code needed for displaying your autocomplete. - -``` html - -``` diff --git a/doc/usage/services/business_account.md b/doc/usage/services/business_account.md deleted file mode 100644 index 64690d68..00000000 --- a/doc/usage/services/business_account.md +++ /dev/null @@ -1,97 +0,0 @@ -# Business Account - -When using a service for business purpose, you will receive a business account from Google. This one allows you to -bypass Google limitation according to your billing plan. In order to use this feature, you will need an -`Ivory\GoogleMap\Services\BusinessAccount`: - -``` php -use Ivory\GoogleMap\Services\BusinessAccount; - -$businessAccount = new BusinessAccount('client_id', 'secret'); - -$clientId = $businessAccount->getClientId(); -$businessAccount->setClientId($clientId); - -$secret = $businessAccount->getSecret(); -$businessAccount->setSecret($secret); -``` - -Note that the client identifier is not prefixed by `gme-` (it is automatically prepended by the library). - -Additionally, you can use channel: - -``` -$businessAccount = new BusinessAccount('client_id', 'secret', 'my_channel'); - -$channel = $businessAccount->getChannel(); -$businessAccount->setChannel($channel); -``` - -## Geocoder - -If you want to use the geocoder service with a Google business account, you need to set it on the provider and then, -everything is done automatically: - -``` php -use Ivory\GoogleMap\Services\BusinessAccount; -use Ivory\GoogleMap\Services\Geocoding\Geocoder; -use Ivory\GoogleMap\Services\Geocoding\GeocoderProvider; -use Geocoder\HttpAdapter\CurlHttpAdapter; - - -$provider = new GeocoderProvider(new CurlHttpAdapter()) - -$provider->setBusinessAccount(new BusinessAccount('client_id', 'secret')); -$businessAccount = $provider->getBusinessAccount(); - -$geocoder = new Geocoder(); -$geocoder->registerProviders(array($provider)); - -$response = $geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); -``` - -If you want to go back the normal behavior (anonymous), you need to reset the business account to `null`: - -``` php -$geocoder->setBusinessAccount(null); -``` - -## Directions - -If you want to use the directions service with a Google business account, you need to set it on the service and then, -everything is done automatically: - -``` php -use Ivory\GoogleMap\Services\BusinessAccount; - -$directions->setBusinessAccount(new BusinessAccount('client_id', 'secret')); -$businessAccount = $directions->getBusinessAccount(); - -$response = $directions->route('Lille', 'Paris') -``` - -If you want to go back the normal behavior (anonymous), you need to reset the business account to `null`: - -``` php -$directions->setBusinessAccount(null); -``` - -## Distance Matrix - -If you want to use the distance matrix service with a Google business account, you need to set it on the service and -then, everything is done automatically: - -``` php -use Ivory\GoogleMap\Services\BusinessAccount; - -$distanceMatrix->setBusinessAccount(new BusinessAccount('client_id', 'secret')); -$businessAccount = $distanceMatrix->getBusinessAccount(); - -$response = $distanceMatrix->process(array('Vancouver BC'), array('San Francisco')); -``` - -If you want to go back the normal behavior (anonymous), you need to reset the business account to `null`: - -``` php -$distanceMatrix->setBusinessAccount(null); -``` diff --git a/doc/usage/services/directions/directions_request.md b/doc/usage/services/directions/directions_request.md deleted file mode 100644 index 16202c80..00000000 --- a/doc/usage/services/directions/directions_request.md +++ /dev/null @@ -1,47 +0,0 @@ -# Directions Request - -## Build a directions request - -``` php -use Ivory\GoogleMap\Services\Directions\DirectionsRequest; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; - -$request = new DirectionsRequest(); - -// Set your origin -$request->setOrigin('New York') -$request->setOrigin(1.1, 2.1, true); - -// Set your destination -$request->setDestination('Washington'); -$request->setDestination(2.1, 1.1, true); - -// Set your waypoints -$request->addWaypoint('Philadelphia'); -$request->addWaypoint(1.2, 2.2, true); - -// If you use waypoint, optimize it -$request->setOptimizeWaypoints(true); - -$request->setAvoidHighways(true); -$request->setAvoidTolls(true); -$request->setProvideRouteAlternatives(true); - -$request->setRegion('us'); -$request->setLanguage('en'); -$request->setTravelMode(TravelMode::DRIVING); -$request->setUnitSystem(UnitSystem::METRIC); -$request->setSensor(false); -``` - -## Route your request - -``` php -use Ivory\GoogleMap\Services\Directions\DirectionsRequest; - -$request = new DirectionsRequest(); - -// Route your request -$response = $directions->route($request); -``` diff --git a/doc/usage/services/distance_matrix/distance_matrix.md b/doc/usage/services/distance_matrix/distance_matrix.md deleted file mode 100644 index be4ec90b..00000000 --- a/doc/usage/services/distance_matrix/distance_matrix.md +++ /dev/null @@ -1,124 +0,0 @@ -# Distance Matrix API - -The Distance Matrix API uses [widop/http-adapter](http://github.com/widop/http-adapter) which is a PHP 5.3 library for -issuing http requests. - -The Google Distance Matrix API is a service that provides travel distance and time for a matrix of origins and -destinations. The information returned is based on the recommended route between start and end points, as calculated -by the Google Maps API, and consists of rows containing duration and distance values for each pair. - -This service does not return detailed route information. Route information can be obtained by passing the desired -single origin and destination to the -[Directions API](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/directions/directions.md). - -## Request the distance matrix service - -``` php -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrix; -use Widop\HttpAdapter\CurlHttpAdapter; - -$distanceMatrix = new DistanceMatrix(new CurlHttpAdapter()); -``` - -If you want to use it with a business account, you can read this -[documentation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/business_account.md). - -## Processes a request - -``` php -$response = $distanceMatrix->process(array('Vancouver BC'), array('San Francisco')); -``` - -The distance matrix allows you to proceess a much more advanced request. If you want to lear more, you can read this -[documentation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/distance_matrix/distance_matrix_request.md). - -## Distance matrix response - -When you have requested your distance matrix, the returned object is an -``Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponse``. It wraps a status, origins, destinations and rows. - -### Distance matrix status - -The available status are defined by the ``Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixStatus`` constants. - -``` php -// Get the status -$status = $response->getStatus(); -``` - -### Distance matrix origins - -It contains an array of addresses as returned by the API from your original request. These are formatted by the -geocoder and localized according to the language parameter passed with the request. - -``` php -// Get the origins -$origins = $response->getOrigins(); -``` - -### Directions matrix destinations - -It contains an array of addresses as returned by the API from your original request. As with distance matrix origins, -these are localized if appropriate. - -``` php -// Get the destinations -$destinations = $response->getDestinations(); -``` - -### Directions rows - -When the Distance Matrix API returns results, it places them within a rows array. Even if no results are returned -(such as when the origins and/or destinations don't exist), it still returns an empty array. Rows are ordered according -to the values in the origin parameter of the request. Each row corresponds to an origin, and each element within that -row corresponds to a pairing of the origin with a destination value. - -Each row array contains one or more distance matrix element entries, which in turn contain the information about a -single origin-destination pairing. - -``` php -// Get the rows -foreach ($rows as $row) { - $elements = $row->getElements(); -} -``` - -## Distance matrix element - -The information about each origin-destination pairing is represented by the -`Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixElement`. An element contains a status, a duration and -a distance. - -``` php -foreach ($elements as $element) { - // Play with distance matrix element. -} -``` - -### Distance matrix element status - -The available status are defined by the ``Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixElementStatus`` -constants. - -``` php -// Get the status -$status = $element->getStatus(); -``` - -### Distance matrix element distance - -The duration of this route represented by `Ivory\GoogleMap\Services\Base\Distance`. - -``` php -// Get the distance -$distance = $element->getDistance(); -``` - -### Distance matrix element duration - -The duration of this route represented by `Ivory\GoogleMap\Services\Base\Duration`. - -``` php -// Get the duration -$duration = $element->getDuration(); -``` diff --git a/doc/usage/services/distance_matrix/distance_matrix_request.md b/doc/usage/services/distance_matrix/distance_matrix_request.md deleted file mode 100644 index a122b154..00000000 --- a/doc/usage/services/distance_matrix/distance_matrix_request.md +++ /dev/null @@ -1,40 +0,0 @@ -# Distance Matrix Request - -## Build a distance matrix request - -``` php -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; - -$request = new DistanceMatrixRequest(); - -// Set your origins -$request->setOrigins(array('New York')); -$request->setOrigins(array(new Coordinate(1.1, 2.1, true))); - -// Set your destinations -$request->setDestinations(array('Washington')); -$request->setDestinations(array(new Coordinate(2.1, 1.1, true))); - -$request->setAvoidHighways(true); -$request->setAvoidTolls(true); - -$request->setRegion('us'); -$request->setLanguage('en'); -$request->setTravelMode(TravelMode::DRIVING); -$request->setUnitSystem(UnitSystem::METRIC); -$request->setSensor(false); -``` - -## Process your request - -``` php -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest; - -$request = new DistanceMatrixRequest(); - -// Process your request -$response = $distanceMatrix->process($request); -``` diff --git a/doc/usage/services/geocoding/geocoder.md b/doc/usage/services/geocoding/geocoder.md deleted file mode 100644 index 3c8f61e3..00000000 --- a/doc/usage/services/geocoding/geocoder.md +++ /dev/null @@ -1,60 +0,0 @@ -# Geocoding API - -The Geocoding API uses [Geocoder](http://github.com/willdurand/Geocoder) which is a PHP 5.3 library for issuing -Geocoding. So, I recommend you to read his documentation. - -Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic -coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. -Additionally, the service allows you to perform the converse operation (turning coordinates into addresses). This -process is known as "reverse geocoding". - -## Request a geocoder - -``` php -use Ivory\GoogleMap\Services\Geocoding\Geocoder; - -$geocoder = new Geocoder(); -``` - -The Ivory Google Map Geocoder allows you to build all available geocoder directly by configuration file. - -Available providers: - - - ``Geocoder\Provider\BindMapsProvider`` - - ``Geocoder\Provider\FreeGeoIpProvider`` - - ``Geocoder\Provider\GoogleMapsProvider`` - - ``Geocoder\Provider\HostIpProvider`` - - ``Geocoder\Provider\IpInfoDbProvider`` - - ``Geocoder\Provider\YahooProvider`` - - ``Ivory\GoogleMapBundle\Model\Services\Geocoding\Provider`` - -Available adapters: - - - ``Geocoder\HttpAdapter\BuzzHttpAdapter`` - - ``Geocoder\HttpAdapter\CurlHttpAdapter`` - - ``Geocoder\HttpAdapter\GuzzleHttpAdapter`` - - ``Geocoder\HttpAdapter\ZendHttpAdapter`` - -To use these providers/adapters, simply register them: - -``` php -use Ivory\GoogleMap\Services\Geocoding\Geocoder; -use Ivory\GoogleMap\Services\Geocoding\GeocoderProvider; -use Geocoder\HttpAdapter\CurlHttpAdapter; - -$geocoder = new Geocoder(); -$geocoder->registerProviders(array( - new GeocoderProvider(new CurlHttpAdapter()), -)); -``` - -## The standard Geocoder - -If you use the standard Geocoder components, I recommand you to directly read this own documentation available -[here](http://www.geocoder-php.org/). - -## The Ivory Google Map Geocoder - -The specific Ivory Google Map Geocoder has been added to allow you to geocode a very advanced request & use the -response to directly build your overlays. If you are interested about this geocoder, the documentation is available -[here](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/geocoding/ivory_geocoder.md). diff --git a/doc/usage/services/geocoding/geocoder_request.md b/doc/usage/services/geocoding/geocoder_request.md deleted file mode 100644 index a9c5a620..00000000 --- a/doc/usage/services/geocoding/geocoder_request.md +++ /dev/null @@ -1,33 +0,0 @@ -# Geocoder Request - -## Build a geocoder request - -``` php -use Ivory\GoogleMap\Services\Geocoding\GeocoderRequest; - -$request = new GeocoderRequest(); - -// Set address -$request->setAddress('1600 Amphitheatre Parkway, Mountain View, CA'); - -// Or set coordinate (reverse geocoding) -$request->setCoordinate(1.1, 2.1, true); - -$request->setBound(-1.1, -2.1, 2.1, 1.1, true, true); -$request->setRegion('en'); -$request->setLanguage('en'); -$request->setSensor(false); -``` - -If you set an address & a coordinate, address takes precedence over coordinate. - -## Geocoloate your request - -``` php -use Ivory\GoogleMap\Services\Geocoding\GeocoderRequest; - -$request = new GeocoderRequest(); - -// Geocode your request -$response = $geocoder->geocode($request); -``` diff --git a/doc/usage/services/geocoding/ivory_geocoder.md b/doc/usage/services/geocoding/ivory_geocoder.md deleted file mode 100644 index fd4022e6..00000000 --- a/doc/usage/services/geocoding/ivory_geocoder.md +++ /dev/null @@ -1,194 +0,0 @@ -# Ivory Geocoder - -Warning, if you want to use the Ivory Geocoder, you need to use the Ivory Provider otherwise there is no benefit. - -## Geocode a position - -The library allows you to request the google map geocoding API by two different ways. You have the choice between a -simple address (IP or street) or an advanced geocoder request. - -If you want to use it with a business account, you can read this -[documentation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/business_account.md). - -### Simple address - -``` php -use Ivory\GoogleMap\Services\Geocoding\Geocoder; -use Ivory\GoogleMap\Services\Geocoding\GeocoderProvider; -use Geocoder\HttpAdapter\CurlHttpAdapter; - -$geocoder = new Geocoder(); -$geocoder->registerProviders(array( - new GeocoderProvider(new CurlHttpAdapter()), -)); - -// Geocode an address -$response = $geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); -``` - -### Advanced geocoder request - -If you want to build an advanced request, read this specific -[documenation](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/geocoding/geocoder_request.md). - -## Geocoder response - -When you have requested your position, the returned object is an ``Ivory\GoogleMap\Services\Geocoding\GeocoderResponse``. -It wraps a geocoder status & geocoder results. - -### Geocoder status - -The available status are defined by the ``Ivory\GoogleMap\Services\Geocoding\GeocoderStatus`` constants. - -``` php -// Get the geocoder status -$status = $response->getStatus(); -``` - -### Geocoder results - -A request can return many results. The geocoder response wraps an array of ``Ivory\GoogleMap\Services\Geocoding\GeocoderResult``. - -``` php -// Get the geocoder results -$results = $response->getResults(); -``` - -### Geocoder result - -Each result wraps an human readable adress, some address & geometry informations, a partial match flag & some result -types. - -#### Human readable address - -The method ``getFormattedAddress`` is a string containing the human-readable address of this location. Often this -address is equivalent to the "postal address," which sometimes differs from country to country. (Note that some -countries, such as the United Kingdom, do not allow distribution of true postal addresses due to licensing -restrictions). - -``` php -// Get the geocoder results -$results = $reponse->getResults(); - -foreach ($results as $result) { - // Get the formatted address - $address = $result->getFormattedAddress(); -} -``` - -#### Address informations - -The method ``getAddressComponents`` returns an array containing the separate address components. Each address_component -typically contains: - - - types which is an array indicating the type of the address component. - - long name which is the full text description or name of the address component as returned by the Geocoder. - - short name which is an abbreviated textual name for the address component, if available. For example, an address - component for the state of Alaska may have a long_name of "Alaska" and a short_name of "AK" using the 2-letter - postal abbreviation. - -``` php -// Get the geocoder results -$results = $response->getResults(); - -foreach ($results as $result) { - foreach ($result->getAddressComponents() as $addressComponent) { - $longName = $addressComponent->getLongName(); - $shortName = $addressComponent->getShortName(); - $types = $addressComponent->getTypes(); - } -} -``` - -You can filter the address components by type: - -``` php -// Get the geocoder results -$results = $response->getResults(); - -foreach ($results as $result) { - foreach ($result->getAddressComponents('route') as $addressComponent) { - // ... - } -} - -#### Geometry informations - -Geometry contains the following information: - - - location which is an ``Ivory\GoogleMap\Base\Coordinate``. - - location type stores additional data about the specified location. The available possibilites are describes by the - ``Ivory\GoogleMap\Services\Geocoding\GeocoderLocationType`` constants. - - viewport which contains the recommended viewport for displaying the returned result, specified as ``Ivory\GoogleMap\Base\Bound``. - - bounds (optionally returned) which stores the bounding box which can fully contain the returned result, specified as - ``Ivory\GoogleMap\Base\Bound``. Note that these bounds may not match the recommended viewport. - -``` php -// Get the geocoder results -$results = $response->getResults(); - -foreach ($results as $result) { - $location = $result->getGeometry()->getLocation() - $locationType = $result->getGeometry()->getLocationType(); - $viewport = $result->getGeometry()->getViewport(); - $bound = $result->getGeometry()->getBound(); -} -``` - -#### Partial match flag - -The partial match flag indicates that the geocoder did not return an exact match for the original request, though it -did match part of the requested address. You may wish to examine the original request for misspellings and/or an -incomplete address. Partial matches most often occur for street addresses that do not exist within the locality you -pass in the request. - -``` php -// Get the geocoder results -$results = $response->getResults(); - -foreach ($results as $result) { - $partialMatch = $result->isPartialMatch(); -} -``` - -#### Result types - -The result types is an array indicates the type of the returned result. This array contains a set of one or more tags -identifying the type of feature returned in the result. For example, a geocode of "Chicago" returns "locality" which -indicates that "Chicago" is a city, and also returns "political" which indicates it is a political entity. - -``` php -// Get the geocoder results -$results = $response->getResults(); - -foreach ($results as $result) { - $types = $result->getTypes(); -} -``` - -## Create a marker according to a geocoded location - -``` php -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Marker; -use Ivory\GoogleMap\Services\Geocoding\Geocoder; - -$geocoder = new Geocoder(); - -// Geocode a location -$response = $this->geocode('1600 Amphitheatre Parkway, Mountain View, CA'); - -// Create your map -$map = new Map(); - -foreach ($response->getResults() as $result) { - // Create a marker - $marker = new Marker(); - - // Position the marker - $marker->setPosition($result->getGeometry()->getLocation()); - - // Add the marker to the map - $map->addMarker($marker); -} -``` diff --git a/doc/usage/services/index.md b/doc/usage/services/index.md deleted file mode 100644 index 97a3144c..00000000 --- a/doc/usage/services/index.md +++ /dev/null @@ -1,8 +0,0 @@ -# Google Map API Services - - 1. [Directions API](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/directions/directions.md) - 2. Distance Matrix API - 3. Elevation API - 4. [Geocoding API](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/geocoding/geocoder.md) - 5. Places API - 6. [Business Account](http://github.com/egeloen/ivory-google-map/blob/master/doc/usage/services/business_account.md) diff --git a/phpunit.travis.xml b/phpunit.travis.xml new file mode 100644 index 00000000..d67f55be --- /dev/null +++ b/phpunit.travis.xml @@ -0,0 +1,17 @@ + + + + + + ./tests/ + + + + + + + + ./src/ + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 042cc1bb..e22c5706 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,19 @@ - + ./tests/ + + + + + + functional + + ./src/ diff --git a/src/Assets/AbstractJavascriptVariableAsset.php b/src/Assets/AbstractJavascriptVariableAsset.php deleted file mode 100644 index 8faf50b2..00000000 --- a/src/Assets/AbstractJavascriptVariableAsset.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Assets; - -use Ivory\GoogleMap\Exception\AssetException; - -/** - * Allow easy generation of unique javascript variable for any class model that requires it. - * - * @author GeLo - */ -abstract class AbstractJavascriptVariableAsset -{ - /** @var string */ - protected $javascriptVariable; - - /** - * Creates a javascript variable asset. - */ - public function __construct($javascriptVariable = null) - { - if ($javascriptVariable === null) { - $javascriptVariable = $this->generateJavascriptVariable(); - } - - $this->setJavascriptVariable($javascriptVariable); - } - - /** - * Sets the prefix of the javascript variable. - * - * @param string $prefixJavascriptVariable The prefix of the javascript variable. - * - * @throws \Ivory\GoogleMap\Exception\AssetException If the prefix javascript variable is not valid. - */ - public function setPrefixJavascriptVariable($prefixJavascriptVariable) - { - if (!is_string($prefixJavascriptVariable)) { - throw AssetException::invalidPrefixJavascriptVariable(); - } - - $this->javascriptVariable = $this->generateJavascriptVariable($prefixJavascriptVariable); - } - - /** - * Gets the javascript variable which describes the asset. - * - * @return string The javascript variable. - */ - public function getJavascriptVariable() - { - return $this->javascriptVariable; - } - - /** - * Sets the javascript variable which describes the asset - * - * @param string $javascriptVariable The javascript variable. - * - * @throws \Ivory\GoogleMap\Exception\AssetException If the javascript variable is not valid. - */ - public function setJavascriptVariable($javascriptVariable) - { - if (!is_string($javascriptVariable)) { - throw AssetException::invalidJavascriptVariable(); - } - - $this->javascriptVariable = $javascriptVariable; - } - - /** - * Generates a unique javascript variable which can be prefixed. - * - * @param string $prefix The prefix. - * - * @return string The unique javascript variable. - */ - protected function generateJavascriptVariable($prefix = null) - { - return str_replace('.', '', uniqid($prefix, true)); - } -} diff --git a/src/Assets/AbstractOptionsAsset.php b/src/Assets/AbstractOptionsAsset.php deleted file mode 100644 index 9bfb5a85..00000000 --- a/src/Assets/AbstractOptionsAsset.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Assets; - -use Ivory\GoogleMap\Exception\AssetException; - -/** - * Allow easy add of options for any class model that requires it. - * - * @author GeLo - */ -abstract class AbstractOptionsAsset extends AbstractJavascriptVariableAsset -{ - /** @var array */ - protected $options; - - /** - * Creates an options asset. - * - * @param string $javascriptVariable The javascript variable. - * @param array $options The options. - */ - public function __construct($javascriptVariable = null, array $options = array()) - { - parent::__construct($javascriptVariable); - - $this->setOptions($options); - } - - /** - * Checks if there is option. - * - * @return boolean TRUE if there is option else FALSE. - */ - public function hasOptions() - { - return !empty($this->options); - } - - /** - * Checks if the option exists. - * - * @param string $option The option. - * - * @throws \Ivory\GoogleMap\Exception\AssetException If the option is not valid. - * - * @return boolean TRUE if the option exists else FALSE. - */ - public function hasOption($option) - { - if (!is_string($option)) { - throw AssetException::invalidOption(); - } - - return isset($this->options[$option]); - } - - /** - * Gets the options. - * - * @return array The options. - */ - public function getOptions() - { - return $this->options; - } - - /** - * Sets the options. - * - * @param array $options The options. - */ - public function setOptions(array $options) - { - $this->options = array(); - - foreach ($options as $option => $value) { - $this->setOption($option, $value); - } - } - - /** - * Gets a specific option. - * - * @param string $option The option. - * - * @throws \Ivory\GoogleMap\Exception\AssetException If the option does not exist. - * - * @return mixed The option value. - */ - public function getOption($option) - { - if (!$this->hasOption($option)) { - throw AssetException::optionDoesNotExist($option); - } - - return $this->options[$option]; - } - - /** - * Sets a specific option. - * - * @param string $option The option - * @param mixed $value The option value. - * - * @throws \Ivory\GoogleMap\Exception\AssetException If the option is not valid. - */ - public function setOption($option, $value) - { - if (!is_string($option)) { - throw AssetException::invalidOption(); - } - - $this->options[$option] = $value; - } - - /** - * Removes an option. - * - * @param string $option The option. - * - * @throws \Ivory\GoogleMap\Exception\AssetException If the option does not exist. - */ - public function removeOption($option) - { - if (!$this->hasOption($option)) { - throw AssetException::optionDoesNotExist($option); - } - - unset($this->options[$option]); - } -} diff --git a/src/Base/Bound.php b/src/Base/Bound.php index acfe7718..65f0c1c1 100644 --- a/src/Base/Bound.php +++ b/src/Base/Bound.php @@ -11,53 +11,63 @@ namespace Ivory\GoogleMap\Base; -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Exception\BaseException; -use Ivory\GoogleMap\Overlays\ExtendableInterface; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; /** - * Bound wich describes a google map bound. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLngBounds + * * @author GeLo */ -class Bound extends AbstractJavascriptVariableAsset +class Bound implements VariableAwareInterface { - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $southWest; + use VariableAwareTrait; - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $northEast; + /** + * @var Coordinate|null + */ + private $southWest; - /** @var array */ - protected $extends; + /** + * @var Coordinate|null + */ + private $northEast; /** - * Creates a bound. + * @var ExtendableInterface[] */ - public function __construct(Coordinate $southWest = null, Coordinate $northEast = null, array $extends = array()) - { - $this->setPrefixJavascriptVariable('bound_'); + private $extendables = []; + /** + * @param Coordinate|null $southWest + * @param Coordinate|null $northEast + */ + public function __construct(Coordinate $southWest = null, Coordinate $northEast = null) + { + $this->setVariablePrefix('bound'); $this->setSouthWest($southWest); $this->setNorthEast($northEast); - $this->setExtends($extends); } /** - * Checks if the bound has coordinates. - * - * @return boolean TRUE if the bound has coordinates else FALSE. + * @return bool */ public function hasCoordinates() { - return ($this->southWest !== null) && ($this->northEast !== null); + return $this->hasSouthWest() && $this->hasNorthEast(); } /** - * Gets the south west coordinate. - * - * @return \Ivory\GoogleMap\Base\Coordinate The south west coordinate. + * @return bool + */ + public function hasSouthWest() + { + return $this->southWest !== null; + } + + /** + * @return Coordinate|null */ public function getSouthWest() { @@ -65,42 +75,23 @@ public function getSouthWest() } /** - * Sets the south west coordinate. - * - * Available prototypes: - * - function setSouthWest(Ivory\GoogleMap\Base\Coordinate $southWest = null) - * - function setSouthWest(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the south west coordinate is not valid (prototypes). + * @param Coordinate|null $southWest */ - public function setSouthWest() + public function setSouthWest(Coordinate $southWest = null) { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->southWest = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->southWest === null) { - $this->southWest = new Coordinate(); - } - - $this->southWest->setLatitude($args[0]); - $this->southWest->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->southWest->setNoWrap($args[2]); - } - } elseif (!isset($args[0])) { - $this->southWest = null; - } else { - throw BaseException::invalidBoundSouthWest(); - } + $this->southWest = $southWest; } /** - * Gets the north east coordinate. - * - * @return \Ivory\GoogleMap\Base\Coordinate The northh east coordinate. + * @return bool + */ + public function hasNorthEast() + { + return $this->northEast !== null; + } + + /** + * @return Coordinate|null */ public function getNorthEast() { @@ -108,92 +99,73 @@ public function getNorthEast() } /** - * Sets the north east coordinate. - * - * Available prototypes: - * - function setNorthEast(Ivory\GoogleMap\Base\Coordinate $northEast = null) - * - function setNorthEast(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the north east coordinate is not valid (prototypes). + * @param Coordinate|null $northEast */ - public function setNorthEast() + public function setNorthEast(Coordinate $northEast = null) { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->northEast = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->northEast === null) { - $this->northEast = new Coordinate(); - } - - $this->northEast->setLatitude($args[0]); - $this->northEast->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->northEast->setNoWrap($args[2]); - } - } elseif (!isset($args[0])) { - $this->northEast = null; - } else { - throw BaseException::invalidBoundNorthEast(); - } + $this->northEast = $northEast; } /** - * Checks if the bound extends something. - * - * @return boolean TRUE if the bound extends somethind else FALSE. + * @return bool */ - public function hasExtends() + public function hasExtendables() { - return !empty($this->extends); + return !empty($this->extendables); } /** - * Gets the google map objects that the bound extends. - * - * @return array The objects that the bound extends. + * @return ExtendableInterface[] */ - public function getExtends() + public function getExtendables() { - return $this->extends; + return $this->extendables; } /** - * Sets the google map objects that the bound extends. - * - * @param array $extends The objects that the bound extends. + * @param ExtendableInterface[] $extendables */ - public function setExtends($extends) + public function setExtendables($extendables) { - $this->extends = array(); + $this->extendables = []; + $this->addExtendables($extendables); + } - foreach ($extends as $extend) { - $this->extend($extend); + /** + * @param ExtendableInterface[] $extendables + */ + public function addExtendables($extendables) + { + foreach ($extendables as $extendable) { + $this->addExtendable($extendable); } } /** - * Adds an object that the bound extends. + * @param ExtendableInterface $extendable * - * @param \Ivory\GoogleMap\Overlays\ExtendableInterface $extend The object that the bound extends. + * @return bool */ - public function extend(ExtendableInterface $extend) + public function hasExtendable(ExtendableInterface $extendable) { - $this->extends[] = $extend; + return in_array($extendable, $this->extendables, true); } /** - * Gets the center of the bound. - * - * @return \Ivory\GoogleMap\Base\Coordinate The bound center. + * @param ExtendableInterface $extendable */ - public function getCenter() + public function addExtendable(ExtendableInterface $extendable) { - $centerLatitude = ($this->getSouthWest()->getLatitude() + $this->getNorthEast()->getLatitude()) / 2; - $centerLongitude = ($this->getSouthWest()->getLongitude() + $this->getNorthEast()->getLongitude()) / 2; + if (!$this->hasExtendable($extendable)) { + $this->extendables[] = $extendable; + } + } - return new Coordinate($centerLatitude, $centerLongitude); + /** + * @param ExtendableInterface $extendable + */ + public function removeExtendable(ExtendableInterface $extendable) + { + unset($this->extendables[array_search($extendable, $this->extendables, true)]); } } diff --git a/src/Base/Coordinate.php b/src/Base/Coordinate.php index 4bf65748..a2e5637e 100644 --- a/src/Base/Coordinate.php +++ b/src/Base/Coordinate.php @@ -11,46 +11,48 @@ namespace Ivory\GoogleMap\Base; -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Exception\BaseException; +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; /** - * Coordinate which describes a google map coordinate. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLng + * * @author GeLo */ -class Coordinate extends AbstractJavascriptVariableAsset +class Coordinate implements VariableAwareInterface { - /** @var double */ - protected $latitude; + use VariableAwareTrait; - /** @var double */ - protected $longitude; + /** + * @var float + */ + private $latitude; - /** @var boolean */ - protected $noWrap; + /** + * @var float + */ + private $longitude; /** - * Create a coordinate - * - * @param double $latitude The latitude. - * @param double $longitude The longitude. - * @param boolean $noWrap The no wrap flag. + * @var bool */ - public function __construct($latitude = 0, $longitude = 0, $noWrap = true) - { - $this->setPrefixJavascriptVariable('coordinate_'); + private $noWrap; + /** + * @param float $latitude + * @param float $longitude + * @param bool $noWrap + */ + public function __construct($latitude = 0.0, $longitude = 0.0, $noWrap = true) + { + $this->setVariablePrefix('coordinate'); $this->setLatitude($latitude); $this->setLongitude($longitude); $this->setNoWrap($noWrap); } /** - * Gets the latitude. - * - * @return double The latitude. + * @return float */ public function getLatitude() { @@ -58,25 +60,15 @@ public function getLatitude() } /** - * Sets the latitude - * - * @param double $latitude The latitude. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the latitude is not valid. + * @param float $latitude */ public function setLatitude($latitude) { - if (!is_numeric($latitude) && ($latitude !== null)) { - throw BaseException::invalidCoordinateLatitude(); - } - $this->latitude = $latitude; } /** - * Gets the longitude - * - * @return doube The longitude. + * @return float */ public function getLongitude() { @@ -84,25 +76,15 @@ public function getLongitude() } /** - * Sets the longitude. - * - * @param double $longitude The longitude. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the longitude is not valid. + * @param float $longitude */ public function setLongitude($longitude) { - if (!is_numeric($longitude) && ($longitude !== null)) { - throw BaseException::invalidCoordinateLongitude(); - } - $this->longitude = $longitude; } /** - * Check if the coordinate is not wrap. - * - * @return boolean TRUE if the coordinate is not wrap else FALSE. + * @return bool */ public function isNoWrap() { @@ -110,18 +92,10 @@ public function isNoWrap() } /** - * Sets if the coordinate is wrap. - * - * @param boolean $noWrap TRUE if the coordinate is not wrap else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the no wrap flag is not valid. + * @param bool $noWrap */ public function setNoWrap($noWrap) { - if (!is_bool($noWrap) && ($noWrap !== null)) { - throw BaseException::invalidCoordinateNoWrap(); - } - $this->noWrap = $noWrap; } } diff --git a/src/Base/Point.php b/src/Base/Point.php index 60f9d283..435752e6 100644 --- a/src/Base/Point.php +++ b/src/Base/Point.php @@ -11,41 +11,41 @@ namespace Ivory\GoogleMap\Base; -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Exception\BaseException; +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; /** - * Point which describes a google map point - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Point + * * @author GeLo */ -class Point extends AbstractJavascriptVariableAsset +class Point implements VariableAwareInterface { - /** @var double */ - protected $x; + use VariableAwareTrait; - /** @var double */ - protected $y; + /** + * @var float + */ + private $x; /** - * Creates a point. - * - * @param double $x X coordinate. - * @param double $y Y coordinate. + * @var float */ - public function __construct($x = 0, $y = 0) - { - $this->setPrefixJavascriptVariable('point_'); + private $y; + /** + * @param float $x + * @param float $y + */ + public function __construct($x = 0.0, $y = 0.0) + { + $this->setVariablePrefix('point'); $this->setX($x); $this->setY($y); } /** - * Gets the x coordinate. - * - * @return double The x coordinate. + * @return float */ public function getX() { @@ -53,25 +53,15 @@ public function getX() } /** - * Sets the x coordinate. - * - * @param double $x The x coordinate. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the X coordinate is not valid. + * @param float $x */ public function setX($x) { - if (!is_numeric($x)) { - throw BaseException::invalidPointX(); - } - $this->x = $x; } /** - * Gets the y coordinate. - * - * @return double The Y coordinate. + * @return float */ public function getY() { @@ -79,18 +69,10 @@ public function getY() } /** - * Sets the y coordinate. - * - * @param double $y The y coordinate. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the Y coordinate is not valid. + * @param float $y */ public function setY($y) { - if (!is_numeric($y)) { - throw BaseException::invalidPointY(); - } - $this->y = $y; } } diff --git a/src/Base/Size.php b/src/Base/Size.php index 135b09ae..7cfe6e55 100644 --- a/src/Base/Size.php +++ b/src/Base/Size.php @@ -11,52 +11,55 @@ namespace Ivory\GoogleMap\Base; -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Exception\BaseException; +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; /** - * Size which describes a google map size. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Size + * * @author GeLo */ -class Size extends AbstractJavascriptVariableAsset +class Size implements VariableAwareInterface { - /** @var double */ - protected $width; + use VariableAwareTrait; - /** @var double */ - protected $height; + /** + * @var float + */ + private $width; + + /** + * @var float + */ + private $height; - /** @var string */ - protected $widthUnit; + /** + * @var string + */ + private $widthUnit; - /** @var string */ - protected $heightUnit; + /** + * @var string + */ + private $heightUnit; /** - * Create a size. - * - * @param double $width The width. - * @param double $height The height. - * @param string $widthUnit The width unit. - * @param string $heightUnit The height unit. + * @param float $width + * @param float $height + * @param string|null $widthUnit + * @param string|null $heightUnit */ - public function __construct($width = 1, $height = 1, $widthUnit = null, $heightUnit = null) + public function __construct($width = 1.0, $height = 1.0, $widthUnit = null, $heightUnit = null) { - $this->setPrefixJavascriptVariable('size_'); - + $this->setVariablePrefix('size'); $this->setWidth($width); $this->setHeight($height); - $this->setWidthUnit($widthUnit); $this->setHeightUnit($heightUnit); } /** - * Gets the width size. - * - * @return double The width size. + * @return float */ public function getWidth() { @@ -64,25 +67,15 @@ public function getWidth() } /** - * Sets the width size. - * - * @param double $width The width size. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the width is not valid. + * @param float $width */ public function setWidth($width) { - if (!is_numeric($width)) { - throw BaseException::invalidSizeWidth(); - } - $this->width = $width; } /** - * Gets the height size - * - * @return double The height size. + * @return float */ public function getHeight() { @@ -90,35 +83,31 @@ public function getHeight() } /** - * Sets the height size. - * - * @param double $height The height size. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the height is not valid. + * @param float $height */ public function setHeight($height) { - if (!is_numeric($height)) { - throw BaseException::invalidSizeHeight(); - } - $this->height = $height; } /** - * Checks if the size has units. - * - * @return boolean TRUE if the size has units else FALSE. + * @return bool */ public function hasUnits() { - return ($this->widthUnit !== null) && ($this->heightUnit !== null); + return $this->hasWidthUnit() && $this->hasHeightUnit(); } /** - * Gets the width unit size. - * - * @return string The width unit size. + * @return bool + */ + public function hasWidthUnit() + { + return $this->widthUnit !== null; + } + + /** + * @return string|null */ public function getWidthUnit() { @@ -126,25 +115,23 @@ public function getWidthUnit() } /** - * Sets the width unit size. - * - * @param string $widthUnit The width unit size. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the width unit is not valid. + * @param string|null $widthUnit */ - public function setWidthUnit($widthUnit) + public function setWidthUnit($widthUnit = null) { - if (!is_string($widthUnit) && ($widthUnit !== null)) { - throw BaseException::invalidSizeWidthUnit(); - } - $this->widthUnit = $widthUnit; } /** - * Gets the height unit size. - * - * @return string The height unit size. + * @return bool + */ + public function hasHeightUnit() + { + return $this->heightUnit !== null; + } + + /** + * @return string|null */ public function getHeightUnit() { @@ -152,18 +139,10 @@ public function getHeightUnit() } /** - * Sets the height unit size. - * - * @param string $heightUnit The height unit size. - * - * @throws \Ivory\GoogleMap\Exception\BaseException If the height unit is not valid. + * @param string|null $heightUnit */ - public function setHeightUnit($heightUnit) + public function setHeightUnit($heightUnit = null) { - if (!is_string($heightUnit) && ($heightUnit !== null)) { - throw BaseException::invalidSizeHeightUnit(); - } - $this->heightUnit = $heightUnit; } } diff --git a/src/Control/ControlManager.php b/src/Control/ControlManager.php new file mode 100644 index 00000000..40132309 --- /dev/null +++ b/src/Control/ControlManager.php @@ -0,0 +1,198 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Control; + +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class ControlManager +{ + /** + * @var Map|null + */ + private $map; + + /** + * @var MapTypeControl|null + */ + private $mapTypeControl; + + /** + * @var RotateControl|null + */ + private $rotateControl; + + /** + * @var ScaleControl|null + */ + private $scaleControl; + + /** + * @var StreetViewControl|null + */ + private $streetViewControl; + + /** + * @var ZoomControl|null + */ + private $zoomControl; + + /** + * @return bool + */ + public function hasMap() + { + return $this->map !== null; + } + + /** + * @return Map|null + */ + public function getMap() + { + return $this->map; + } + + /** + * @param Map $map + */ + public function setMap(Map $map) + { + $this->map = $map; + + if ($map->getControlManager() !== $this) { + $map->setControlManager($this); + } + } + + /** + * @return bool + */ + public function hasMapTypeControl() + { + return $this->mapTypeControl !== null; + } + + /** + * @return MapTypeControl|null + */ + public function getMapTypeControl() + { + return $this->mapTypeControl; + } + + /** + * @param MapTypeControl|null $mapTypeControl + */ + public function setMapTypeControl(MapTypeControl $mapTypeControl = null) + { + $this->mapTypeControl = $mapTypeControl; + } + + /** + * @return bool + */ + public function hasRotateControl() + { + return $this->rotateControl !== null; + } + + /** + * @return RotateControl|null + */ + public function getRotateControl() + { + return $this->rotateControl; + } + + /** + * @param RotateControl|null $rotateControl + */ + public function setRotateControl(RotateControl $rotateControl = null) + { + $this->rotateControl = $rotateControl; + } + + /** + * @return bool + */ + public function hasScaleControl() + { + return $this->scaleControl !== null; + } + + /** + * @return ScaleControl|null + */ + public function getScaleControl() + { + return $this->scaleControl; + } + + /** + * @param ScaleControl|null $scaleControl + */ + public function setScaleControl(ScaleControl $scaleControl = null) + { + $this->scaleControl = $scaleControl; + } + + /** + * @return bool + */ + public function hasStreetViewControl() + { + return $this->streetViewControl !== null; + } + + /** + * @return StreetViewControl|null + */ + public function getStreetViewControl() + { + return $this->streetViewControl; + } + + /** + * @param StreetViewControl|null $streetViewControl + */ + public function setStreetViewControl(StreetViewControl $streetViewControl = null) + { + $this->streetViewControl = $streetViewControl; + } + + /** + * @return bool + */ + public function hasZoomControl() + { + return $this->zoomControl !== null; + } + + /** + * @return ZoomControl|null + */ + public function getZoomControl() + { + return $this->zoomControl; + } + + /** + * @param ZoomControl|null $zoomControl + */ + public function setZoomControl(ZoomControl $zoomControl = null) + { + $this->zoomControl = $zoomControl; + } +} diff --git a/src/Controls/ControlPosition.php b/src/Control/ControlPosition.php similarity index 53% rename from src/Controls/ControlPosition.php rename to src/Control/ControlPosition.php index f2e30adf..43bd3874 100644 --- a/src/Controls/ControlPosition.php +++ b/src/Control/ControlPosition.php @@ -9,15 +9,14 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Controls; +namespace Ivory\GoogleMap\Control; /** - * Control position which describes a google map control position. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ControlPosition + * * @author GeLo */ -class ControlPosition +final class ControlPosition { const BOTTOM_CENTER = 'bottom_center'; const BOTTOM_LEFT = 'bottom_left'; @@ -33,35 +32,9 @@ class ControlPosition const TOP_RIGHT = 'top_right'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available control positions. - * - * @return array The control positions. - */ - public static function getControlPositions() + private function __construct() { - return array( - self::BOTTOM_CENTER, - self::BOTTOM_LEFT, - self::BOTTOM_RIGHT, - self::LEFT_BOTTOM, - self::LEFT_CENTER, - self::LEFT_TOP, - self::RIGHT_BOTTOM, - self::RIGHT_CENTER, - self::RIGHT_TOP, - self::TOP_CENTER, - self::TOP_LEFT, - self::TOP_RIGHT, - ); } } diff --git a/src/Control/MapTypeControl.php b/src/Control/MapTypeControl.php new file mode 100644 index 00000000..92e30197 --- /dev/null +++ b/src/Control/MapTypeControl.php @@ -0,0 +1,147 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Control; + +use Ivory\GoogleMap\MapTypeId; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeControlOptions + * + * @author GeLo + */ +class MapTypeControl +{ + /** + * @var string[] + */ + private $ids = []; + + /** + * @var string + */ + private $position; + + /** + * @var string + */ + private $style; + + /** + * @param string[] $ids + * @param string $position + * @param string $style + */ + public function __construct( + array $ids = [MapTypeId::ROADMAP, MapTypeId::SATELLITE], + $position = ControlPosition::TOP_RIGHT, + $style = MapTypeControlStyle::DEFAULT_ + ) { + $this->addIds($ids); + $this->setPosition($position); + $this->setStyle($style); + } + + /** + * @return bool + */ + public function hasIds() + { + return !empty($this->ids); + } + + /** + * @return string[] + */ + public function getIds() + { + return $this->ids; + } + + /** + * @param string[] $ids + */ + public function setIds(array $ids) + { + $this->ids = []; + $this->addIds($ids); + } + + /** + * @param string[] $ids + */ + public function addIds(array $ids) + { + foreach ($ids as $mapTypeId) { + $this->addId($mapTypeId); + } + } + + /** + * @param string $id + * + * @return bool + */ + public function hasId($id) + { + return in_array($id, $this->ids, true); + } + + /** + * @param string $id + */ + public function addId($id) + { + if (!$this->hasId($id)) { + $this->ids[] = $id; + } + } + + /** + * @param string $id + */ + public function removeId($id) + { + unset($this->ids[array_search($id, $this->ids, true)]); + } + + /** + * @return string + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param string $position + */ + public function setPosition($position) + { + $this->position = $position; + } + + /** + * @return string + */ + public function getStyle() + { + return $this->style; + } + + /** + * @param string $style + */ + public function setStyle($style) + { + $this->style = $style; + } +} diff --git a/src/Controls/MapTypeControlStyle.php b/src/Control/MapTypeControlStyle.php similarity index 51% rename from src/Controls/MapTypeControlStyle.php rename to src/Control/MapTypeControlStyle.php index 9f7374f6..a84c7ace 100644 --- a/src/Controls/MapTypeControlStyle.php +++ b/src/Control/MapTypeControlStyle.php @@ -9,41 +9,23 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Controls; +namespace Ivory\GoogleMap\Control; /** - * Map type control style which describes a google map type control style. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ControlPosition + * * @author GeLo */ -class MapTypeControlStyle +final class MapTypeControlStyle { const DEFAULT_ = 'default'; const DROPDOWN_MENU = 'dropdown_menu'; const HORIZONTAL_BAR = 'horizontal_bar'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available map type control styles. - * - * @return array The map type control styles. - */ - public static function getMapTypeControlStyles() + private function __construct() { - return array( - self::DEFAULT_, - self::DROPDOWN_MENU, - self::HORIZONTAL_BAR, - ); } } diff --git a/src/Control/RotateControl.php b/src/Control/RotateControl.php new file mode 100644 index 00000000..791c3a7e --- /dev/null +++ b/src/Control/RotateControl.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Control; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#RotateControlOptions + * + * @author GeLo + */ +class RotateControl +{ + /** + * @var string + */ + private $position; + + /** + * @param string $position + */ + public function __construct($position = ControlPosition::TOP_LEFT) + { + $this->setPosition($position); + } + + /** + * @return string + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param string $position + */ + public function setPosition($position) + { + $this->position = $position; + } +} diff --git a/src/Control/ScaleControl.php b/src/Control/ScaleControl.php new file mode 100644 index 00000000..81a5e9f1 --- /dev/null +++ b/src/Control/ScaleControl.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Control; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ScaleControlOptions + * + * @author GeLo + */ +class ScaleControl +{ + /** + * @var string + */ + private $position; + + /** + * @var string + */ + private $style; + + /** + * @param string $position + * @param string $style + */ + public function __construct($position = ControlPosition::BOTTOM_LEFT, $style = ScaleControlStyle::DEFAULT_) + { + $this->setPosition($position); + $this->setStyle($style); + } + + /** + * @return string + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param string $position + */ + public function setPosition($position) + { + $this->position = $position; + } + + /** + * @return string + */ + public function getStyle() + { + return $this->style; + } + + /** + * @param string $style + */ + public function setStyle($style) + { + $this->style = $style; + } +} diff --git a/src/Controls/ScaleControlStyle.php b/src/Control/ScaleControlStyle.php similarity index 51% rename from src/Controls/ScaleControlStyle.php rename to src/Control/ScaleControlStyle.php index e513be8a..eb221bbb 100644 --- a/src/Controls/ScaleControlStyle.php +++ b/src/Control/ScaleControlStyle.php @@ -9,37 +9,21 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Controls; +namespace Ivory\GoogleMap\Control; /** - * Scale control style which describes a google map scale control style. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ScaleControlStyle + * * @author GeLo */ -class ScaleControlStyle +final class ScaleControlStyle { const DEFAULT_ = 'default'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available map scale control styles - * - * @return array The map scale constrol styles. - */ - public static function getScaleControlStyles() + private function __construct() { - return array( - self::DEFAULT_, - ); } } diff --git a/src/Control/StreetViewControl.php b/src/Control/StreetViewControl.php new file mode 100644 index 00000000..e8d50acd --- /dev/null +++ b/src/Control/StreetViewControl.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Control; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#StreetViewControlOptions + * + * @author GeLo + */ +class StreetViewControl +{ + /** + * @var string + */ + private $position; + + /** + * @param string $position + */ + public function __construct($position = ControlPosition::TOP_LEFT) + { + $this->setPosition($position); + } + + /** + * @return string + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param string $position + */ + public function setPosition($position) + { + $this->position = $position; + } +} diff --git a/src/Control/ZoomControl.php b/src/Control/ZoomControl.php new file mode 100644 index 00000000..165a8704 --- /dev/null +++ b/src/Control/ZoomControl.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Control; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ZoomControlOptions + * + * @author GeLo + */ +class ZoomControl +{ + /** + * @var string + */ + private $position; + + /** + * @var string + */ + private $style; + + /** + * @param string $position + * @param string $style + */ + public function __construct($position = ControlPosition::TOP_LEFT, $style = ZoomControlStyle::DEFAULT_) + { + $this->setPosition($position); + $this->setStyle($style); + } + + /** + * @return string + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param string $position + */ + public function setPosition($position) + { + $this->position = $position; + } + + /** + * @return string + */ + public function getStyle() + { + return $this->style; + } + + /** + * @param string $style + */ + public function setStyle($style) + { + $this->style = $style; + } +} diff --git a/src/Controls/ZoomControlStyle.php b/src/Control/ZoomControlStyle.php similarity index 51% rename from src/Controls/ZoomControlStyle.php rename to src/Control/ZoomControlStyle.php index 79bc2a39..8cb1df40 100644 --- a/src/Controls/ZoomControlStyle.php +++ b/src/Control/ZoomControlStyle.php @@ -9,41 +9,23 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Controls; +namespace Ivory\GoogleMap\Control; /** - * Zoom control style which describes a google map zoom control style. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ZoomControlStyle + * * @author GeLo */ -class ZoomControlStyle +final class ZoomControlStyle { const DEFAULT_ = 'default'; const LARGE = 'large'; const SMALL = 'small'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available map zoom control styles. - * - * @return array The map zoom control styles. - */ - public static function getZoomControlStyles() + private function __construct() { - return array( - self::DEFAULT_, - self::LARGE, - self::SMALL, - ); } } diff --git a/src/Controls/MapTypeControl.php b/src/Controls/MapTypeControl.php deleted file mode 100644 index 7e27cd6b..00000000 --- a/src/Controls/MapTypeControl.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Controls; - -use Ivory\GoogleMap\Exception\ControlException; -use Ivory\GoogleMap\MapTypeId; - -/** - * Map type control options describes a google map type control options. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeControlOptions - * @author GeLo - */ -class MapTypeControl -{ - /** @var array */ - protected $mapTypeIds; - - /** @var string */ - protected $controlPosition; - - /** @var string */ - protected $mapTypeControlStyle; - - /** - * Create a map type control. - * - * @param array $mapTypeIds The map type IDs. - * @param string $controlPosition The control position. - * @param string $mapTypeControlStyle The map type control style. - */ - public function __construct( - array $mapTypeIds = array(MapTypeId::ROADMAP, MapTypeId::SATELLITE), - $controlPosition = ControlPosition::TOP_RIGHT, - $mapTypeControlStyle = MapTypeControlStyle::DEFAULT_ - ) { - $this->setMapTypeIds($mapTypeIds); - $this->setControlPosition($controlPosition); - $this->setMapTypeControlStyle($mapTypeControlStyle); - } - - /** - * Gets the map type IDs. - * - * @return array The map type IDs. - */ - public function getMapTypeIds() - { - return $this->mapTypeIds; - } - - /** - * Sets the map type IDs. - * - * @param array $mapTypeIds The map type IDs. - */ - public function setMapTypeIds($mapTypeIds) - { - $this->mapTypeIds = array(); - - foreach ($mapTypeIds as $mapTypeId) { - $this->addMapTypeId($mapTypeId); - } - } - - /** - * Add a map type ID. - * - * @param string $mapTypeId The map type ID to add. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the map type ID is not valid. - */ - public function addMapTypeId($mapTypeId) - { - if (!in_array($mapTypeId, MapTypeId::getMapTypeIds())) { - throw ControlException::invalidMapTypeId(); - } - - if (!in_array($mapTypeId, $this->mapTypeIds)) { - $this->mapTypeIds[] = $mapTypeId; - } - } - - /** - * Gets the control position. - * - * @return string The control position. - */ - public function getControlPosition() - { - return $this->controlPosition; - } - - /** - * Sets the control position. - * - * @param string $controlPosition The control position. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the control position is not valid. - */ - public function setControlPosition($controlPosition) - { - if (!in_array($controlPosition, ControlPosition::getControlPositions())) { - throw ControlException::invalidControlPosition(); - } - - $this->controlPosition = $controlPosition; - } - - /** - * Gets the map type control style. - * - * @return string The map type control style. - */ - public function getMapTypeControlStyle() - { - return $this->mapTypeControlStyle; - } - - /** - * Sets the map type control style. - * - * @param type $mapTypeControlStyle The map type control style. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the map type control style is not valid. - */ - public function setMapTypeControlStyle($mapTypeControlStyle) - { - if (!in_array($mapTypeControlStyle, MapTypeControlStyle::getMapTypeControlStyles())) { - throw ControlException::invalidMapTypeControlStyle(); - } - - $this->mapTypeControlStyle = $mapTypeControlStyle; - } -} diff --git a/src/Controls/OverviewMapControl.php b/src/Controls/OverviewMapControl.php deleted file mode 100644 index 8d368e61..00000000 --- a/src/Controls/OverviewMapControl.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Controls; - -use Ivory\GoogleMap\Exception\ControlException; - -/** - * An overview map control describes a google map overview control. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#OverviewMapControlOptions - * @author GeLo - */ -class OverviewMapControl -{ - /** @var boolean */ - protected $opened; - - /** - * Create an overview map control. - * - * @param boolean $opened TRUE if the overview map control is opened else FALSE. - */ - public function __construct($opened = false) - { - $this->setOpened($opened); - } - - /** - * Checks if the overview map control is opened. - * - * @return boolean TRUE if the overview map control is opened else FALSE. - */ - public function isOpened() - { - return $this->opened; - } - - /** - * Sets if the overview map control is opened. - * - * @param boolean $opened TRUE if the overview map control is opened else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the opened flag is not valid. - */ - public function setOpened($opened) - { - if (!is_bool($opened)) { - throw ControlException::invalidOverviewMapControlOpened(); - } - - $this->opened = $opened; - } -} diff --git a/src/Controls/PanControl.php b/src/Controls/PanControl.php deleted file mode 100644 index d35905b9..00000000 --- a/src/Controls/PanControl.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Controls; - -use Ivory\GoogleMap\Exception\ControlException; - -/** - * A pan control describes a google map pan control. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#PanControlOptions - * @author GeLo - */ -class PanControl -{ - /** @var string */ - protected $controlPosition; - - /** - * Create a pan control. - * - * @param string $controlPosition The pan control position. - */ - public function __construct($controlPosition = ControlPosition::TOP_LEFT) - { - $this->setControlPosition($controlPosition); - } - - /** - * Gets the control position. - * - * @return string The control position. - */ - public function getControlPosition() - { - return $this->controlPosition; - } - - /** - * Sets the control position. - * - * @param string $controlPosition The control position. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the control position is not valid. - */ - public function setControlPosition($controlPosition) - { - if (!in_array($controlPosition, ControlPosition::getControlPositions())) { - throw ControlException::invalidControlPosition(); - } - - $this->controlPosition = $controlPosition; - } -} diff --git a/src/Controls/RotateControl.php b/src/Controls/RotateControl.php deleted file mode 100644 index 2531a575..00000000 --- a/src/Controls/RotateControl.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Controls; - -use Ivory\GoogleMap\Exception\ControlException; - -/** - * A rotate control describes a google map rotate control. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#RotateControlOptions - * @author GeLo - */ -class RotateControl -{ - /** @var string */ - protected $controlPosition; - - /** - * Create a rotate control. - * - * @param string $controlPosition The rotate control position. - */ - public function __construct($controlPosition = ControlPosition::TOP_LEFT) - { - $this->setControlPosition($controlPosition); - } - - /** - * Gets the control position. - * - * @return string The control position. - */ - public function getControlPosition() - { - return $this->controlPosition; - } - - /** - * Sets the control position. - * - * @param string $controlPosition The control position. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the control position is not valid. - */ - public function setControlPosition($controlPosition) - { - if (!in_array($controlPosition, ControlPosition::getControlPositions())) { - throw ControlException::invalidControlPosition(); - } - - $this->controlPosition = $controlPosition; - } -} diff --git a/src/Controls/ScaleControl.php b/src/Controls/ScaleControl.php deleted file mode 100644 index 2f03772a..00000000 --- a/src/Controls/ScaleControl.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Controls; - -use Ivory\GoogleMap\Exception\ControlException; - -/** - * Scale control options describes a google map scale control options - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ScaleControlOptions - * @author GeLo - */ -class ScaleControl -{ - /** @var string */ - protected $controlPosition; - - /** @var string */ - protected $scaleControlStyle; - - /** - * Creates a scale control. - * - * @param string $controlPosition The control position. - * @param string $scaleControlStyle The scale control style. - */ - public function __construct( - $controlPosition = ControlPosition::BOTTOM_LEFT, - $scaleControlStyle = ScaleControlStyle::DEFAULT_ - ) { - $this->setControlPosition($controlPosition); - $this->setScaleControlStyle($scaleControlStyle); - } - - /** - * Gets the control position. - * - * @return string The control position. - */ - public function getControlPosition() - { - return $this->controlPosition; - } - - /** - * Sets the control position. - * - * @param string $controlPosition The control position. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the control position is not valid. - */ - public function setControlPosition($controlPosition) - { - if (!in_array($controlPosition, ControlPosition::getControlPositions())) { - throw ControlException::invalidControlPosition(); - } - - $this->controlPosition = $controlPosition; - } - - /** - * Gets the scale control style. - * - * @return string The scale control style. - */ - public function getScaleControlStyle() - { - return $this->scaleControlStyle; - } - - /** - * Sets the scale control style. - * - * @param type $scaleControlStyle The scale control style. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the scale control style is not valid. - */ - public function setScaleControlStyle($scaleControlStyle) - { - if (!in_array($scaleControlStyle, ScaleControlStyle::getScaleControlStyles())) { - throw ControlException::invalidScaleControlStyle(); - } - - $this->scaleControlStyle = $scaleControlStyle; - } -} diff --git a/src/Controls/StreetViewControl.php b/src/Controls/StreetViewControl.php deleted file mode 100644 index 36604709..00000000 --- a/src/Controls/StreetViewControl.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Controls; - -use Ivory\GoogleMap\Exception\ControlException; - -/** - * A street view control describes a google map street view control. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#StreetViewControlOptions - * @author GeLo - */ -class StreetViewControl -{ - /** @var string */ - protected $controlPosition; - - /** - * Creates a street view control. - * - * @param string $controlPosition The control position. - */ - public function __construct($controlPosition = ControlPosition::TOP_LEFT) - { - $this->setControlPosition($controlPosition); - } - - /** - * Gets the control position. - * - * @return string The control position. - */ - public function getControlPosition() - { - return $this->controlPosition; - } - - /** - * Sets the control position. - * - * @param string $controlPosition The control position. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the control position is not valid. - */ - public function setControlPosition($controlPosition) - { - if (!in_array($controlPosition, ControlPosition::getControlPositions())) { - throw ControlException::invalidControlPosition(); - } - - $this->controlPosition = $controlPosition; - } -} diff --git a/src/Controls/ZoomControl.php b/src/Controls/ZoomControl.php deleted file mode 100644 index 75dae652..00000000 --- a/src/Controls/ZoomControl.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Controls; - -use Ivory\GoogleMap\Exception\ControlException; - -/** - * A zoom control describes a google map zoom control. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ZoomControlOptions - * @author GeLo - */ -class ZoomControl -{ - /** @var string */ - protected $controlPosition; - - /** @var string */ - protected $zoomControlStyle; - - /** - * Create a zoom control - */ - public function __construct( - $controlPosition = ControlPosition::TOP_LEFT, - $zoomControlStyle = ZoomControlStyle::DEFAULT_ - ) { - $this->setControlPosition($controlPosition); - $this->setZoomControlStyle($zoomControlStyle); - } - - /** - * Gets the control position. - * - * @return string The control position. - */ - public function getControlPosition() - { - return $this->controlPosition; - } - - /** - * Sets the control position. - * - * @param string $controlPosition The control position. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the control position is not valid. - */ - public function setControlPosition($controlPosition) - { - if (!in_array($controlPosition, ControlPosition::getControlPositions())) { - throw ControlException::invalidControlPosition(); - } - - $this->controlPosition = $controlPosition; - } - - /** - * Gets the zoom control style. - * - * @return string The zoom control style. - */ - public function getZoomControlStyle() - { - return $this->zoomControlStyle; - } - - /** - * Sets the zoom control style. - * - * @param string $zoomControlStyle The zoom control style. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the zoom control style is not valid. - */ - public function setZoomControlStyle($zoomControlStyle) - { - if (!in_array($zoomControlStyle, ZoomControlStyle::getZoomControlStyles())) { - throw ControlException::invalidZoomControlStyle(); - } - - $this->zoomControlStyle = $zoomControlStyle; - } -} diff --git a/src/Event/Event.php b/src/Event/Event.php new file mode 100644 index 00000000..e0b9d695 --- /dev/null +++ b/src/Event/Event.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Event; + +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MapsEventListener + * + * @author GeLo + */ +class Event implements VariableAwareInterface +{ + use VariableAwareTrait; + + /** + * @var string + */ + private $instance; + + /** + * @var string + */ + private $trigger; + + /** + * @var string + */ + private $handle; + + /** + * @var bool + */ + private $capture; + + /** + * @param string $instance + * @param string $trigger + * @param string $handle + * @param bool $capture + */ + public function __construct($instance, $trigger, $handle, $capture = false) + { + $this->setVariablePrefix('event'); + $this->setInstance($instance); + $this->setTrigger($trigger); + $this->setHandle($handle); + $this->setCapture($capture); + } + + /** + * @return string + */ + public function getInstance() + { + return $this->instance; + } + + /** + * @param string $instance + */ + public function setInstance($instance) + { + $this->instance = $instance; + } + + /** + * @return string + */ + public function getTrigger() + { + return $this->trigger; + } + + /** + * @param string $trigger + */ + public function setTrigger($trigger) + { + $this->trigger = $trigger; + } + + /** + * @return string + */ + public function getHandle() + { + return $this->handle; + } + + /** + * @param string $handle + */ + public function setHandle($handle) + { + $this->handle = $handle; + } + + /** + * @return bool + */ + public function isCapture() + { + return $this->capture; + } + + /** + * @param bool $capture + */ + public function setCapture($capture) + { + $this->capture = $capture; + } +} diff --git a/src/Event/EventManager.php b/src/Event/EventManager.php new file mode 100644 index 00000000..cf5574bd --- /dev/null +++ b/src/Event/EventManager.php @@ -0,0 +1,325 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Event; + +use Ivory\GoogleMap\Map; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MapsEventListener + * + * @author GeLo + */ +class EventManager +{ + /** + * @var Map|null + */ + private $map; + + /** + * @var Event[] + */ + private $domEvents = []; + + /** + * @var Event[] + */ + private $domEventsOnce = []; + + /** + * @var Event[] + */ + private $events = []; + + /** + * @var Event[] + */ + private $eventsOnce = []; + + /** + * @return bool + */ + public function hasMap() + { + return $this->map !== null; + } + + /** + * @return Map|null + */ + public function getMap() + { + return $this->map; + } + + /** + * @param Map $map + */ + public function setMap(Map $map) + { + $this->map = $map; + + if ($map->getEventManager() !== $this) { + $map->setEventManager($this); + } + } + + /** + * @return bool + */ + public function hasDomEvents() + { + return !empty($this->domEvents); + } + + /** + * @return Event[] + */ + public function getDomEvents() + { + return $this->domEvents; + } + + /** + * @param Event[] $domEvents + */ + public function setDomEvents(array $domEvents) + { + $this->domEvents = []; + $this->addDomEvents($domEvents); + } + + /** + * @param Event[] $domEvents + */ + public function addDomEvents(array $domEvents) + { + foreach ($domEvents as $domEvent) { + $this->addDomEvent($domEvent); + } + } + + /** + * @param Event $domEvent + * + * @return bool + */ + public function hasDomEvent(Event $domEvent) + { + return in_array($domEvent, $this->domEvents, true); + } + + /** + * @param Event $domEvent + */ + public function addDomEvent(Event $domEvent) + { + if (!$this->hasDomEvent($domEvent)) { + $this->domEvents[] = $domEvent; + } + } + + /** + * @param Event $domEvent + */ + public function removeDomEvent(Event $domEvent) + { + unset($this->domEvents[array_search($domEvent, $this->domEvents, true)]); + } + + /** + * @return bool + */ + public function hasDomEventsOnce() + { + return !empty($this->domEventsOnce); + } + + /** + * @return Event[] + */ + public function getDomEventsOnce() + { + return $this->domEventsOnce; + } + + /** + * @param Event[] $domEventsOnce + */ + public function setDomEventsOnce(array $domEventsOnce) + { + $this->domEventsOnce = []; + $this->addDomEventsOnce($domEventsOnce); + } + + /** + * @param Event[] $domEventsOnce + */ + public function addDomEventsOnce(array $domEventsOnce) + { + foreach ($domEventsOnce as $domEventOnce) { + $this->addDomEventOnce($domEventOnce); + } + } + + /** + * @param Event $domEventOnce + * + * @return bool + */ + public function hasDomEventOnce(Event $domEventOnce) + { + return in_array($domEventOnce, $this->domEventsOnce, true); + } + + /** + * @param Event $domEventOnce + */ + public function addDomEventOnce(Event $domEventOnce) + { + if (!$this->hasDomEventOnce($domEventOnce)) { + $this->domEventsOnce[] = $domEventOnce; + } + } + + /** + * @param Event $domEventOnce + */ + public function removeDomEventOnce(Event $domEventOnce) + { + unset($this->domEventsOnce[array_search($domEventOnce, $this->domEventsOnce, true)]); + } + + /** + * @return bool + */ + public function hasEvents() + { + return !empty($this->events); + } + + /** + * @return Event[] + */ + public function getEvents() + { + return $this->events; + } + + /** + * @param Event[] $events + */ + public function setEvents(array $events) + { + $this->events = []; + $this->addEvents($events); + } + + /** + * @param Event[] $events + */ + public function addEvents(array $events) + { + foreach ($events as $event) { + $this->addEvent($event); + } + } + + /** + * @param Event $event + * + * @return bool + */ + public function hasEvent(Event $event) + { + return in_array($event, $this->events, true); + } + + /** + * @param Event $event + */ + public function addEvent(Event $event) + { + if (!$this->hasEvent($event)) { + $this->events[] = $event; + } + } + + /** + * @param Event $event + */ + public function removeEvent(Event $event) + { + unset($this->events[array_search($event, $this->events, true)]); + } + + /** + * @return bool + */ + public function hasEventsOnce() + { + return !empty($this->eventsOnce); + } + + /** + * @return Event[] + */ + public function getEventsOnce() + { + return $this->eventsOnce; + } + + /** + * @param Event[] $eventsOnce + */ + public function setEventsOnce(array $eventsOnce) + { + $this->eventsOnce = []; + $this->addEventsOnce($eventsOnce); + } + + /** + * @param Event[] $eventsOnce + */ + public function addEventsOnce(array $eventsOnce) + { + foreach ($eventsOnce as $eventOnce) { + $this->addEventOnce($eventOnce); + } + } + + /** + * @param Event $eventOnce + * + * @return bool + */ + public function hasEventOnce(Event $eventOnce) + { + return in_array($eventOnce, $this->eventsOnce, true); + } + + /** + * @param Event $eventOnce + */ + public function addEventOnce(Event $eventOnce) + { + $this->eventsOnce[] = $eventOnce; + } + + /** + * @param Event $eventOnce + */ + public function removeEventOnce(Event $eventOnce) + { + unset($this->eventsOnce[array_search($eventOnce, $this->eventsOnce, true)]); + } +} diff --git a/src/Events/MouseEvent.php b/src/Event/MouseEvent.php similarity index 50% rename from src/Events/MouseEvent.php rename to src/Event/MouseEvent.php index b5026464..bef071d0 100644 --- a/src/Events/MouseEvent.php +++ b/src/Event/MouseEvent.php @@ -9,14 +9,12 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Events; +namespace Ivory\GoogleMap\Event; /** - * Mouse event describes the google map mouse event. - * * @author GeLo */ -class MouseEvent +final class MouseEvent { const CLICK = 'click'; const DBLCLICK = 'dblclick'; @@ -26,29 +24,9 @@ class MouseEvent const MOUSEOUT = 'mouseout'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available mouse events. - * - * @return array The mouse events. - */ - public static function getMouseEvents() + private function __construct() { - return array( - self::CLICK, - self::DBLCLICK, - self::MOUSEUP, - self::MOUSEDOWN, - self::MOUSEOVER, - self::MOUSEOUT, - ); } } diff --git a/src/Events/Event.php b/src/Events/Event.php deleted file mode 100644 index 8de5abe7..00000000 --- a/src/Events/Event.php +++ /dev/null @@ -1,167 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Events; - -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Exception\EventException; - -/** - * Event which describes a google map event. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MapsEventListener - * @author GeLo - */ -class Event extends AbstractJavascriptVariableAsset -{ - /** @var string */ - protected $instance; - - /** @var string */ - protected $eventName; - - /** @var string */ - protected $handle; - - /** @var boolean */ - protected $capture; - - /** - * Creates an event. - * - * @param string $instance The event object instance. - * @param string $eventName The event name. - * @param string $handle The event function handle. - * @param boolean $capture The event capture. - */ - public function __construct($instance = null, $eventName = null, $handle = null, $capture = false) - { - $this->setPrefixJavascriptVariable('event_'); - - if ($instance !== null) { - $this->setInstance($instance); - } - - if ($eventName !== null) { - $this->setEventName($eventName); - } - - if ($handle !== null) { - $this->setHandle($handle); - } - - $this->setCapture($capture); - } - - /** - * Gets the event object instance. - * - * @return string The event object instance. - */ - public function getInstance() - { - return $this->instance; - } - - /** - * Sets the event object instance. - * - * @param string $instance The event object instance. - * - * @throws \Ivory\GoogleMap\Exception\EventException If the instance is not valid. - */ - public function setInstance($instance) - { - if (!is_string($instance)) { - throw EventException::invalidInstance(); - } - - $this->instance = $instance; - } - - /** - * Gets the event name. - * - * @return string The event name. - */ - public function getEventName() - { - return $this->eventName; - } - - /** - * Sets the event name. - * - * @param string $eventName The event name. - * - * @throws \Ivory\GoogleMap\Exception\EventException If the event name is not valid. - */ - public function setEventName($eventName) - { - if (!is_string($eventName)) { - throw EventException::invalidEventName(); - } - - $this->eventName = $eventName; - } - - /** - * Gets the event function handle. - * - * @return string The event function handle. - */ - public function getHandle() - { - return $this->handle; - } - - /** - * Sets the event function handle. - * - * @param string $handle The event function handle. - * - * @throws \Ivory\GoogleMap\Exception\EventException If the handle is not valid. - */ - public function setHandle($handle) - { - if (!is_string($handle)) { - throw EventException::invalidHandle(); - } - - $this->handle = $handle; - } - - /** - * Checks if the event is capture. - * - * @return boolean TRUE if the event is capture else FALSE. - */ - public function isCapture() - { - return $this->capture; - } - - /** - * Sets if the event is capture. - * - * @param boolean $capture TRUE if the event is capture else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\EventException If the capture is not valid. - */ - public function setCapture($capture) - { - if (!is_bool($capture)) { - throw EventException::invalidCapture(); - } - - $this->capture = $capture; - } -} diff --git a/src/Events/EventManager.php b/src/Events/EventManager.php deleted file mode 100644 index 2fc812bc..00000000 --- a/src/Events/EventManager.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Events; - -/** - * Event manager which manages the google map event. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MapsEventListener - * @author GeLo - */ -class EventManager -{ - /** @var array */ - protected $domEvents; - - /** @var array */ - protected $domEventsOnce; - - /** @var array */ - protected $events; - - /** @var array */ - protected $eventsOnce; - - /** - * Creates an event manager. - * - * @param array $domEvents The dom events.Z - * @param array $domEventsOnce The dom events which are triggered only one time. - * @param array $events The events. - * @param array $eventsOnce The events which are triggered only one time. - */ - public function __construct( - array $domEvents = array(), - array $domEventsOnce = array(), - array $events = array(), - array $eventsOnce = array() - ) { - $this->domEvents = array(); - foreach ($domEvents as $domEvent) { - $this->addDomEvent($domEvent); - } - - $this->domEventsOnce = array(); - foreach ($domEventsOnce as $domEventOnce) { - $this->addDomEventOnce($domEventOnce); - } - - $this->events = array(); - foreach ($events as $event) { - $this->addEvent($event); - } - - $this->eventsOnce = array(); - foreach ($eventsOnce as $eventOnce) { - $this->addEventOnce($eventOnce); - } - } - - /** - * Gets the dom events. - * - * @return array The dom events. - */ - public function getDomEvents() - { - return $this->domEvents; - } - - /** - * Add a dom event. - * - * @param \Ivory\GoogleMap\Events\Event $domEvent The dom event. - */ - public function addDomEvent(Event $domEvent) - { - $this->domEvents[] = $domEvent; - } - - /** - * Gets the dom events which are just triggered one time. - * - * @return array The dom events which are just triggered one time. - */ - public function getDomEventsOnce() - { - return $this->domEventsOnce; - } - - /** - * Adds a dom event which is just triggered one time. - * - * @param \Ivory\GoogleMap\Events\Event $domEventOnce A dom event which is just triggered one time. - */ - public function addDomEventOnce(Event $domEventOnce) - { - $this->domEventsOnce[] = $domEventOnce; - } - - /** - * Gets the events. - * - * @return array The events. - */ - public function getEvents() - { - return $this->events; - } - - /** - * Adds an event. - * - * @param \Ivory\GoogleMap\Events\Event $event An event. - */ - public function addEvent(Event $event) - { - $this->events[] = $event; - } - - /** - * Gets the events which are just triggered one time. - * - * @return array The events which are just triggered one time. - */ - public function getEventsOnce() - { - return $this->eventsOnce; - } - - /** - * Adds an event which is just triggered one time. - * - * @param \Ivory\GoogleMap\Events\Event $eventOnce An event which is just triggered one time. - */ - public function addEventOnce(Event $eventOnce) - { - $this->eventsOnce[] = $eventOnce; - } -} diff --git a/src/Exception/AssetException.php b/src/Exception/AssetException.php deleted file mode 100644 index 7d63b07c..00000000 --- a/src/Exception/AssetException.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -/** - * Asset exception. - * - * @author GeLo - */ -class AssetException extends Exception -{ - /** - * Gets the "INVALID JAVASCRIPT VARIABLE" exception. - * - * @return \Ivory\GoogleMap\Exception\AssetException The "INVALID JAVASCRIPT VARIABLE" exception. - */ - public static function invalidJavascriptVariable() - { - return new static('The javascript variable must be a string value.'); - } - - /** - * Gets the "INVALID OPTION" exception. - * - * @return \Ivory\GoogleMap\Exception\AssetException The "INVALID OPTION" exception. - */ - public static function invalidOption() - { - return new static('The option property must be a string value.'); - } - - /** - * Gets the "INVALID PREFIX JAVASCRIPT VARIABLE" exception. - * - * @return \Ivory\GoogleMap\Exception\AssetException The "INVALID PREFIX JAVASCRIPT VARIABLE" exception. - */ - public static function invalidPrefixJavascriptVariable() - { - return new static('The prefix of a javascript variable must be a string value.'); - } - - /** - * Gets the "OPTION DOES NOT EXIST" exception. - * - * @param string $option The option. - * - * @return \Ivory\GoogleMap\Exception\AssetException The "OPTION DOES NOT EXIST" exception. - */ - public static function optionDoesNotExist($option) - { - return new static(sprintf('The option "%s" does not exist.', $option)); - } -} diff --git a/src/Exception/BaseException.php b/src/Exception/BaseException.php deleted file mode 100644 index eb4a6b55..00000000 --- a/src/Exception/BaseException.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -/** - * Base exception. - * - * @author GeLo - */ -class BaseException extends Exception -{ - /** - * Gets the "INVALID BOUND NORTH EAST" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID BOUND NORTH EAST" exception. - */ - public static function invalidBoundNorthEast() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The north east setter arguments is invalid.', - 'The available prototypes are :', - ' - function setNorthEast(Ivory\GoogleMap\Base\Coordinate $northEast)', - ' - function setNorthEast(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID BOUND SOUTH WEST" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID BOUND SOUTH WEST" exception. - */ - public static function invalidBoundSouthWest() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The south west setter arguments is invalid.', - 'The available prototypes are :', - ' - function setSouthWest(Ivory\GoogleMap\Base\Coordinate $southWest)', - ' - function setSouthWest(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID COORDINATE LATITUDE" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID COORDINATE LATITUDE" exception. - */ - public static function invalidCoordinateLatitude() - { - return new static('The latitude of a coordinate must be a numeric value.'); - } - - /** - * Gets the "INVALID COORDINATE LONGITUDE" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID COORDINATE LONGITUDE" exception. - */ - public static function invalidCoordinateLongitude() - { - return new static('The longitude of a coordinate must be a numeric value.'); - } - - /** - * Gets the "INVALID COORDINATE NO WRAP" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID COORDINATE NO WRAP" exception. - */ - public static function invalidCoordinateNoWrap() - { - return new static('The no wrap coordinate property must be a boolean value.'); - } - - /** - * Gets the "INVALID POINT X" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID POINT X" exception. - */ - public static function invalidPointX() - { - return new static('The x coordinate of a point must be a numeric value.'); - } - - /** - * Gets the "INVALID POINT Y" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID POINT Y" exception. - */ - public static function invalidPointY() - { - return new static('The y coordinate of a point must be a numeric value.'); - } - - /** - * Gets the "INVALID SIZE HEIGHT" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID SIZE HEIGHT" exception. - */ - public static function invalidSizeHeight() - { - return new static('The height of a size must be a numeric value.'); - } - - /** - * Gets the "INVALID SIZE HEIGHT UNIT" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID SIZE HEIGHT UNIT" exception. - */ - public static function invalidSizeHeightUnit() - { - return new static('The height unit of a size must be a string value.'); - } - - /** - * Gets the "INVALID SIZE WIDTH" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID SIZE WIDTH" exception. - */ - public static function invalidSizeWidth() - { - return new static('The width of a size must be a numeric value.'); - } - - /** - * Gets the "INVALID SIZE WIDTH UNIT" exception. - * - * @return \Ivory\GoogleMap\Exception\BaseException The "INVALID SIZE WIDTH UNIT" exception. - */ - public static function invalidSizeWidthUnit() - { - return new static('The width unit of a size must be a string value.'); - } -} diff --git a/src/Exception/ControlException.php b/src/Exception/ControlException.php deleted file mode 100644 index 541e0050..00000000 --- a/src/Exception/ControlException.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\Controls\ScaleControlStyle; -use Ivory\GoogleMap\Controls\ZoomControlStyle; -use Ivory\GoogleMap\MapTypeId; - -/** - * Control exception. - * - * @author GeLo - */ -class ControlException extends Exception -{ - /** - * Gets the "INVALID CONTROL POSITION" exception. - * - * @return \Ivory\GoogleMap\Exception\ControlException The "INVALID CONTROL POSITION" exception. - */ - public static function invalidControlPosition() - { - return new static(sprintf( - 'The control position can only be : %s.', - implode(', ', ControlPosition::getControlPositions()) - )); - } - - /** - * Gets the "INVALID MAP TYPE CONTROL STYLE" exception. - * - * @return \Ivory\GoogleMap\Exception\ControlException The "INVALID MAP TYPE CONTROL STYLE" exception. - */ - public static function invalidMapTypeControlStyle() - { - return new static(sprintf( - 'The map type control style can only be : %s.', - implode(', ', MapTypeControlStyle::getMapTypeControlStyles()) - )); - } - - /** - * Gets the "INVALID MAP TYPE ID" exception. - * - * @return \Ivory\GoogleMap\Exception\ControlException The "INVALID MAP TYPE ID" exception. - */ - public static function invalidMapTypeId() - { - return new static(sprintf('The map type id can only be : %s.', implode(', ', MapTypeId::getMapTypeIds()))); - } - - /** - * Gets the "INVALID OVERVIEW MAP CONTROL OPENED" exception. - * - * @return \Ivory\GoogleMap\Exception\ControlException The "INVALID OVERVIEW MAP CONTROL OPENED" exception. - */ - public static function invalidOverviewMapControlOpened() - { - return new static('The opened property of an overview map control must be a boolean value.'); - } - - /** - * Gets the "INVALID SCALE CONTROL STYLE" exception. - * - * @return \Ivory\GoogleMap\Exception\ControlException The "INVALID SCALE CONTROL STYLE" exception. - */ - public static function invalidScaleControlStyle() - { - return new static(sprintf( - 'The scale control style of a scale control can only be : %s.', - implode(', ', ScaleControlStyle::getScaleControlStyles()) - )); - } - - /** - * Gets the "INVALID ZOOM CONTROL STYLE" exception. - * - * @return \Ivory\GoogleMap\Exception\ControlException The "INVALID ZOOM CONTROL STYLE" exception. - */ - public static function invalidZoomControlStyle() - { - return new static(sprintf( - 'The zoom control style of a zoom control can only be : %s.', - implode(', ', ZoomControlStyle::getZoomControlStyles()) - )); - } -} diff --git a/src/Exception/DirectionsException.php b/src/Exception/DirectionsException.php deleted file mode 100644 index 4a726d60..00000000 --- a/src/Exception/DirectionsException.php +++ /dev/null @@ -1,328 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -use Ivory\GoogleMap\Services\Directions\DirectionsStatus; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; - -/** - * Directions exception. - * - * @author GeLo - */ -class DirectionsException extends ServiceException -{ - /** - * Gets the "INVALID DIRECTIONS LEG END ADDRESS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS LEG END ADDRESS" exception. - */ - public static function invalidDirectionsLegEndAddress() - { - return new static('The leg end address must be a string value.'); - } - - /** - * Gets the "INVALID DIRECTIONS LEG START ADDRESS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS LEG START ADDRESS" exception. - */ - public static function invalidDirectionsLegStartAddress() - { - return new static('The leg start address must be a string value.'); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST" exception. - */ - public static function invalidDirectionsRequest() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The directions request is not valid. It needs at least an origin and a destination.', - 'If you add waypoint to the directions request, it needs at least a location.', - 'If travel mode is "TRANSIT", it needs either a departure time or an arrival time.' - )); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST PARAMETERS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST PARAMETERS" exception. - */ - public static function invalidDirectionsRequestParameters() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The route arguments are invalid.', - 'The available prototypes are:', - '- function route(string $origin, string $destination)', - '- function route(Ivory\GoogleMap\Services\Directions\DirectionsRequest $request)' - )); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST AVOID HIGHWAYS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST AVOID HIGHWAYS" exception. - */ - public static function invalidDirectionsRequestAvoidHighways() - { - return new static('The directions request avoid hightways flag must be a boolean value.'); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST AVOID TOLLS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST AVOID TOLLS" exception. - */ - public static function invalidDirectionsRequestAvoidTolls() - { - return new static('The directions request avoid tolls flag must be a boolean value.'); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST DESTINATION" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST DESTINATION" exception. - */ - public static function invalidDirectionsRequestDestination() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The destination setter arguments are invalid.', - 'The available prototypes are :', - ' - function setDestination(string $destination)', - ' - function setDestination(Ivory\GoogleMap\Base\Coordinate $destination)', - ' - function setDestination(double $latitude, double $longitude, boolean $noWrap)' - )); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST OPTIMIZE WAYPOINTS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST OPTIMIZE WAYPOINTS" - * exception. - */ - public static function invalidDirectionsRequestOptimizeWaypoints() - { - return new static('The directions request optimize waypoints flag must be a boolean value.'); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST ORIGIN" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST ORIGIN" exception. - */ - public static function invalidDirectionsRequestOrigin() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The origin setter arguments are invalid.', - 'The available prototypes are :', - ' - function setOrigin(string $destination)', - ' - function setOrigin(Ivory\GoogleMap\Base\Coordinate $destination)', - ' - function setOrigin(double $latitude, double $longitude, boolean $noWrap)' - )); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST PROVIDE ROUTE ALTERNATIVES" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST PROVIDE ROUTE - * ALTERNATIVES" exception. - */ - public static function invalidDirectionsRequestProvideRouteAlternatives() - { - return new static('The directions request provide route alternatives flag must be a boolean value.'); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST REGION" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST REGION" exception. - */ - public static function invalidDirectionsRequestRegion() - { - return new static('The directions request region must be a string with two characters.'); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST LANGUAGE" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST LANGUAGE" exception. - */ - public static function invalidDirectionsRequestLanguage() - { - return new static('The directions request language must be a string with two or five characters.'); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST SENSOR" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST SENSOR" exception. - */ - public static function invalidDirectionsRequestSensor() - { - return new static('The directions request sensor flag must be a boolean value.'); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST TRAVEL MODE" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST TRAVEL MODE" exception. - */ - public static function invalidDirectionsRequestTravelMode() - { - return new static(sprintf( - 'The directions request travel mode can only be : %s.', - implode(', ', TravelMode::getTravelModes()) - )); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST UNIT SYSTEM" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST UNIT SYSTEM" exception. - */ - public static function invalidDirectionsRequestUnitSystem() - { - return new static(sprintf( - 'The directions request unit system can only be : %s.', - implode(', ', UnitSystem::getUnitSystems()) - )); - } - - /** - * Gets the "INVALID DIRECTIONS REQUEST WAYPOINT" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS REQUEST WAYPOINT" exception. - */ - public static function invalidDirectionsRequestWaypoint() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The waypoint adder arguments are invalid.', - 'The available prototypes are :', - ' - function addWaypoint(Ivory\GoogleMap\Services\Directions\DirectionsWaypoint $waypoint)', - ' - function addWaypoint(string $location)', - ' - function addWaypoint(Ivory\GoogleMap\Base\Coordinate $location)', - ' - function addWaypoint(double $latitude, double $longitude, boolean $noWrap)' - )); - } - - /** - * Gets the "INVALID DIRECTIONS RESPONSE STATUS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS RESPONSE STATUS" exception. - */ - public static function invalidDirectionsResponseStatus() - { - return new static(sprintf( - 'The directions response status can only be : %s.', - implode(', ', DirectionsStatus::getDirectionsStatus()) - )); - } - - /** - * Gets the "INVALID DIRECTIONS ROUTE COPYRIGHTS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS ROUTE COPYRIGHTS" exception. - */ - public static function invalidDirectionsRouteCopyrights() - { - return new static('The directions route copyrights must be a string value.'); - } - - /** - * Gets the "INVALID DIRECTIONS ROUTE SUMMARY" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS ROUTE SUMMARY" exception. - */ - public static function invalidDirectionsRouteSummary() - { - return new static('The directions route summary must be a string value.'); - } - - /** - * Gets the "INVALID DIRECTIONS ROUTE WARNING" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS ROUTE WARNING" exception. - */ - public static function invalidDirectionsRouteWarning() - { - return new static('The directions route warning must be a string value.'); - } - - /** - * Gets the "INVALID DIRECTIONS ROUTE WAYPOINT ORDER" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS ROUTE WAYPOINT ORDER" exception. - */ - public static function invalidDirectionsRouteWaypointOrder() - { - return new static('The directions route waypoint order must be an integer value.'); - } - - /** - * Gets the "INALID DIRECTIONS STEP INSTRUCTIONS" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INALID DIRECTIONS STEP INSTRUCTIONS" exception. - */ - public static function invalidDirectionsStepInstructions() - { - return new static('The step instructions must be a string value.'); - } - - /** - * Gets the "INVALID DIRECTIONS STEP TRAVEL MODE" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS STEP TRAVEL MODE" exception. - */ - public static function invalidDirectionsStepTravelMode() - { - return new static(sprintf( - 'The directions step travel mode can only be : %s.', - implode(', ', TravelMode::getTravelModes()) - )); - } - - /** - * Gets the "INVALID DIRECTIONS WAYPOINT LOCATION" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS WAYPOINT LOCATION" exception. - */ - public static function invalidDirectionsWaypointLocation() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The location setter arguments are invalid.', - 'The available prototypes are :', - ' - function setLocation(string $destination)', - ' - function setLocation(Ivory\GoogleMap\Base\Coordinate $destination)', - ' - function setLocation(double $latitude, double $longitude, boolean $noWrap)' - )); - } - - /** - * Gets the "INVALID DIRECTIONS WAYPOINT STOPOPVER" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS WAYPOINT STOPOPVER" exception. - */ - public static function invalidDirectionsWaypointStopover() - { - return new static('The directions waypoint stopover flag must be a boolean value.'); - } -} diff --git a/src/Exception/DistanceMatrixException.php b/src/Exception/DistanceMatrixException.php deleted file mode 100644 index 09ada47e..00000000 --- a/src/Exception/DistanceMatrixException.php +++ /dev/null @@ -1,190 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixStatus; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixElementStatus; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; - -/** - * DistanceMatrix exception. - * - * @author GeLo - * @author Tyler Sommer - */ -class DistanceMatrixException extends ServiceException -{ - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST" exception. - */ - public static function invalidDistanceMatrixRequest() - { - return new static('The directions request is not valid. It needs at least one origin and one destination.'); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST PARAMETERS" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST PARAMETERS" exception. - */ - public static function invalidDistanceMatrixRequestParameters() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The process arguments are invalid.', - 'The available prototypes are:', - '- function process(array $origins, array $destinations)', - '- function process(Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest $request)' - )); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST DESTINATION" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST DESTINATION" exception. - */ - public static function invalidDistanceMatrixRequestDestination() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The destination adder arguments are invalid.', - 'The available prototypes are :', - ' - function addDestination(string $destination)', - ' - function addDestination(Ivory\GoogleMap\Base\Coordinate $destination)', - ' - function addDestination(double $latitude, double $longitude, boolean $noWrap)' - )); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST ORIGIN" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST ORIGIN" exception. - */ - public static function invalidDistanceMatrixRequestOrigin() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The origin adder arguments are invalid.', - 'The available prototypes are :', - ' - function addOrigin(string $origin)', - ' - function addOrigin(Ivory\GoogleMap\Base\Coordinate $origin)', - ' - function addOrigin(double $latitude, double $longitude, boolean $noWrap)' - )); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST REGION" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST REGION" exception. - */ - public static function invalidDistanceMatrixRequestRegion() - { - return new static('The distance matrix request region must be a string with two characters.'); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST LANGUAGE" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST LANGUAGE" exception. - */ - public static function invalidDistanceMatrixRequestLanguage() - { - return new static('The distance matrix request language must be a string with two or five characters.'); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST SENSOR" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST SENSOR" exception. - */ - public static function invalidDistanceMatrixRequestSensor() - { - return new static('The distance matrix request sensor flag must be a boolean value.'); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST TRAVEL MODE" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST TRAVEL MODE" exception. - */ - public static function invalidDistanceMatrixRequestTravelMode() - { - $travelModes = array_diff(TravelMode::getTravelModes(), array(TravelMode::TRANSIT)); - - return new static(sprintf( - 'The distance matrix request travel mode can only be : %s.', - implode(', ', $travelModes) - )); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST UNIT SYSTEM" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST UNIT SYSTEM" exception. - */ - public static function invalidDistanceMatrixRequestUnitSystem() - { - return new static(sprintf( - 'The distance matrix request unit system can only be : %s.', - implode(', ', UnitSystem::getUnitSystems()) - )); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST AVOID HIGHWAYS" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST AVOID HIGHWAYS" exception. - */ - public static function invalidDistanceMatrixRequestAvoidHighways() - { - return new static('The distance matrix request avoid hightways flag must be a boolean value.'); - } - - /** - * Gets the "INVALID DISTANCE MATRIX REQUEST AVOID TOLLS" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST AVOID TOLLS" exception. - */ - public static function invalidDistanceMatrixRequestAvoidTolls() - { - return new static('The distance matrix request avoid tolls flag must be a boolean value.'); - } - - /** - * Gets the "INVALID DISTANCE MATRIX RESPONSE STATUS" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX RESPONSE STATUS" exception. - */ - public static function invalidDistanceMatrixResponseStatus() - { - return new static(sprintf( - 'The distance matrix response status can only be : %s.', - implode(', ', DistanceMatrixStatus::getDistanceMatrixStatus()) - )); - } - - /** - * Gets the "INVALID DISTANCE MATRIX RESPONSE ELEMENT STATUS" exception. - * - * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX RESPONSE ELEMENT STATUS" exception. - */ - public static function invalidDistanceMatrixResponseElementStatus() - { - return new static(sprintf( - 'The distance matrix response element status can only be : %s.', - implode(', ', DistanceMatrixElementStatus::getDistanceMatrixElementStatus()) - )); - } -} diff --git a/src/Exception/EventException.php b/src/Exception/EventException.php deleted file mode 100644 index 17a80134..00000000 --- a/src/Exception/EventException.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -/** - * Event exception. - * - * @author GeLo - */ -class EventException extends Exception -{ - /** - * Gets the "INVALID CAPTURE" exception. - * - * @return \Ivory\GoogleMap\Exception\EventException The "INVALID CAPTURE" exception. - */ - public static function invalidCapture() - { - return new static('The capture property of an event must be a boolean value.'); - } - - /** - * Gets the "INVALID EVENT NAME" exception. - * - * @return \Ivory\GoogleMap\Exception\EventException The "INVALID EVENT NAME" exception. - */ - public static function invalidEventName() - { - return new static('The event name of an event must be a string value.'); - } - - /** - * Gets the "INVALID HANDLE" exception. - * - * @return \Ivory\GoogleMap\Exception\EventException The "INVALID HANDLE" exception. - */ - public static function invalidHandle() - { - return new static('The handle of an event must be a string value.'); - } - - /** - * Gets the "INVALID INSTANCE" exception. - * - * @return \Ivory\GoogleMap\Exception\EventException The "INVALID INSTANCE" exception. - */ - public static function invalidInstance() - { - return new static('The instance of an event must be a string value.'); - } -} diff --git a/src/Exception/GeocodingException.php b/src/Exception/GeocodingException.php deleted file mode 100644 index 6fca2e09..00000000 --- a/src/Exception/GeocodingException.php +++ /dev/null @@ -1,254 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderLocationType; -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderStatus; - -/** - * Geocoding exception. - * - * @author GeLo - */ -class GeocodingException extends ServiceException -{ - /** - * Gets the "INVALID GEOCODER ADDRESS COMPONENT LONG NAME" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER ADDRESS COMPONENT LONG NAME" - * exception. - */ - public static function invalidGeocoderAddressComponentLongName() - { - return new static('The geocoder address component long name must be a string value.'); - } - - /** - * Gets the "INVALID GEOCODER ADDRESS COMPONENT SHORT NAME" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER ADDRESS COMPONENT SHORT NAME" - * exception. - */ - public static function invalidGeocoderAddressComponentShortName() - { - return new static('The geocoder address component short name must be a string value.'); - } - - /** - * Gets the "INVALID GEOCODER ADDRESS COMPONENT TYPE" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER ADDRESS COMPONENT TYPE" exception. - */ - public static function invalidGeocoderAddressComponentType() - { - return new static('The geocoder address component type must be a string value.'); - } - - /** - * Gets the "INVALID GEOCODER LOCATION TYPE" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER LOCATION TYPE" exception. - */ - public static function invalidGeocoderLocationType() - { - return new static(sprintf( - 'The geocoder geometry location type can only be : %s.', - implode(', ', GeocoderLocationType::getGeocoderLocationTypes()) - )); - } - - /** - * Gets the "INVALID GEOCODER PROVIDER FORMAT" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER PROVIDER FORMAT" exception. - */ - public static function invalidGeocoderProviderFormat() - { - return new static(sprintf( - 'The geocoder provider format can only be : %s.', - implode(', ', array('json', 'xml')) - )); - } - - /** - * Gets the "INVALID GEOCODER PROVIDER HTTPS" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER PROVIDER HTTPS" exception. - */ - public static function invalidGeocoderProviderHttps() - { - return new static('The geocoder provider https flag must be a boolean value.'); - } - - /** - * Gets the "INVALID GEOCODER PROVIDER REQUEST" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER PROVIDER REQUEST" exception. - */ - public static function invalidGeocoderProviderRequest() - { - return new static('The geocoder request is not valid. It needs at least an address or a coordinate.'); - } - - /** - * Gets the "INVALID GEOCODER PROVIDER REQUEST ARGUMENTS" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER PROVIDER REQUEST ARGUMENTS" - * exception. - */ - public static function invalidGeocoderProviderRequestArguments() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The geolocate argument is invalid.', - 'The available prototypes are :', - ' - function geocode(string $address)', - ' - function geocode(Ivory\GoogleMap\Services\Geocoding\GeocoderRequest $request)' - )); - } - - /** - * Gets the "INVALID GEOCODER PROVIDER URL" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER PROVIDER URL" exception. - */ - public static function invalidGeocoderProviderUrl() - { - return new static('The geocoder provider url must be a string value.'); - } - - /** - * Gets the "INVALID GEOCODER REQUEST ADDRESS" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER REQUEST ADDRESS" exception. - */ - public static function invalidGeocoderRequestAddress() - { - return new static('The geocoder request address must be a string value.'); - } - - /** - * Gets the "INVALID GEOCODER REQUEST BOUND" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER REQUEST BOUND" exception. - */ - public static function invalidGeocoderRequestBound() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The bound setter arguments are invalid.', - 'The available prototypes are :', - ' - function setBound(Ivory\GoogleMap\Base\Bound $bound = null)', - ' - function setBound('. - 'Ivory\GoogleMap\Base\Coordinate $southWest, '. - 'Ivory\GoogleMap\Base\Coordinate $northEast'. - ')', - ' - function setBound('. - 'double $southWestLatitude, '. - 'double $southWestLongitude, '. - 'double $northEastLatitude, '. - 'double $northEastLongitude, '. - 'boolean southWestNoWrap = true, '. - 'boolean $northEastNoWrap = true'. - ')' - )); - } - - /** - * Gets the "INVALID GEOCODER REQUEST COORDINATE" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER REQUEST COORDINATE" exception. - */ - public static function invalidGeocoderRequestCoordinate() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The coordinate setter arguments is invalid.', - 'The available prototypes are :', - ' - function setCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate = null)', - ' - function setCoordinate(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID GEOCODER REQUEST REGION" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER REQUEST REGION" exception. - */ - public static function invalidGeocoderRequestRegion() - { - return new static('The geocoder request region must be a string with two characters.'); - } - - /** - * Gets the "INVALID GEOCODER REQUEST LANGUAGE" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER REQUEST LANGUAGE" exception. - */ - public static function invalidGeocoderRequestLanguage() - { - return new static('The geocoder request language must be a string with two or five characters.'); - } - - /** - * Gets the "INVALID GEOCODER REQUEST SENSOR" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER REQUEST SENSOR" exception. - */ - public static function invalidGeocoderRequestSensor() - { - return new static('The geocoder request sensor flag must be a boolean value.'); - } - - /** - * Gets the "INVALID GEOCODER RESPONSE STATUS" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER RESPONSE STATUS" exception. - */ - public static function invalidGeocoderResponseStatus() - { - return new static(sprintf( - 'The geocoder response status can only be : %s.', - implode(', ', GeocoderStatus::getGeocoderStatus()) - )); - } - - /** - * Gets the "INVALID GEOCODER RESULT FORMATTED ADDRESS" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER RESULT FORMATTED ADDRESS" exception. - */ - public static function invalidGeocoderResultFormattedAddress() - { - return new static('The geocoder result formatted address must be a string value.'); - } - - /** - * Gets the "INVALID GEOCODER RESULT PARTIAL MATCH" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER RESULT PARTIAL MATCH" exception. - */ - public static function invalidGeocoderResultPartialMatch() - { - return new static('The geocoder result partial match flag must be a boolean value.'); - } - - /** - * Gets the "INVALID GEOCODER RESULT TYPE" exception. - * - * @return \Ivory\GoogleMap\Exception\GeocodingException The "INVALID GEOCODER RESULT TYPE" exception. - */ - public static function invalidGeocoderResultType() - { - return new static('The geocoder result type must be a string value.'); - } -} diff --git a/src/Exception/HelperException.php b/src/Exception/HelperException.php deleted file mode 100644 index d43db1fb..00000000 --- a/src/Exception/HelperException.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\Controls\ScaleControlStyle; -use Ivory\GoogleMap\Controls\ZoomControlStyle; -use Ivory\GoogleMap\Overlays\Animation; -use Ivory\GoogleMap\MapTypeId; - -/** - * Helper exception. - * - * @author GeLo - */ -class HelperException extends Exception -{ - /** - * Gets the "INVALID ANIMATION" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID ANIMATION" exception. - */ - public static function invalidAnimation() - { - return new static(sprintf('The animation can only be : %s.', implode(', ', Animation::getAnimations()))); - } - - /** - * Gets the "INVALID AUTOCOMPLETE BOUND" exception. - * - * @return \Ivory\GoogleMap\Exception\TemplatingException The "INVALID AUTOCOMPLETE BOUND" exception. - */ - public static function invalidAutocompleteBound() - { - return new static('The place autocomplete bound must have coordinates.'); - } - - /** - * Gets the "INVALID CONTROL POSITION" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID CONTROL POSITION" exception. - */ - public static function invalidControlPosition() - { - return new static(sprintf( - 'The control position can only be : %s.', - implode(', ', ControlPosition::getControlPositions()) - )); - } - - /** - * Gets the "INVALID ENCODED PATH" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID ENCODED PATH" exception. - */ - public static function invalidEncodedPath() - { - return new static('The encoded path must be a string value.'); - } - - /** - * Gets the "INVALID EXTENSION" exception. - * - * @param string $name The "INVALID EXTENSION" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID EXTENSION" exception. - */ - public static function invalidExtension($name) - { - return new static(sprintf('The extension helper "%s" does not exist.', $name)); - } - - /** - * Gets the "INVALID MAP TYPE CONTROL STYLE" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID MAP TYPE CONTROL STYLE" exception. - */ - public static function invalidMapTypeControlStyle() - { - return new static(sprintf( - 'The map type control style can only be : %s.', - implode(', ', MapTypeControlStyle::getMapTypeControlStyles()) - )); - } - - /** - * Gets the "INVALID MAP TYPE ID" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID MAP TYPE ID" exception. - */ - public static function invalidMapTypeId() - { - return new static(sprintf('The map type id can only be : %s.', implode(', ', MapTypeId::getMapTypeIds()))); - } - - /** - * Gets the "INVALID MARKER CLUSTER HELPER" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID MARKER CLUSTER HELPER" exception. - */ - public static function invalidMarkerClusterHelper() - { - return new static('The marker cluster helper can not be resolved.'); - } - - /** - * Gets the "INVALID SCALE CONTROL STYLE" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID SCALE CONTROL STYLE" exception. - */ - public static function invalidScaleControlStyle() - { - return new static(sprintf( - 'The scale control style can only be : %s.', - implode(', ', ScaleControlStyle::getScaleControlStyles()) - )); - } - - /** - * Gets the "INVALID ZOOM CONTROL STYLE" exception. - * - * @return \Ivory\GoogleMap\Exception\HelperException The "INVALID ZOOM CONTROL STYLE" exception. - */ - public static function invalidZoomControlStyle() - { - return new static(sprintf( - 'The zoom control style can only be : %s.', - implode(', ', ZoomControlStyle::getZoomControlStyles()) - )); - } -} diff --git a/src/Exception/LayerException.php b/src/Exception/LayerException.php deleted file mode 100644 index fca53820..00000000 --- a/src/Exception/LayerException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -/** - * Layer exception. - * - * @author GeLo - */ -class LayerException extends Exception -{ - /** - * Gets the "INVALID KML LAYER URL" exception. - * - * @return \Ivory\GoogleMap\Exception\LayerException The "INVALID KML LAYER URL" exception. - */ - public static function invalidKmlLayerUrl() - { - return new static('The kml layer url must be a string value.'); - } -} diff --git a/src/Exception/MapException.php b/src/Exception/MapException.php deleted file mode 100644 index fcb13bb1..00000000 --- a/src/Exception/MapException.php +++ /dev/null @@ -1,249 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -/** - * Ivory google map exception. - * - * @author GeLo - */ -class MapException extends Exception -{ - /** - * Gets the "INVALID ASYNC" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID ASYNC" exception. - */ - public static function invalidAsync() - { - return new static('The asynchronous load of a map must be a boolean value.'); - } - - /** - * Gets the "INVALID AUTO ZOOM" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID AUTO ZOOM" exception. - */ - public static function invalidAutoZoom() - { - return new static('The auto zoom of a map must be a boolean value.'); - } - - /** - * Gets the "INVALID BOUND" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID BOUND" exception. - */ - public static function invalidBound() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The bound setter arguments is invalid.', - 'The available prototypes are :', - ' - function setBound(Ivory\GoogleMap\Base\Bound $bound)', - ' - function setBount('. - 'Ivory\GoogleMap\Base\Coordinate $southWest, '. - 'Ivory\GoogleMap\Base\Coordinate $northEast'. - ')', - ' - function setBound('. - 'double $southWestLatitude, '. - 'double $southWestLongitude, '. - 'double $northEastLatitude, '. - 'double $northEastLongitude, '. - 'boolean southWestNoWrap = true, '. - 'boolean $northEastNoWrap = true'. - ')' - )); - } - - /** - * Gets the "INVALID CENTER" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID CENTER" exception. - */ - public static function invalidCenter() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The center setter arguments is invalid.', - 'The available prototypes are :', - ' - function setCenter(Ivory\GoogleMap\Base\Coordinate $center)', - ' - function setCenter(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID HTML CONTAINER ID" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID HTML CONTAINER ID" exception. - */ - public static function invalidHtmlContainerId() - { - return new static('The html container id of a map must be a string value.'); - } - - /** - * Gets the "INVALID MAP OPTION" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID MAP OPTION" exception. - */ - public static function invalidMapOption() - { - return new static('The map option property of a map must be a string value.'); - } - - /** - * Gets the "INVALID MAP TYPE CONTROL" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INAVLID MAP TYPE CONTROL" exception. - */ - public static function invalidMapTypeControl() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The map type control setter arguments is invalid.', - 'The available prototypes are :', - ' - function setMapTypeControl(Ivory\GoogleMap\Controls\MapTypeControl $mapTypeControl = null)', - ' - function setMaptypeControl(array $mapTypeIds, string $controlPosition, string $mapTypeControlStyle)' - )); - } - - /** - * Gets the "INVALID OVERVIEW MAP CONTROL" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID OVERVIEW MAP CONTROL" exception. - */ - public static function invalidOverviewMapControl() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The overview map control setter arguments is invalid.', - 'The available prototypes are :', - ' - function setOverviewMapControl(Ivory\GoogleMap\Controls\OverviewMapControl $overviewMapControl = null)', - ' - function setOverviewMapControl(boolean $opened)' - )); - } - - /** - * Gets the "INVALID PAN CONTROL" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID PAN CONTROL" exception. - */ - public static function invalidPanControl() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The pan control setter arguments is invalid.', - 'The available prototypes are :', - ' - function setPanControl(Ivory\GoogleMap\Controls\PanControl $panControl = null)', - ' - function setPanControl(string $controlPosition)' - )); - } - - /** - * Gets the "INVALID ROTATE CONTROL" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID ROTATE CONTROL" exception. - */ - public static function invalidRotateControl() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The rotate control setter arguments is invalid.', - 'The available prototypes are :', - ' - function setRotateControl(Ivory\GoogleMap\Controls\RotateControl $rotateControl = null)', - ' - function setRotateControl(string $controlPosition)' - )); - } - - /** - * Gets the "INVALID SCALE CONTROL" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID SCALE CONTROL" exception. - */ - public static function invalidScaleControl() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The scale control setter arguments is invalid.', - 'The available prototypes are :', - ' - function setScaleControl(Ivory\GoogleMap\Controls\ScaleControl $scaleControl = null)', - ' - function setScaleControl(string $controlPosition, string $scaleControlStyle)' - )); - } - - /** - * Gets the "INVALID STREET VIEW CONTROL" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID STREET VIEW CONTROL" exception. - */ - public static function invalidStreetViewControl() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The street view control setter arguments is invalid.', - 'The available prototypes are :', - ' - function setStreetViewControl(Ivory\GoogleMap\Controls\StreetViewControl $streetViewControl = null)', - ' - function setStreetViewControl(string $controlPosition)' - )); - } - - /** - * Gets the "INVALID ZOOM CONTROL" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INVALID ZOOM CONTROL" exception. - */ - public static function invalidZoomControl() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The zoom control setter arguments is invalid.', - 'The available prototypes are :', - ' - function setZoomControl(Ivory\GoogleMap\Controls\ZoomControl $zoomControl = null)', - ' - function setZoomControl(string $controlPosition, string $zoomControlStyle)' - )); - } - - /** - * Gets the "INVALID STYLESHEET OPTION" exception. - * - * @return \Ivory\GoogleMap\Exception\MapException The "INAVLID STYLESHEET OPTION" exception. - */ - public static function invalidStylesheetOption() - { - return new static('The stylesheet option property of a map must be a string value.'); - } - - /** - * Gets the "MAP OPTION DOES NOT EXIST" exception. - * - * @param string $mapOption The map option. - * - * @return \Ivory\GoogleMap\Exception\MapException The "MAP OPTION DOES NOT EXIST" exception. - */ - public static function mapOptionDoesNotExist($mapOption) - { - return new static(sprintf('The map option "%s" does not exist.', $mapOption)); - } - - /** - * Gets the "STYLESHEET OPTION DOES NOT EXIST" exception. - * - * @param string $stylesheetOption The stylesheet option. - * - * @return \Ivory\GoogleMap\Exception\MapException The "STYLESHEET OPTION DOES NOT EXIST" exception. - */ - public static function stylesheetOptionDoesNotExist($stylesheetOption) - { - return new static(sprintf('The stylesheet option "%s" does not exist.', $stylesheetOption)); - } -} diff --git a/src/Exception/OverlayException.php b/src/Exception/OverlayException.php deleted file mode 100644 index bf9abbb5..00000000 --- a/src/Exception/OverlayException.php +++ /dev/null @@ -1,536 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -use Ivory\GoogleMap\Events\MouseEvent; -use Ivory\GoogleMap\Overlays\Animation; - -/** - * Overlay exception. - * - * @author GeLo - */ -class OverlayException extends Exception -{ - /** - * Gets the "INVALID CIRCLE CENTER" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID CIRCLE CENTER" exception. - */ - public static function invalidCircleCenter() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The center setter arguments is invalid.', - 'The available prototypes are :', - ' - function setCenter(Ivory\GoogleMap\Base\Coordinate $center)', - ' - function setCenter(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID CIRCLE RADIUS" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID CIRCLE RADIUS" exception. - */ - public static function invalidCircleRadius() - { - return new static('The radius of a circle must be a numeric value.'); - } - - /** - * Gets the "INVALID ENCODED POLYLINE VALUE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID ENCODED POLYLINE VALUE" exception. - */ - public static function invalidEncodedPolylineValue() - { - return new static('The encoded polyline value must be a string value.'); - } - - /** - * Gets the "INVALID GROUND OVERLAY BOUND COORDINATES" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID GROUND OVERLAY BOUND COORDINATES" exception. - */ - public static function invalidGroundOverlayBoundCoordinates() - { - return new static('A ground overlay bound must have a south west & a north east coordinate.'); - } - - /** - * Gets the "INVALID GROUND OVERLAY URL" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID GROUND OVERLAY URL" exception. - */ - public static function invalidGroundOverlayUrl() - { - return new static('The url of a ground overlay must be a string value.'); - } - - /** - * Gets the "INVALID GROUND OVERLAY" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID GROUND OVERLAY" exception. - */ - public static function invalidGroundOverlayBound() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The bound setter arguments is invalid.', - 'The available prototypes are :', - ' - public function setBound(Ivory\GoogleMapBundle\Model\Base\Bound $bound)', - ' - public function setBount('. - 'Ivory\GoogleMapBundle\Model\Base\Coordinate $southWest, '. - 'Ivory\GoogleMapBundle\Model\Base\Coordinate $northEast'. - ')', - ' - public function setBound('. - 'double $southWestLatitude, '. - 'double $southWestLongitude, '. - 'double $northEastLatitude, '. - 'double $northEastLongitude, '. - 'boolean southWestNoWrap = true, '. - 'boolean $northEastNoWrap = true'. - ')' - )); - } - - /** - * Gets the "INVALID INFO WINDOW AUTO CLOSE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID INFO WINDOW AUTO CLOSE" exception. - */ - public static function invalidInfoWindowAutoClose() - { - return new static('The info window auto close flag must be a boolean value.'); - } - - /** - * Gets the "INVALID INFO WINDOW AUTO OPEN" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID INFO WINDOW AUTO OPEN" exception. - */ - public static function invalidInfoWindowAutoOpen() - { - return new static('The auto open property of an info window must be a boolean value.'); - } - - /** - * Gets the "INVALID INFO WINDOW CONTENT" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID INFO WINDOW CONTENT" exception. - */ - public static function invalidInfoWindowContent() - { - return new static('The content of an info window must be a string value.'); - } - - /** - * Gets the "INVALID INFO WINDOW OPEN" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID INFO WINDOW OPEN" exception. - */ - public static function invalidInfoWindowOpen() - { - return new static('The open property of an info window must be a boolean value.'); - } - - /** - * Gets the "INVALID INFO WINDOW OPEN EVENT" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID INFO WINDOW OPEN EVENT" exception. - */ - public static function invalidInfoWindowOpenEvent() - { - return new static(sprintf( - 'The only available open event are : %s.', - implode(', ', MouseEvent::getMouseEvents()) - )); - } - - /** - * Gets the "INVALID INFO WINDOW POSITION" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID INFO WINDOW POSITION" exception. - */ - public static function invalidInfoWindowPosition() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The position setter arguments is invalid.', - 'The available prototypes are :', - ' - function setPosition(Ivory\GoogleMap\Base\Coordinate $position)', - ' - function setPosition(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID INFO WINDOW PIXEL OFFSET" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID INFO WINDOW PIXEL OFFSET" exception. - */ - public static function invalidInfoWindowPixelOffset() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The pixel offset setter arguments is invalid.', - 'The available prototypes are :', - ' - function setPixelOffset(Ivory\GoogleMap\Base\Size $scaledSize)', - ' - function setPixelOffset('. - 'double $width, '. - 'double $height, '. - 'string $widthUnit = null, '. - 'string $heightUnit = null'. - ')' - )); - } - - /** - * Gets the "INVALID MARKER ANIMATION" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER ANIMATION" exception. - */ - public static function invalidMarkerAnimation() - { - return new static(sprintf( - 'The animation of a marker can only be : %s.', - implode(', ', Animation::getAnimations()) - )); - } - - /** - * Gets the "INVALID MARKER ICON" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER ICON" exception. - */ - public static function invalidMarkerIcon() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The icon setter arguments is invalid.', - 'The available prototypes are :', - ' - function setIcon(Ivory\GoogleMap\Overlays\MarkerImage $markerImage = null)', - ' - function setIcon(string $url = null)' - )); - } - - /** - * Gets the "INVALID MARKER ICON URL" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER ICON URL" exception. - */ - public static function invalidMarkerIconUrl() - { - return new static('A marker image icon must have an url.'); - } - - /** - * Gets the "INVALID MARKER IMAGE ANCHOR" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER IMAGE ANCHOR" exception. - */ - public static function invalidMarkerImageAnchor() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The anchor setter arguments is invalid.', - 'The available prototypes are :', - ' - function setAnchor(Ivory\GoogleMap\Base\Point $anchor)', - ' - function setAnchor(double x, double y)' - )); - } - - /** - * Gets the "INVALID MARKER IMAGE ORIGIN" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER IMAGE ORIGIN" exception. - */ - public static function invalidMarkerImageOrigin() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The origin setter arguments is invalid.', - 'The available prototypes are :', - ' - function setOrigin(Ivory\GoogleMap\Base\Point $origin)', - ' - function setOrigin(double x, double y)' - )); - } - - /** - * Gets the "INVALID MARKER IMAGE SCALED SIZE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER IMAGE SCALED SIZE" exception. - */ - public static function invalidMarkerImageScaledSize() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The scaled size setter arguments is invalid.', - 'The available prototypes are :', - ' - function setScaledSize(Ivory\GoogleMap\Base\Size $scaledSize = null)', - ' - function setScaledSize('. - 'double $width, '. - 'double $height, '. - 'string $widthUnit = null, '. - 'string $heightUnit = null'. - ')' - )); - } - - /** - * Gets the "INVALID MARKER IMAGE SIZE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER IMAGE SIZE" exception. - */ - public static function invalidMarkerImageSize() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The size setter arguments is invalid.', - 'The available prototypes are :', - ' - function setSize(Ivory\GoogleMap\Base\Size $size = null)', - ' - function setSize(double $width, double $height, string $widthUnit = null, string $heightUnit = null)' - )); - } - - /** - * Gets the "INVALID MARKER IMAGE URL" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER IMAGE URL" exception. - */ - public static function invalidMarkeImageUrl() - { - return new static('The url of a maker image must be a string value.'); - } - - /** - * Gets the "INVALID MARKER POSITION" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER POSITION" exception. - */ - public static function invalidMarkerPosition() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The position setter arguments is invalid.', - 'The available prototypes are :', - ' - function setPosition(Ivory\GoogleMap\Base\Coordinate $position)', - ' - function setPosition(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID MARKER SHADOW URL" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHADOW URL" exception. - */ - public static function invalidMarkerShadowUrl() - { - return new static('A marker image shadow must have an url.'); - } - - /** - * Gets the "INVALID MARKER SHADOW" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHADOW" exception. - */ - public static function invalidMarkerShadow() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The shadow setter arguments is invalid.', - 'The available prototypes are :', - ' - function setShadow(Ivory\GoogleMap\Overlays\MarkerImage $markerImage = null)', - ' - function setShadow(string $url = null)' - )); - } - - /** - * Gets the "INVALID MARKER SHAPE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHAPE" exception. - */ - public static function invalidMarkerShape() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The shape setter arguments is invalid.', - 'The available prototypes are :', - ' - function setShape(Ivory\GoogleMap\Overlays\MarkerShape $shape = null)', - ' - function setShape(string $type, array $coordinates)' - )); - } - - /** - * Gets the "INVALID MARKER SHAPE COORDINATES" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHAPE COORDINATES" exception. - */ - public static function invalidMarkerShapeCoordinates() - { - return new static('A marker shape must have coordinates.'); - } - - /** - * Gets the "INVALID MARKER SHAPE ADD POLY COORDINATE CALL" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHAPE ADD POLY COORDINATE CALL" - * exception. - */ - public static function invalidMarkerShapeAddPolyCoordinateCall() - { - return new static(sprintf( - 'The %s method can only be use with a marker shape which has type poly.', - 'MarkerShape::addPolyCoordinate($x, $y)' - )); - } - - /** - * Gets the "INVALID MARKER SHAPE TYPE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHAPE TYPE" exception. - */ - public static function invalidMarkerShapeType() - { - return new static(sprintf( - 'The type of a marker shape can only be : %s.', - implode(', ', array('circle', 'poly', 'rect')) - )); - } - - /** - * Gets the "INVALID MARKER SHAPE CIRCLE COORDINATES" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHAPE CIRCLE COORDINATES" exception. - */ - public static function invalidMarkerShapeCircleCoordinates() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s', - 'The coordinates setter arguments is invalid if the marker shape type is circle.', - 'The available prototype is : function setCoordinates(array(double $x, double $y, double $r))' - )); - } - - /** - * Gets the "INVALID MARKER SHAPE POLY COORDINATE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHAPE POLY COORDINATE" exception. - */ - public static function invalidMarkerShapePolyCoordinate() - { - return new static('The x & y coordinates of a poly marker shape must be numeric values.'); - } - - /** - * Gets the "INVALID MARKER SHAPE POLY COORDINATES" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHAPE POLY COORDINATES" exception. - */ - public static function invalidMarkerShapePolyCoordinates() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s', - 'The coordinates setter arguments is invalid if the marker shape type is poly.', - 'The available prototype is : function setCoordinates('. - 'array(double $x1, double $y1, '. - '..., '. - 'double $xn, double $yn'. - ')' - )); - } - - /** - * Gets the "INVALID MARKER SHAPE RECT COORDINATES" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID MARKER SHAPE RECT COORDINATES" exception. - */ - public static function invalidMarkerShapeRectCoordinates() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s', - 'The coordinates setter arguments is invalid if the marker shape type is rect.', - 'The available prototype is : function setCoordinates('. - 'array(double $x1, double $y1, double $x2, double $y2)'. - ')' - )); - } - - /** - * Gets the "INVALID POLYGON COORDINATE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID POLYGON COORDINATE" exception. - */ - public static function invalidPolygonCoordinate() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The coordinate adder arguments is invalid.', - 'The available prototypes are :', - ' - function addCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate)', - ' - function addCoordinate(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID POLYLINE COORDINATE" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID POLYLINE COORDINATE" exception. - */ - public static function invalidPolylineCoordinate() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The coordinate adder arguments is invalid.', - 'The available prototypes are :', - ' - function addCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate)', - ' - function addCoordinate(double $latitude, double $longitude, boolean $noWrap = true)' - )); - } - - /** - * Gets the "INVALID RECTANGLE BOUND" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID RECTANGLE BOUND" exception. - */ - public static function invalidRectangleBound() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The bound setter arguments is invalid.', - 'The available prototypes are :', - ' - function setBound(Ivory\GoogleMap\Base\Bound $bound)', - ' - function setBount('. - 'Ivory\GoogleMap\Base\Coordinate $southWest, '. - 'Ivory\GoogleMap\Base\Coordinate $northEast'. - ')', - ' - function setBound('. - 'double $southWestLatitude, '. - 'double $southWestLongitude, '. - 'double $northEastLatitude, '. - 'double $northEastLongitude, '. - 'boolean southWestNoWrap = true, '. - 'boolean $northEastNoWrap = true'. - ')' - )); - } - - /** - * Gets the "INVALID RECTANGLE BOUND COORDINATES" exception. - * - * @return \Ivory\GoogleMap\Exception\OverlayException The "INVALID RECTANGLE BOUND COORDINATES" exception. - */ - public static function invalidRectangleBoundCoordinates() - { - return new static('A rectangle bound must have a south west & a north east coordinate.'); - } -} diff --git a/src/Exception/PlaceException.php b/src/Exception/PlaceException.php deleted file mode 100644 index b7954f20..00000000 --- a/src/Exception/PlaceException.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -use Ivory\GoogleMap\Places\AutocompleteType; -use Ivory\GoogleMap\Places\AutocompleteComponentRestriction; - -/** - * Place exception. - * - * @author GeLo - */ -class PlaceException extends Exception -{ - /** - * Gets the "AUTOCOMPLETE COMPONENT RESTRICTION TYPE ALREADY EXISTS" exception. - * - * @param string $type The type. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "AUTOCOMPLETE RESTRICTION TYPE ALREADY EXISTS" exception. - */ - public static function autocompleteComponentRestrictionAlreadyExists($type) - { - return new static(sprintf('The place autocomplete component restriction type "%s" already exists.', $type)); - } - - /**s - * Gets the "AUTOCOMPLETE COMPONENT RESTRICTION TYPE DOES NOT EXIST" exception. - * - * @param string $type The type. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "AUTOCOMPLETE RESTRICTION TYPE DOES DOES NOT EXIST" exception. - */ - public static function autocompleteComponentRestrictionDoesNotExist($type) - { - return new static(sprintf('The place autocomplete component restriction type "%s" does not exist.', $type)); - } - - /** - * Gets the "AUTOCOMPLETE TYPE ALREADY EXISTS" exception. - * - * @param string $type The type. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "AUTOCOMPLETE TYPE ALREADY EXISTS" exception. - */ - public static function autocompleteTypeAlreadyExists($type) - { - return new static(sprintf('The place autocomplete type "%s" already exists.', $type)); - } - - /** - * Gets the "AUTOCOMPLETE TYPE DOES NOT EXIST" exception. - * - * @param string $type The type. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "AUTOCOMPLETE TYPE DOES NOT EXIST" exception. - */ - public static function autocompleteTypeDoesNotExist($type) - { - return new static(sprintf('The place autocomplete type "%s" does not exist.', $type)); - } - - /** - * Gets the "INVALID AUTOCOMPLETE ASYNC" exception. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "INVALID AUTOCOMPLETE ASYNC" exception. - */ - public static function invalidAutocompleteAsync() - { - return new static('The asynchronous load of a place autocomplete must be a boolean value.'); - } - - /** - * Gets the "INVALID AUTOCOMPLETE BOUND" exception. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "INVALID AUTOCOMPLETE BOUND" exception. - */ - public static function invalidAutocompleteBound() - { - return new static(sprintf( - '%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s'.PHP_EOL.'%s', - 'The bound setter arguments is invalid.', - 'The available prototypes are :', - ' - function setBound(Ivory\GoogleMap\Base\Bound $bound)', - ' - function setBount('. - 'Ivory\GoogleMap\Base\Coordinate $southWest, '. - 'Ivory\GoogleMap\Base\Coordinate $northEast'. - ')', - ' - function setBound('. - 'double $southWestLatitude, '. - 'double $southWestLongitude, '. - 'double $northEastLatitude, '. - 'double $northEastLongitude, '. - 'boolean southWestNoWrap = true, '. - 'boolean $northEastNoWrap = true'. - ')' - )); - } - - /** - * Gets the "INVALID AUTOCOMPLETE COMPONENT RESTRICTION" exception. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "INVALID AUTOCOMPLETE COMPONENT RESTRICTION" exception. - */ - public static function invalidAutocompleteComponentRestriction() - { - return new static( - sprintf( - 'The place autocomplete component restriction can only be: %s.', - implode(', ', AutocompleteComponentRestriction::getAvailableAutocompleteComponentRestrictions()) - ) - ); - } - - /** - * Gets the "INVALID AUTOCOMPLETE INPUT ID" exception. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "INVALID AUTOCOMPLETE INPUT ID" exception. - */ - public static function invalidAutocompleteInputId() - { - return new static('The place autocomplete input ID must be a string value.'); - } - - /** - * Gets the "INVALID AUTOCOMPLETE TYPE" exception. - * - * @return \Ivory\GoogleMap\Exception\PlaceException The "INVALID AUTOCOMPLETE TYPE" exception. - */ - public static function invalidAutocompleteType() - { - return new static( - sprintf( - 'The place autocomplete type can only be: %s.', - implode(', ', AutocompleteType::getAvailableAutocompleteTypes()) - ) - ); - } -} diff --git a/src/Exception/ServiceException.php b/src/Exception/ServiceException.php deleted file mode 100644 index daf50523..00000000 --- a/src/Exception/ServiceException.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Exception; - -/** - * Service exception. - * - * @author GeLo - */ -class ServiceException extends Exception -{ - /** - * Gets the "INVALID SERVICE FORMAT" exception. - * - * @return \Ivory\GoogleMap\Exception\ServiceException The "INVALID SERVICE FORMAT" exception. - */ - public static function invalidServiceFormat() - { - return new static(sprintf('The service format can only be : %s.', implode(', ', array('json', 'xml')))); - } - - /** - * Gets the "INVALID SERVICE HTTPS" exception. - * - * @return \Ivory\GoogleMap\Exception\ServiceException The "INVALID SERVICE HTTPS" exception. - */ - public static function invalidServiceHttps() - { - return new static('The service https flag must be a boolean value.'); - } - - /** - * Gets the "INVALID SERVICE RESULT" exception. - * - * @return \Ivory\GoogleMap\Exception\ServiceException The "INVALID SERVICE RESULT" exception. - */ - public static function invalidServiceResult() - { - return new static('The service result is not valid.'); - } - - /** - * Gets the "INVALID SERVICE URL" exception. - * - * @return \Ivory\GoogleMap\Exception\ServiceException The "INVALID SERVICE URL" exception. - */ - public static function invalidServiceUrl() - { - return new static('The service url must be a string value.'); - } - - /** - * Gets the "INVALID DISTANCE TEXT" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DISTANCE TEXT" exception. - */ - public static function invalidDistanceText() - { - return new static('The distance text must be a string value.'); - } - - /** - * Gets the "INVALID DISTANCE VALUE" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DISTANCE VALUE" exception. - */ - public static function invalidDistanceValue() - { - return new static('The distance value must be a numeric value.'); - } - - /** - * Gets the "INVALID DURATION TEXT" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DURATION TEXT" exception. - */ - public static function invalidDurationText() - { - return new static('The duration text must be a string value.'); - } - - /** - * Gets the "INVALID DURATION VALUE" exception. - * - * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DURATION VALUE" exception. - */ - public static function invalidDurationValue() - { - return new static('The duration value must be a numeric value.'); - } - - /** - * Gets the "INVALID RESPONSE" exception. - * - * @param string $url The url fetched. - * @param integer $statusCode The status code. - * - * @return \Ivory\GoogleMap\Exception\ServiceException The "INVALID RESPONSE" exception. - */ - public static function invalidResponse($url, $statusCode) - { - return new static(sprintf('An error occured while fetching %s (status code: %s).', $url, $statusCode)); - } -} diff --git a/src/Helper/AbstractHelper.php b/src/Helper/AbstractHelper.php index c5d68135..1602f300 100644 --- a/src/Helper/AbstractHelper.php +++ b/src/Helper/AbstractHelper.php @@ -11,62 +11,39 @@ namespace Ivory\GoogleMap\Helper; -use Ivory\GoogleMap\Map; -use Ivory\JsonBuilder\JsonBuilder; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Abstract helper. - * * @author GeLo */ abstract class AbstractHelper { - /** @var \Ivory\GoogleMap\Helper\Utils\JsonBuilder */ - protected $jsonBuilder; - /** - * Creates an helper. - * - * @param \Ivory\JsonBuilder\JsonBuilder $jsonBuilder The json builder. + * @var EventDispatcherInterface */ - public function __construct(JsonBuilder $jsonBuilder = null) - { - if ($jsonBuilder === null) { - $jsonBuilder = new JsonBuilder(); - } - - $this->setJsonBuilder($jsonBuilder); - } + private $eventDispatcher; /** - * Gets the json builder. - * - * @return \Ivory\JsonBuilder\JsonBuilder The json builder. + * @param EventDispatcherInterface $eventDispatcher */ - public function getJsonBuilder() + public function __construct(EventDispatcherInterface $eventDispatcher) { - return $this->jsonBuilder; + $this->setEventDispatcher($eventDispatcher); } /** - * Sets the json builder. - * - * @param \Ivory\JsonBuilder\JsonBuilder $jsonBuilder The json builder. + * @return EventDispatcherInterface */ - public function setJsonBuilder(JsonBuilder $jsonBuilder) + public function getEventDispatcher() { - $this->jsonBuilder = $jsonBuilder; + return $this->eventDispatcher; } /** - * Gets the javascript container name according to the map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The javascript container name. + * @param EventDispatcherInterface $eventDispatcher */ - protected function getJsContainerName(Map $map) + public function setEventDispatcher($eventDispatcher) { - return $map->getJavascriptVariable().'_container'; + $this->eventDispatcher = $eventDispatcher; } } diff --git a/src/Helper/ApiHelper.php b/src/Helper/ApiHelper.php index be8998df..9b9bc498 100644 --- a/src/Helper/ApiHelper.php +++ b/src/Helper/ApiHelper.php @@ -11,88 +11,23 @@ namespace Ivory\GoogleMap\Helper; +use Ivory\GoogleMap\Helper\Event\ApiEvent; +use Ivory\GoogleMap\Helper\Event\ApiEvents; + /** - * Google Map API helper. - * * @author GeLo */ class ApiHelper extends AbstractHelper { - /** @var boolean */ - protected $loaded; - /** - * Creates a Google Map API helper. - */ - public function __construct() - { - parent::__construct(); - - $this->loaded = false; - } - - /** - * Checks/Sets if the API is already loaded. - * - * @param boolean $loaded TRUE if the API is already loaded else FALSE. + * @param object[] $objects * - * @return boolean TRUE if the API is already loaded else FALSE. + * @return string */ - public function isLoaded($loaded = null) + public function render(array $objects) { - if ($loaded !== null) { - $this->loaded = (bool) $loaded; - } - - return $this->loaded; - } - - /** - * Renders the API. - * - * @param string $language The language. - * @param array $libraries Additionnal libraries. - * @param string $callback A JS callback. - * @param boolean $sensor The sensor flag. - * - * @return string The HTML output. - */ - public function render( - $language = 'en', - array $libraries = array(), - $callback = null, - $sensor = false - ) - { - $otherParameters = array(); - - if (!empty($libraries)) { - $otherParameters['libraries'] = implode(',', $libraries); - } - - $otherParameters['language'] = $language; - $otherParameters['sensor'] = json_encode((bool) $sensor); - - $this->jsonBuilder - ->reset() - ->setValue('[other_params]', urldecode(http_build_query($otherParameters))); - - if ($callback !== null) { - $this->jsonBuilder->setValue('[callback]', $callback, false); - } - - $callbackFunction = 'load_ivory_google_map_api'; - $url = sprintf('//www.google.com/jsapi?callback=%s', $callbackFunction); - $loader = sprintf('google.load("maps", "3", %s);', $this->jsonBuilder->build()); - - $output = array(); - $output[] = ''.PHP_EOL; - $output[] = sprintf(''.PHP_EOL, $url); - - $this->loaded = true; + $this->getEventDispatcher()->dispatch(ApiEvents::JAVASCRIPT, $event = new ApiEvent($objects)); - return implode('', $output); + return $event->getCode(); } } diff --git a/src/Helper/Base/BoundHelper.php b/src/Helper/Base/BoundHelper.php deleted file mode 100644 index 25094dbd..00000000 --- a/src/Helper/Base/BoundHelper.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Base; - -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Overlays\Circle; -use Ivory\GoogleMap\Overlays\EncodedPolyline; -use Ivory\GoogleMap\Overlays\GroundOverlay; -use Ivory\GoogleMap\Overlays\InfoWindow; -use Ivory\GoogleMap\Overlays\Marker; -use Ivory\GoogleMap\Overlays\Polyline; -use Ivory\GoogleMap\Overlays\Polygon; -use Ivory\GoogleMap\Overlays\Rectangle; - -/** - * Bound helper. - * - * @author GeLo - */ -class BoundHelper -{ - /** - * Renders the bound. - * - * @param \Ivory\GoogleMap\Base\Bound $bound The bound. - * - * @return string The JS output. - */ - public function render(Bound $bound) - { - if ($bound->hasExtends() || !$bound->hasCoordinates()) { - return sprintf('%s = new google.maps.LatLngBounds();'.PHP_EOL, $bound->getJavascriptVariable()); - } - - return sprintf( - '%s = new google.maps.LatLngBounds(%s, %s);'.PHP_EOL, - $bound->getJavascriptVariable(), - $bound->getSouthWest()->getJavascriptVariable(), - $bound->getNorthEast()->getJavascriptVariable() - ); - } - - /** - * Renders the bound's extend of a marker. - * - * @param \Ivory\GoogleMap\Base\Bound $bound The bound. - * - * @return string The JS output. - */ - public function renderExtends(Bound $bound) - { - $output = array(); - - foreach ($bound->getExtends() as $extend) { - if (($extend instanceof Marker) || ($extend instanceof InfoWindow)) { - $output[] = sprintf( - '%s.extend(%s.getPosition());'.PHP_EOL, - $bound->getJavascriptVariable(), - $extend->getJavascriptVariable() - ); - } elseif (($extend instanceof Polyline) - || ($extend instanceof EncodedPolyline) - || ($extend instanceof Polygon) - ) { - $output[] = sprintf( - '%s.getPath().forEach(function(element){%s.extend(element)});'.PHP_EOL, - $extend->getJavascriptVariable(), - $bound->getJavascriptVariable() - ); - } elseif (($extend instanceof Rectangle) || ($extend instanceof GroundOverlay)) { - $output[] = sprintf( - '%s.union(%s);'.PHP_EOL, - $bound->getJavascriptVariable(), - $extend->getBound()->getJavascriptVariable() - ); - } elseif ($extend instanceof Circle) { - $output[] = sprintf( - '%s.union(%s.getBounds());'.PHP_EOL, - $bound->getJavascriptVariable(), - $extend->getJavascriptVariable() - ); - } - } - - return implode('', $output); - } -} diff --git a/src/Helper/Base/SizeHelper.php b/src/Helper/Base/SizeHelper.php deleted file mode 100644 index 16a8cd33..00000000 --- a/src/Helper/Base/SizeHelper.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Base; - -use Ivory\GoogleMap\Base\Size; - -/** - * Size helper. - * - * @author GeLo - */ -class SizeHelper -{ - /** - * Renders a size. - * - * @param \Ivory\GoogleMap\Base\Size $size The size. - * - * @return string The JS output. - */ - public function render(Size $size) - { - if ($size->hasUnits()) { - return sprintf( - '%s = new google.maps.Size(%s, %s, "%s", "%s");'.PHP_EOL, - $size->getJavascriptVariable(), - $size->getWidth(), - $size->getHeight(), - $size->getWidthUnit(), - $size->getHeightUnit() - ); - } - - return sprintf( - '%s = new google.maps.Size(%s, %s);'.PHP_EOL, - $size->getJavascriptVariable(), - $size->getWidth(), $size->getHeight() - ); - } -} diff --git a/src/Helper/Builder/AbstractHelperBuilder.php b/src/Helper/Builder/AbstractHelperBuilder.php new file mode 100644 index 00000000..358584f7 --- /dev/null +++ b/src/Helper/Builder/AbstractHelperBuilder.php @@ -0,0 +1,199 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Builder; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\JsonBuilder\JsonBuilder; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * @author GeLo + */ +abstract class AbstractHelperBuilder +{ + /** + * @var Formatter + */ + private $formatter; + + /** + * @var JsonBuilder + */ + private $jsonBuilder; + + /** + * @var EventSubscriberInterface[] + */ + private $subscribers = []; + + /** + * @param Formatter|null $formatter + * @param JsonBuilder|null $jsonBuilder + */ + public function __construct(Formatter $formatter = null, JsonBuilder $jsonBuilder = null) + { + $this->setFormatter($formatter ?: new Formatter()); + $this->setJsonBuilder($jsonBuilder ?: new JsonBuilder()); + } + + /** + * @return static + */ + public static function create() + { + return new static(); + } + + /** + * @return Formatter + */ + public function getFormatter() + { + return $this->formatter; + } + + /** + * @param Formatter $formatter + * + * @return $this + */ + public function setFormatter(Formatter $formatter) + { + $this->formatter = $formatter; + + return $this; + } + + /** + * @return JsonBuilder + */ + public function getJsonBuilder() + { + return $this->jsonBuilder; + } + + /** + * @param JsonBuilder $jsonBuilder + * + * @return $this + */ + public function setJsonBuilder(JsonBuilder $jsonBuilder) + { + $this->jsonBuilder = $jsonBuilder; + + return $this; + } + + /** + * @return bool + */ + public function hasSubscribers() + { + return !empty($this->subscribers); + } + + /** + * @return EventSubscriberInterface[] + */ + public function getSubscribers() + { + return $this->subscribers; + } + + /** + * @param EventSubscriberInterface[] $subscribers + * + * @return $this + */ + public function setSubscribers(array $subscribers) + { + $this->subscribers = []; + $this->addSubscribers($subscribers); + + return $this; + } + + /** + * @param EventSubscriberInterface[] $subscribers + * + * @return $this + */ + public function addSubscribers(array $subscribers) + { + foreach ($subscribers as $subscriber) { + $this->addSubscriber($subscriber); + } + + return $this; + } + + /** + * @param EventSubscriberInterface $subscriber + * + * @return bool + */ + public function hasSubscriber(EventSubscriberInterface $subscriber) + { + return in_array($subscriber, $this->subscribers, true); + } + + /** + * @param EventSubscriberInterface $subscriber + * + * @return $this + */ + public function addSubscriber(EventSubscriberInterface $subscriber) + { + if (!$this->hasSubscriber($subscriber)) { + $this->subscribers[] = $subscriber; + } + + return $this; + } + + /** + * @param EventSubscriberInterface $subscriber + * + * @return $this + */ + public function removeSubscriber(EventSubscriberInterface $subscriber) + { + unset($this->subscribers[array_search($subscriber, $this->subscribers, true)]); + $this->subscribers = array_values($this->subscribers); + + return $this; + } + + /** + * @return EventDispatcherInterface + */ + protected function createEventDispatcher() + { + $eventDispatcher = new EventDispatcher(); + + foreach ($this->createSubscribers() as $subscriber) { + $eventDispatcher->addSubscriber($subscriber); + } + + return $eventDispatcher; + } + + /** + * @return EventSubscriberInterface[] + */ + protected function createSubscribers() + { + return $this->subscribers; + } +} diff --git a/src/Helper/Builder/ApiHelperBuilder.php b/src/Helper/Builder/ApiHelperBuilder.php new file mode 100644 index 00000000..37073fb1 --- /dev/null +++ b/src/Helper/Builder/ApiHelperBuilder.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Builder; + +use Ivory\GoogleMap\Helper\ApiHelper; +use Ivory\GoogleMap\Helper\Collector\Overlay\EncodedPolylineCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoBoxCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Helper\Renderer\ApiInitRenderer; +use Ivory\GoogleMap\Helper\Renderer\ApiRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlManagerRenderer; +use Ivory\GoogleMap\Helper\Renderer\Geometry\EncodingRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\JavascriptTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; +use Ivory\GoogleMap\Helper\Renderer\LoaderRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapTypeIdRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\EncodedPolylineRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoBoxRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerClustererRenderer; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\CallbackRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementLoaderRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\SourceRenderer; +use Ivory\GoogleMap\Helper\Subscriber\ApiJavascriptSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapJavascriptSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\EncodedPolylineSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\InfoBoxSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\MarkerClustererSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Place\AutocompleteJavascriptSubscriber; + +/** + * @author GeLo + */ +class ApiHelperBuilder extends AbstractHelperBuilder +{ + /** + * @return ApiHelper + */ + public function build() + { + return new ApiHelper($this->createEventDispatcher()); + } + + /** + * {@inheritdoc} + */ + protected function createSubscribers() + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder(); + + // Overlay collectors + $encodedPolylineCollector = new EncodedPolylineCollector(); + $markerCollector = new MarkerCollector(); + $infoBoxCollector = new InfoBoxCollector($markerCollector); + + // Control renderers + $controlManagerRenderer = new ControlManagerRenderer(); + + // Utility renderers + $callbackRenderer = new CallbackRenderer($formatter); + $loaderRenderer = new LoaderRenderer($formatter, $jsonBuilder); + $requirementLoaderRenderer = new RequirementLoaderRenderer($formatter); + $requirementRenderer = new RequirementRenderer($formatter); + $sourceRenderer = new SourceRenderer($formatter); + + // Map renderers + $mapTypeIdRenderer = new MapTypeIdRenderer($formatter); + $mapRenderer = new MapRenderer( + $formatter, + $jsonBuilder, + $mapTypeIdRenderer, + $controlManagerRenderer, + $requirementRenderer + ); + + // Overlay renderers + $encodingRenderer = new EncodingRenderer($formatter); + $encodedPolylineRenderer = new EncodedPolylineRenderer($formatter, $jsonBuilder, $encodingRenderer); + $infoBoxRenderer = new InfoBoxRenderer($formatter, $jsonBuilder, $requirementRenderer); + $markerClustererRenderer = new MarkerClustererRenderer($formatter, $jsonBuilder, $requirementRenderer); + + // Place renderers + $autocompleteRenderer = new AutocompleteRenderer($formatter, $jsonBuilder, $requirementRenderer); + + // Html renderers + $tagRenderer = new TagRenderer($formatter); + $javascriptTagRenderer = new JavascriptTagRenderer($formatter, $tagRenderer); + + // Api renderers + $apiInitRenderer = new ApiInitRenderer($formatter); + $apiRenderer = new ApiRenderer( + $formatter, + $apiInitRenderer, + $loaderRenderer, + $requirementLoaderRenderer, + $sourceRenderer + ); + + return array_merge([ + new ApiJavascriptSubscriber($formatter, $apiRenderer, $javascriptTagRenderer), + new AutocompleteJavascriptSubscriber( + $formatter, + $autocompleteRenderer, + $callbackRenderer, + $javascriptTagRenderer + ), + new EncodedPolylineSubscriber($formatter, $encodedPolylineCollector, $encodedPolylineRenderer), + new InfoBoxSubscriber($formatter, $infoBoxCollector, $infoBoxRenderer), + new MapJavascriptSubscriber($formatter, $mapRenderer, $callbackRenderer, $javascriptTagRenderer), + new MarkerClustererSubscriber($formatter, $markerClustererRenderer), + ], parent::createSubscribers()); + } +} diff --git a/src/Helper/Builder/MapHelperBuilder.php b/src/Helper/Builder/MapHelperBuilder.php new file mode 100644 index 00000000..5fcb3e70 --- /dev/null +++ b/src/Helper/Builder/MapHelperBuilder.php @@ -0,0 +1,358 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Builder; + +use Ivory\GoogleMap\Helper\Collector\Base\BoundCollector; +use Ivory\GoogleMap\Helper\Collector\Base\CoordinateCollector; +use Ivory\GoogleMap\Helper\Collector\Base\PointCollector; +use Ivory\GoogleMap\Helper\Collector\Base\SizeCollector; +use Ivory\GoogleMap\Helper\Collector\Event\DomEventCollector; +use Ivory\GoogleMap\Helper\Collector\Event\DomEventOnceCollector; +use Ivory\GoogleMap\Helper\Collector\Event\EventCollector; +use Ivory\GoogleMap\Helper\Collector\Event\EventOnceCollector; +use Ivory\GoogleMap\Helper\Collector\Layer\KmlLayerCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\CircleCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\DefaultInfoWindowCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\EncodedPolylineCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\ExtendableCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\GroundOverlayCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\IconCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoBoxCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\PolygonCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\PolylineCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\RectangleCollector; +use Ivory\GoogleMap\Helper\MapHelper; +use Ivory\GoogleMap\Helper\Renderer\Base\BoundRenderer; +use Ivory\GoogleMap\Helper\Renderer\Base\CoordinateRenderer; +use Ivory\GoogleMap\Helper\Renderer\Base\PointRenderer; +use Ivory\GoogleMap\Helper\Renderer\Base\SizeRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlManagerRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlPositionRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\MapTypeControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\MapTypeControlStyleRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\RotateControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ScaleControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ScaleControlStyleRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\StreetViewControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ZoomControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ZoomControlStyleRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\DomEventOnceRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\DomEventRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\EventOnceRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\EventRenderer; +use Ivory\GoogleMap\Helper\Renderer\Geometry\EncodingRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\JavascriptTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\StylesheetRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\StylesheetTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Layer\KmlLayerRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapBoundRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapCenterRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapContainerRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapHtmlRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapTypeIdRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\AnimationRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\CircleRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\DefaultInfoWindowRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\EncodedPolylineRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\ExtendableRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\PathExtendableRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\PositionExtendableRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\UnionExtendableRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\GroundOverlayRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\IconRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoBoxRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowCloseRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowOpenRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerClustererRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerShapeRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\PolygonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\PolylineRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\RectangleRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\CallbackRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\ObjectToArrayRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Helper\Subscriber\Base\BaseSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Base\BoundSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Base\CoordinateSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Base\PointSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Base\SizeSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Event\DomEventOnceSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Event\DomEventSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Event\EventOnceSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Event\EventSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Event\SimpleEventSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Layer\KmlLayerSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Layer\LayerSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapBoundSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapCenterSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapContainerSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapHtmlSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapInitSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapJavascriptSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapStylesheetSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\MapSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\CircleSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\DefaultInfoWindowSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\EncodedPolylineSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\ExtendableSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\GroundOverlaySubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\InfoBoxSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\InfoWindowCloseSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\InfoWindowOpenSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\MarkerClustererSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\MarkerInfoWindowOpenSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\MarkerSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\OverlaySubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\PolygonSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\PolylineSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Overlay\RectangleSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Utility\ObjectToArraySubscriber; +use Ivory\GoogleMap\Overlay\Circle; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\GoogleMap\Overlay\GroundOverlay; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\Polygon; +use Ivory\GoogleMap\Overlay\Polyline; +use Ivory\GoogleMap\Overlay\Rectangle; + +/** + * @author GeLo + */ +class MapHelperBuilder extends AbstractHelperBuilder +{ + /** + * @return MapHelper + */ + public function build() + { + return new MapHelper($this->createEventDispatcher()); + } + + /** + * {@inheritdoc} + */ + protected function createSubscribers() + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder(); + + // Overlay collectors + $markerCollector = new MarkerCollector(); + $circleCollector = new CircleCollector(); + $defaultInfoWindowCollector = new DefaultInfoWindowCollector($markerCollector); + $encodedPolylineCollector = new EncodedPolylineCollector(); + $extendableCollector = new ExtendableCollector(); + $groundOverlayCollector = new GroundOverlayCollector(); + $infoBoxCollector = new InfoBoxCollector($markerCollector); + $infoWindowCollector = new InfoWindowCollector($markerCollector); + $iconCollector = new IconCollector($markerCollector); + $polygonCollector = new PolygonCollector(); + $polylineCollector = new PolylineCollector(); + $rectangleCollector = new RectangleCollector(); + + // Layer collectors + $kmlLayerCollector = new KmlLayerCollector(); + + // Event collectors + $domEventCollector = new DomEventCollector(); + $domEventOnceCollector = new DomEventOnceCollector(); + $eventCollector = new EventCollector(); + $eventOnceCollector = new EventOnceCollector(); + + // Base collectors + $boundCollector = new BoundCollector($groundOverlayCollector, $rectangleCollector); + $pointCollector = new PointCollector($markerCollector); + $sizeCollector = new SizeCollector($infoWindowCollector, $iconCollector); + $coordinateCollector = new CoordinateCollector( + $boundCollector, + $circleCollector, + $infoWindowCollector, + $markerCollector, + $polygonCollector, + $polylineCollector + ); + + // Base renderers + $boundRenderer = new BoundRenderer($formatter); + $coordinateRenderer = new CoordinateRenderer($formatter); + $mapTypeIdRenderer = new MapTypeIdRenderer($formatter); + $pointRenderer = new PointRenderer($formatter); + $sizeRenderer = new SizeRenderer($formatter); + + // Control renderers + $controlPositionRenderer = new ControlPositionRenderer($formatter); + $mapTypeControlStyleRenderer = new MapTypeControlStyleRenderer($formatter); + $rotateControlRenderer = new RotateControlRenderer($formatter, $jsonBuilder, $controlPositionRenderer); + $scaleControlStyleRenderer = new ScaleControlStyleRenderer($formatter); + $streetViewControlRenderer = new StreetViewControlRenderer($formatter, $jsonBuilder, $controlPositionRenderer); + $zoomControlStyleRenderer = new ZoomControlStyleRenderer($formatter); + + $mapTypeControlRenderer = new MapTypeControlRenderer( + $formatter, + $jsonBuilder, + $mapTypeIdRenderer, + $controlPositionRenderer, + $mapTypeControlStyleRenderer + ); + + $scaleControlRenderer = new ScaleControlRenderer( + $formatter, + $jsonBuilder, + $controlPositionRenderer, + $scaleControlStyleRenderer + ); + + $zoomControlRenderer = new ZoomControlRenderer( + $formatter, + $jsonBuilder, + $controlPositionRenderer, + $zoomControlStyleRenderer + ); + + $controlManagerRenderer = new ControlManagerRenderer(); + $controlManagerRenderer->addRenderer($mapTypeControlRenderer); + $controlManagerRenderer->addRenderer($rotateControlRenderer); + $controlManagerRenderer->addRenderer($scaleControlRenderer); + $controlManagerRenderer->addRenderer($streetViewControlRenderer); + $controlManagerRenderer->addRenderer($zoomControlRenderer); + + // Event renderers + $domEventOnceRenderer = new DomEventOnceRenderer($formatter); + $domEventRenderer = new DomEventRenderer($formatter); + $eventOnceRenderer = new EventOnceRenderer($formatter); + $eventRenderer = new EventRenderer($formatter); + + // Geometry renderers + $encodingRenderer = new EncodingRenderer($formatter); + + // Html renderers + $tagRenderer = new TagRenderer($formatter); + $javascriptTagRenderer = new JavascriptTagRenderer($formatter, $tagRenderer); + $stylesheetRenderer = new StylesheetRenderer($formatter); + $stylesheetTagRenderer = new StylesheetTagRenderer($formatter, $tagRenderer, $stylesheetRenderer); + + // Utility + $callbackRenderer = new CallbackRenderer($formatter); + $objectToArrayRenderer = new ObjectToArrayRenderer($formatter); + $requirementRenderer = new RequirementRenderer($formatter); + + // Map renderers + $mapBoundRenderer = new MapBoundRenderer($formatter); + $mapCenterRenderer = new MapCenterRenderer($formatter); + $mapContainerRenderer = new MapContainerRenderer($formatter, $jsonBuilder); + $mapHtmlRenderer = new MapHtmlRenderer($formatter, $tagRenderer, $stylesheetRenderer); + $mapRenderer = new MapRenderer( + $formatter, + $jsonBuilder, + $mapTypeIdRenderer, + $controlManagerRenderer, + $requirementRenderer + ); + + // Overlay renderers + $animationRenderer = new AnimationRenderer($formatter); + $circleRenderer = new CircleRenderer($formatter, $jsonBuilder); + $defaultInfoWindowRenderer = new DefaultInfoWindowRenderer($formatter, $jsonBuilder); + $encodedPolylineRenderer = new EncodedPolylineRenderer($formatter, $jsonBuilder, $encodingRenderer); + $groundOverlayRenderer = new GroundOverlayRenderer($formatter, $jsonBuilder); + $infoBoxRenderer = new InfoBoxRenderer($formatter, $jsonBuilder, $requirementRenderer); + $infoWindowCloseRenderer = new InfoWindowCloseRenderer($formatter); + $infoWindowOpenRenderer = new InfoWindowOpenRenderer($formatter); + $iconRenderer = new IconRenderer($formatter, $jsonBuilder); + $markerClustererRenderer = new MarkerClustererRenderer($formatter, $jsonBuilder, $requirementRenderer); + $markerShapeRenderer = new MarkerShapeRenderer($formatter, $jsonBuilder); + $polygonRenderer = new PolygonRenderer($formatter, $jsonBuilder); + $polylineRenderer = new PolylineRenderer($formatter, $jsonBuilder); + $rectangleRenderer = new RectangleRenderer($formatter, $jsonBuilder); + $markerRenderer = new MarkerRenderer( + $formatter, + $jsonBuilder, + $animationRenderer, + $iconRenderer, + $markerShapeRenderer + ); + + // Extendable renderers + $pathExtendableRenderer = new PathExtendableRenderer($formatter); + $positionExtendableRenderer = new PositionExtendableRenderer($formatter); + $unionExtendableRenderer = new UnionExtendableRenderer($formatter); + + $extendableRenderer = new ExtendableRenderer(); + $extendableRenderer->setRenderer(Circle::class, $unionExtendableRenderer); + $extendableRenderer->setRenderer(EncodedPolyline::class, $pathExtendableRenderer); + $extendableRenderer->setRenderer(GroundOverlay::class, $unionExtendableRenderer); + $extendableRenderer->setRenderer(InfoWindow::class, $positionExtendableRenderer); + $extendableRenderer->setRenderer(Marker::class, $positionExtendableRenderer); + $extendableRenderer->setRenderer(Polyline::class, $pathExtendableRenderer); + $extendableRenderer->setRenderer(Polygon::class, $pathExtendableRenderer); + $extendableRenderer->setRenderer(Rectangle::class, $unionExtendableRenderer); + + // Layer renderers + $kmlLayerRenderer = new KmlLayerRenderer($formatter, $jsonBuilder); + + return array_merge([ + // Base + new BaseSubscriber($formatter), + new BoundSubscriber($formatter, $boundCollector, $boundRenderer), + new CoordinateSubscriber($formatter, $coordinateCollector, $coordinateRenderer), + new PointSubscriber($formatter, $pointCollector, $pointRenderer), + new SizeSubscriber($formatter, $sizeCollector, $sizeRenderer), + + // Event + new DomEventOnceSubscriber($formatter, $domEventOnceCollector, $domEventOnceRenderer), + new DomEventSubscriber($formatter, $domEventCollector, $domEventRenderer), + new EventOnceSubscriber($formatter, $eventOnceCollector, $eventOnceRenderer), + new EventSubscriber($formatter), + new SimpleEventSubscriber($formatter, $eventCollector, $eventRenderer), + + // Layer + new KmlLayerSubscriber($formatter, $kmlLayerCollector, $kmlLayerRenderer), + new LayerSubscriber($formatter), + + // Overlay + new CircleSubscriber($formatter, $circleCollector, $circleRenderer), + new DefaultInfoWindowSubscriber($formatter, $defaultInfoWindowCollector, $defaultInfoWindowRenderer), + new EncodedPolylineSubscriber($formatter, $encodedPolylineCollector, $encodedPolylineRenderer), + new ExtendableSubscriber($formatter, $extendableCollector, $extendableRenderer), + new GroundOverlaySubscriber($formatter, $groundOverlayCollector, $groundOverlayRenderer), + new InfoBoxSubscriber($formatter, $infoBoxCollector, $infoBoxRenderer), + new InfoWindowCloseSubscriber($formatter, $infoWindowCollector, $infoWindowCloseRenderer), + new InfoWindowOpenSubscriber($formatter, $infoWindowCollector, $infoWindowOpenRenderer), + new MarkerClustererSubscriber($formatter, $markerClustererRenderer), + new MarkerInfoWindowOpenSubscriber($formatter, $markerCollector, $infoWindowOpenRenderer, $eventRenderer), + new MarkerSubscriber($formatter, $markerCollector, $markerRenderer), + new OverlaySubscriber($formatter), + new PolygonSubscriber($formatter, $polygonCollector, $polygonRenderer), + new PolylineSubscriber($formatter, $polylineCollector, $polylineRenderer), + new RectangleSubscriber($formatter, $rectangleCollector, $rectangleRenderer), + + // Map + new MapBoundSubscriber($formatter, $mapBoundRenderer), + new MapCenterSubscriber($formatter, $mapCenterRenderer), + new MapContainerSubscriber($formatter, $mapContainerRenderer), + new MapHtmlSubscriber($formatter, $mapHtmlRenderer), + new MapInitSubscriber($formatter), + new MapJavascriptSubscriber($formatter, $mapRenderer, $callbackRenderer, $javascriptTagRenderer), + new MapStylesheetSubscriber($formatter, $stylesheetTagRenderer), + new MapSubscriber($formatter, $mapRenderer), + + // Utility + new ObjectToArraySubscriber($formatter, $objectToArrayRenderer), + ], parent::createSubscribers()); + } +} diff --git a/src/Helper/Builder/PlaceAutocompleteHelperBuilder.php b/src/Helper/Builder/PlaceAutocompleteHelperBuilder.php new file mode 100644 index 00000000..0dc9faef --- /dev/null +++ b/src/Helper/Builder/PlaceAutocompleteHelperBuilder.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Builder; + +use Ivory\GoogleMap\Helper\Collector\Place\AutocompleteBoundCollector; +use Ivory\GoogleMap\Helper\Collector\Place\AutocompleteCoordinateCollector; +use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper; +use Ivory\GoogleMap\Helper\Renderer\Base\BoundRenderer; +use Ivory\GoogleMap\Helper\Renderer\Base\CoordinateRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\JavascriptTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteContainerRenderer; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteHtmlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\CallbackRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Helper\Subscriber\Place\AutocompleteContainerSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Place\AutocompleteHtmlSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Place\AutocompleteInitSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Place\AutocompleteJavascriptSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Place\AutocompleteSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Place\Base\AutocompleteBaseSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Place\Base\AutocompleteBoundSubscriber; +use Ivory\GoogleMap\Helper\Subscriber\Place\Base\AutocompleteCoordinateSubscriber; + +/** + * @author GeLo + */ +class PlaceAutocompleteHelperBuilder extends AbstractHelperBuilder +{ + /** + * @return PlaceAutocompleteHelper + */ + public function build() + { + return new PlaceAutocompleteHelper($this->createEventDispatcher()); + } + + /** + * {@inheritdoc} + */ + protected function createSubscribers() + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder(); + + // Base collectors + $boundCollector = new AutocompleteBoundCollector(); + $coordinateCollector = new AutocompleteCoordinateCollector($boundCollector); + + // Base renderers + $coordinateRenderer = new CoordinateRenderer($formatter); + $boundRenderer = new BoundRenderer($formatter); + + // Html renderers + $tagRenderer = new TagRenderer($formatter); + $autocompleteHtmlRenderer = new AutocompleteHtmlRenderer($formatter, $tagRenderer); + $javascriptTagRenderer = new JavascriptTagRenderer($formatter, $tagRenderer); + + // Utility renderers + $callbackRenderer = new CallbackRenderer($formatter); + $requirementRenderer = new RequirementRenderer($formatter); + + // Autocomplete renderers + $autocompleteContainerRenderer = new AutocompleteContainerRenderer($formatter, $jsonBuilder); + $autocompleteRenderer = new AutocompleteRenderer($formatter, $jsonBuilder, $requirementRenderer); + + return array_merge([ + new AutocompleteBaseSubscriber($formatter), + new AutocompleteContainerSubscriber($formatter, $autocompleteContainerRenderer), + new AutocompleteCoordinateSubscriber($formatter, $coordinateCollector, $coordinateRenderer), + new AutocompleteBoundSubscriber($formatter, $boundCollector, $boundRenderer), + new AutocompleteHtmlSubscriber($formatter, $autocompleteHtmlRenderer), + new AutocompleteInitSubscriber($formatter), + new AutocompleteJavascriptSubscriber( + $formatter, + $autocompleteRenderer, + $callbackRenderer, + $javascriptTagRenderer + ), + new AutocompleteSubscriber($formatter, $autocompleteRenderer), + ], parent::createSubscribers()); + } +} diff --git a/src/Helper/Collector/AbstractCollector.php b/src/Helper/Collector/AbstractCollector.php new file mode 100644 index 00000000..5dd026da --- /dev/null +++ b/src/Helper/Collector/AbstractCollector.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector; + +/** + * @author GeLo + */ +abstract class AbstractCollector +{ + /** + * @param mixed[] $values + * @param mixed[] $defaults + * + * @return mixed[] + */ + protected function collectValues(array $values, array $defaults = []) + { + foreach ($values as $value) { + $defaults = $this->collectValue($value, $defaults); + } + + return $defaults; + } + + /** + * @param object $value + * @param object[] $defaults + * + * @return object[] + */ + protected function collectValue($value, array $defaults = []) + { + if (!in_array($value, $defaults, true)) { + $defaults[] = $value; + } + + return $defaults; + } +} diff --git a/src/Helper/Collector/Base/BoundCollector.php b/src/Helper/Collector/Base/BoundCollector.php new file mode 100644 index 00000000..78adf11a --- /dev/null +++ b/src/Helper/Collector/Base/BoundCollector.php @@ -0,0 +1,99 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Base; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\GroundOverlayCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\RectangleCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class BoundCollector extends AbstractCollector +{ + /** + * @var GroundOverlayCollector + */ + private $groundOverlayCollector; + + /** + * @var RectangleCollector + */ + private $rectangleCollector; + + /** + * @param GroundOverlayCollector $groundOverlayCollector + * @param RectangleCollector $rectangleCollector + */ + public function __construct(GroundOverlayCollector $groundOverlayCollector, RectangleCollector $rectangleCollector) + { + $this->setGroundOverlayCollector($groundOverlayCollector); + $this->setRectangleCollector($rectangleCollector); + } + + /** + * @return GroundOverlayCollector + */ + public function getGroundOverlayCollector() + { + return $this->groundOverlayCollector; + } + + /** + * @param GroundOverlayCollector $groundOverlayCollector + */ + public function setGroundOverlayCollector(GroundOverlayCollector $groundOverlayCollector) + { + $this->groundOverlayCollector = $groundOverlayCollector; + } + + /** + * @return RectangleCollector + */ + public function getRectangleCollector() + { + return $this->rectangleCollector; + } + + /** + * @param RectangleCollector $rectangleCollector + */ + public function setRectangleCollector(RectangleCollector $rectangleCollector) + { + $this->rectangleCollector = $rectangleCollector; + } + + /** + * @param Map $map + * @param Bound[] $bounds + * + * @return Bound[] + */ + public function collect(Map $map, array $bounds = []) + { + if ($map->isAutoZoom()) { + $bounds = $this->collectValue($map->getBound(), $bounds); + } + + foreach ($this->groundOverlayCollector->collect($map) as $groundOverlay) { + $bounds = $this->collectValue($groundOverlay->getBound(), $bounds); + } + + foreach ($this->rectangleCollector->collect($map) as $rectangle) { + $bounds = $this->collectValue($rectangle->getBound(), $bounds); + } + + return $bounds; + } +} diff --git a/src/Helper/Collector/Base/CoordinateCollector.php b/src/Helper/Collector/Base/CoordinateCollector.php new file mode 100644 index 00000000..11286c07 --- /dev/null +++ b/src/Helper/Collector/Base/CoordinateCollector.php @@ -0,0 +1,225 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Base; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\CircleCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\PolygonCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\PolylineCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class CoordinateCollector extends AbstractCollector +{ + /** + * @var BoundCollector + */ + private $boundCollector; + + /** + * @var CircleCollector + */ + private $circleCollector; + + /** + * @var InfoWindowCollector + */ + private $infoWindowCollector; + + /** + * @var MarkerCollector + */ + private $markerCollector; + + /** + * @var PolygonCollector + */ + private $polygonCollector; + + /** + * @var PolylineCollector + */ + private $polylineCollector; + + /** + * @param BoundCollector $boundCollector + * @param CircleCollector $circleCollector + * @param InfoWindowCollector $infoWindowCollector + * @param MarkerCollector $markerCollector + * @param PolygonCollector $polygonCollector + * @param PolylineCollector $polylineCollector + */ + public function __construct( + BoundCollector $boundCollector, + CircleCollector $circleCollector, + InfoWindowCollector $infoWindowCollector, + MarkerCollector $markerCollector, + PolygonCollector $polygonCollector, + PolylineCollector $polylineCollector + ) { + $this->setBoundCollector($boundCollector); + $this->setCircleCollector($circleCollector); + $this->setInfoWindowCollector($infoWindowCollector); + $this->setMarkerCollector($markerCollector); + $this->setPolygonCollector($polygonCollector); + $this->setPolylineCollector($polylineCollector); + } + + /** + * @return BoundCollector + */ + public function getBoundCollector() + { + return $this->boundCollector; + } + + /** + * @param BoundCollector $boundCollector + */ + public function setBoundCollector(BoundCollector $boundCollector) + { + $this->boundCollector = $boundCollector; + } + + /** + * @return CircleCollector + */ + public function getCircleCollector() + { + return $this->circleCollector; + } + + /** + * @param CircleCollector $circleCollector + */ + public function setCircleCollector(CircleCollector $circleCollector) + { + $this->circleCollector = $circleCollector; + } + + /** + * @return InfoWindowCollector + */ + public function getInfoWindowCollector() + { + return $this->infoWindowCollector; + } + + /** + * @param InfoWindowCollector $infoWindowCollector + */ + public function setInfoWindowCollector(InfoWindowCollector $infoWindowCollector) + { + $this->infoWindowCollector = $infoWindowCollector; + } + + /** + * @return MarkerCollector + */ + public function getMarkerCollector() + { + return $this->markerCollector; + } + + /** + * @param MarkerCollector $markerCollector + */ + public function setMarkerCollector(MarkerCollector $markerCollector) + { + $this->markerCollector = $markerCollector; + } + + /** + * @return PolygonCollector + */ + public function getPolygonCollector() + { + return $this->polygonCollector; + } + + /** + * @param PolygonCollector $polygonCollector + */ + public function setPolygonCollector(PolygonCollector $polygonCollector) + { + $this->polygonCollector = $polygonCollector; + } + + /** + * @return PolylineCollector + */ + public function getPolylineCollector() + { + return $this->polylineCollector; + } + + /** + * @param PolylineCollector $polylineCollector + */ + public function setPolylineCollector(PolylineCollector $polylineCollector) + { + $this->polylineCollector = $polylineCollector; + } + + /** + * @param Map $map + * @param Coordinate[] $coordinates + * + * @return Coordinate[] + */ + public function collect(Map $map, array $coordinates = []) + { + if (!$map->isAutoZoom()) { + $coordinates = $this->collectValue($map->getCenter(), $coordinates); + } + + foreach ($this->boundCollector->collect($map) as $bound) { + if ($bound->hasCoordinates()) { + $coordinates = $this->collectValue($bound->getSouthWest(), $coordinates); + $coordinates = $this->collectValue($bound->getNorthEast(), $coordinates); + } + } + + foreach ($this->circleCollector->collect($map) as $circle) { + $coordinates = $this->collectValue($circle->getCenter(), $coordinates); + } + + foreach ($this->infoWindowCollector->collect($map) as $infoWindow) { + if ($infoWindow->hasPosition()) { + $coordinates = $this->collectValue($infoWindow->getPosition(), $coordinates); + } + } + + foreach ($this->markerCollector->collect($map) as $marker) { + $coordinates = $this->collectValue($marker->getPosition(), $coordinates); + } + + foreach ($this->polygonCollector->collect($map) as $polygon) { + foreach ($polygon->getCoordinates() as $coordinate) { + $coordinates = $this->collectValue($coordinate, $coordinates); + } + } + + foreach ($this->polylineCollector->collect($map) as $polyline) { + foreach ($polyline->getCoordinates() as $coordinate) { + $coordinates = $this->collectValue($coordinate, $coordinates); + } + } + + return $coordinates; + } +} diff --git a/src/Helper/Collector/Base/PointCollector.php b/src/Helper/Collector/Base/PointCollector.php new file mode 100644 index 00000000..9171872f --- /dev/null +++ b/src/Helper/Collector/Base/PointCollector.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Base; + +use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class PointCollector extends AbstractCollector +{ + /** + * @var MarkerCollector + */ + private $markerCollector; + + /** + * @param MarkerCollector $markerCollector + */ + public function __construct(MarkerCollector $markerCollector) + { + $this->setMarkerCollector($markerCollector); + } + + /** + * @return MarkerCollector + */ + public function getMarkerCollector() + { + return $this->markerCollector; + } + + /** + * @param MarkerCollector $markerCollector + */ + public function setMarkerCollector(MarkerCollector $markerCollector) + { + $this->markerCollector = $markerCollector; + } + + /** + * @param Map $map + * @param Point[] $points + * + * @return Point[] + */ + public function collect(Map $map, array $points = []) + { + foreach ($this->markerCollector->collect($map) as $marker) { + if ($marker->hasIcon()) { + $icon = $marker->getIcon(); + + if ($icon->hasAnchor()) { + $points = $this->collectValue($icon->getAnchor(), $points); + } + + if ($icon->hasOrigin()) { + $points = $this->collectValue($icon->getOrigin(), $points); + } + } + } + + return $points; + } +} diff --git a/src/Helper/Collector/Base/SizeCollector.php b/src/Helper/Collector/Base/SizeCollector.php new file mode 100644 index 00000000..c43d9de4 --- /dev/null +++ b/src/Helper/Collector/Base/SizeCollector.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Base; + +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\IconCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class SizeCollector extends AbstractCollector +{ + /** + * @var InfoWindowCollector + */ + private $infoWindowCollector; + + /** + * @var IconCollector + */ + private $iconCollector; + + /** + * @param InfoWindowCollector $infoWindowCollector + * @param IconCollector $iconCollector + */ + public function __construct(InfoWindowCollector $infoWindowCollector, IconCollector $iconCollector) + { + $this->setInfoWindowCollector($infoWindowCollector); + $this->setIconCollector($iconCollector); + } + + /** + * @return InfoWindowCollector + */ + public function getInfoWindowCollector() + { + return $this->infoWindowCollector; + } + + /** + * @param InfoWindowCollector $infoWindowCollector + */ + public function setInfoWindowCollector(InfoWindowCollector $infoWindowCollector) + { + $this->infoWindowCollector = $infoWindowCollector; + } + + /** + * @return IconCollector + */ + public function getIconCollector() + { + return $this->iconCollector; + } + + /** + * @param IconCollector $iconCollector + */ + public function setIconCollector(IconCollector $iconCollector) + { + $this->iconCollector = $iconCollector; + } + + /** + * @param Map $map + * @param Size[] $sizes + * + * @return Size[] + */ + public function collect(Map $map, array $sizes = []) + { + foreach ($this->infoWindowCollector->collect($map) as $infoWindow) { + if ($infoWindow->hasPixelOffset()) { + $sizes = $this->collectValue($infoWindow->getPixelOffset(), $sizes); + } + } + + foreach ($this->iconCollector->collect($map) as $icon) { + if ($icon->hasSize()) { + $sizes = $this->collectValue($icon->getSize(), $sizes); + } + + if ($icon->hasScaledSize()) { + $sizes = $this->collectValue($icon->getScaledSize(), $sizes); + } + } + + return $sizes; + } +} diff --git a/src/Helper/Collector/Event/DomEventCollector.php b/src/Helper/Collector/Event/DomEventCollector.php new file mode 100644 index 00000000..238debda --- /dev/null +++ b/src/Helper/Collector/Event/DomEventCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class DomEventCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Event[] $domEvents + * + * @return Event[] + */ + public function collect(Map $map, array $domEvents = []) + { + return $this->collectValues($map->getEventManager()->getDomEvents(), $domEvents); + } +} diff --git a/src/Helper/Collector/Event/DomEventOnceCollector.php b/src/Helper/Collector/Event/DomEventOnceCollector.php new file mode 100644 index 00000000..212a799a --- /dev/null +++ b/src/Helper/Collector/Event/DomEventOnceCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class DomEventOnceCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Event[] $domEventsOnce + * + * @return Event[] + */ + public function collect(Map $map, array $domEventsOnce = []) + { + return $this->collectValues($map->getEventManager()->getDomEventsOnce(), $domEventsOnce); + } +} diff --git a/src/Helper/Collector/Event/EventCollector.php b/src/Helper/Collector/Event/EventCollector.php new file mode 100644 index 00000000..a9d1ffc1 --- /dev/null +++ b/src/Helper/Collector/Event/EventCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class EventCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Event[] $events + * + * @return Event[] + */ + public function collect(Map $map, array $events = []) + { + return $this->collectValues($map->getEventManager()->getEvents(), $events); + } +} diff --git a/src/Helper/Collector/Event/EventOnceCollector.php b/src/Helper/Collector/Event/EventOnceCollector.php new file mode 100644 index 00000000..d8f41b2c --- /dev/null +++ b/src/Helper/Collector/Event/EventOnceCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class EventOnceCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Event[] $eventsOnce + * + * @return Event[] + */ + public function collect(Map $map, array $eventsOnce = []) + { + return $this->collectValues($map->getEventManager()->getEventsOnce(), $eventsOnce); + } +} diff --git a/src/Helper/Collector/Layer/KmlLayerCollector.php b/src/Helper/Collector/Layer/KmlLayerCollector.php new file mode 100644 index 00000000..140c3203 --- /dev/null +++ b/src/Helper/Collector/Layer/KmlLayerCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Layer; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Layer\KmlLayer; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class KmlLayerCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param KmlLayer[] $kmlLayers + * + * @return KmlLayer[] + */ + public function collect(Map $map, array $kmlLayers = []) + { + return $this->collectValues($map->getLayerManager()->getKmlLayers(), $kmlLayers); + } +} diff --git a/src/Helper/Collector/Overlay/CircleCollector.php b/src/Helper/Collector/Overlay/CircleCollector.php new file mode 100644 index 00000000..4ce3f478 --- /dev/null +++ b/src/Helper/Collector/Overlay/CircleCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Circle; + +/** + * @author GeLo + */ +class CircleCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Circle[] $circles + * + * @return Circle[] + */ + public function collect(Map $map, array $circles = []) + { + return $this->collectValues($map->getOverlayManager()->getCircles(), $circles); + } +} diff --git a/src/Helper/Collector/Overlay/DefaultInfoWindowCollector.php b/src/Helper/Collector/Overlay/DefaultInfoWindowCollector.php new file mode 100644 index 00000000..847c429d --- /dev/null +++ b/src/Helper/Collector/Overlay/DefaultInfoWindowCollector.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Overlay\InfoWindowType; + +/** + * @author GeLo + */ +class DefaultInfoWindowCollector extends InfoWindowCollector +{ + /** + * @param MarkerCollector $markerCollector + */ + public function __construct(MarkerCollector $markerCollector) + { + parent::__construct($markerCollector, InfoWindowType::DEFAULT_); + } +} diff --git a/src/Helper/Collector/Overlay/EncodedPolylineCollector.php b/src/Helper/Collector/Overlay/EncodedPolylineCollector.php new file mode 100644 index 00000000..a80f6a6b --- /dev/null +++ b/src/Helper/Collector/Overlay/EncodedPolylineCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\EncodedPolyline; + +/** + * @author GeLo + */ +class EncodedPolylineCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param EncodedPolyline[] $encodedPolylines + * + * @return EncodedPolyline[] + */ + public function collect(Map $map, array $encodedPolylines = []) + { + return $this->collectValues($map->getOverlayManager()->getEncodedPolylines(), $encodedPolylines); + } +} diff --git a/src/Helper/Collector/Overlay/ExtendableCollector.php b/src/Helper/Collector/Overlay/ExtendableCollector.php new file mode 100644 index 00000000..bbaa4c17 --- /dev/null +++ b/src/Helper/Collector/Overlay/ExtendableCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class ExtendableCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param ExtendableInterface[] $extendables + * + * @return ExtendableInterface[] + */ + public function collect(Map $map, array $extendables = []) + { + return $this->collectValues($map->getBound()->getExtendables(), $extendables); + } +} diff --git a/src/Helper/Collector/Overlay/GroundOverlayCollector.php b/src/Helper/Collector/Overlay/GroundOverlayCollector.php new file mode 100644 index 00000000..6230c140 --- /dev/null +++ b/src/Helper/Collector/Overlay/GroundOverlayCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\GroundOverlay; + +/** + * @author GeLo + */ +class GroundOverlayCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param GroundOverlay[] $groundOverlays + * + * @return GroundOverlay[] + */ + public function collect(Map $map, array $groundOverlays = []) + { + return $this->collectValues($map->getOverlayManager()->getGroundOverlays(), $groundOverlays); + } +} diff --git a/src/Helper/Collector/Overlay/IconCollector.php b/src/Helper/Collector/Overlay/IconCollector.php new file mode 100644 index 00000000..45689e58 --- /dev/null +++ b/src/Helper/Collector/Overlay/IconCollector.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Icon; + +/** + * @author GeLo + */ +class IconCollector extends AbstractCollector +{ + /** + * @var MarkerCollector + */ + private $markerCollector; + + /** + * @param MarkerCollector $markerCollector + */ + public function __construct(MarkerCollector $markerCollector) + { + $this->setMarkerCollector($markerCollector); + } + + /** + * @return MarkerCollector + */ + public function getMarkerCollector() + { + return $this->markerCollector; + } + + /** + * @param MarkerCollector $markerCollector + */ + public function setMarkerCollector(MarkerCollector $markerCollector) + { + $this->markerCollector = $markerCollector; + } + + /** + * @param Map $map + * @param Icon[] $icons + * + * @return Icon[] + */ + public function collect(Map $map, array $icons = []) + { + foreach ($this->markerCollector->collect($map) as $marker) { + if ($marker->hasIcon()) { + $icons = $this->collectValue($marker->getIcon(), $icons); + } + } + + return $icons; + } +} diff --git a/src/Helper/Collector/Overlay/InfoBoxCollector.php b/src/Helper/Collector/Overlay/InfoBoxCollector.php new file mode 100644 index 00000000..f28f73eb --- /dev/null +++ b/src/Helper/Collector/Overlay/InfoBoxCollector.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Overlay\InfoWindowType; + +/** + * @author GeLo + */ +class InfoBoxCollector extends InfoWindowCollector +{ + /** + * @param MarkerCollector $markerCollector + */ + public function __construct(MarkerCollector $markerCollector) + { + parent::__construct($markerCollector, InfoWindowType::INFO_BOX); + } +} diff --git a/src/Helper/Collector/Overlay/InfoWindowCollector.php b/src/Helper/Collector/Overlay/InfoWindowCollector.php new file mode 100644 index 00000000..82bc797c --- /dev/null +++ b/src/Helper/Collector/Overlay/InfoWindowCollector.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; + +/** + * @author GeLo + */ +class InfoWindowCollector extends AbstractCollector +{ + /** + * @var MarkerCollector + */ + private $markerCollector; + + /** + * @var string|null + */ + private $type; + + /** + * @param MarkerCollector $markerCollector + * @param string|null $type + */ + public function __construct(MarkerCollector $markerCollector, $type = null) + { + $this->setMarkerCollector($markerCollector); + $this->setType($type); + } + + /** + * @return MarkerCollector + */ + public function getMarkerCollector() + { + return $this->markerCollector; + } + + /** + * @param MarkerCollector $markerCollector + */ + public function setMarkerCollector(MarkerCollector $markerCollector) + { + $this->markerCollector = $markerCollector; + } + + /** + * @return string|null + */ + public function getType() + { + return $this->type; + } + + /** + * @param string|null $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @param Map $map + * @param InfoWindow[] $infoWindows + * @param bool $position + * + * @return InfoWindow[] + */ + public function collect(Map $map, array $infoWindows = [], $position = true) + { + if ($position) { + return $this->collectValues($map->getOverlayManager()->getInfoWindows(), $infoWindows); + } + + foreach ($this->markerCollector->collect($map) as $marker) { + if ($marker->hasInfoWindow()) { + $infoWindows = $this->collectValue($marker->getInfoWindow(), $infoWindows); + } + } + + return $infoWindows; + } + + /** + * {@inheritdoc} + */ + protected function collectValue($value, array $defaults = []) + { + if ($this->type !== null && $value->getType() !== $this->type) { + return $defaults; + } + + return parent::collectValue($value, $defaults); + } +} diff --git a/src/Helper/Collector/Overlay/MarkerCollector.php b/src/Helper/Collector/Overlay/MarkerCollector.php new file mode 100644 index 00000000..fb06e09c --- /dev/null +++ b/src/Helper/Collector/Overlay/MarkerCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class MarkerCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Marker[] $markers + * + * @return Marker[] + */ + public function collect(Map $map, array $markers = []) + { + return $this->collectValues($map->getOverlayManager()->getMarkers(), $markers); + } +} diff --git a/src/Helper/Collector/Overlay/PolygonCollector.php b/src/Helper/Collector/Overlay/PolygonCollector.php new file mode 100644 index 00000000..2436f3e1 --- /dev/null +++ b/src/Helper/Collector/Overlay/PolygonCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polygon; + +/** + * @author GeLo + */ +class PolygonCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Polygon[] $polygons + * + * @return Polygon[] + */ + public function collect(Map $map, array $polygons = []) + { + return $this->collectValues($map->getOverlayManager()->getPolygons(), $polygons); + } +} diff --git a/src/Helper/Collector/Overlay/PolylineCollector.php b/src/Helper/Collector/Overlay/PolylineCollector.php new file mode 100644 index 00000000..dcb2b52c --- /dev/null +++ b/src/Helper/Collector/Overlay/PolylineCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polyline; + +/** + * @author GeLo + */ +class PolylineCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Polyline[] $polylines + * + * @return Polyline[] + */ + public function collect(Map $map, array $polylines = []) + { + return $this->collectValues($map->getOverlayManager()->getPolylines(), $polylines); + } +} diff --git a/src/Helper/Collector/Overlay/RectangleCollector.php b/src/Helper/Collector/Overlay/RectangleCollector.php new file mode 100644 index 00000000..ce7a486f --- /dev/null +++ b/src/Helper/Collector/Overlay/RectangleCollector.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Rectangle; + +/** + * @author GeLo + */ +class RectangleCollector extends AbstractCollector +{ + /** + * @param Map $map + * @param Rectangle[] $rectangles + * + * @return Rectangle[] + */ + public function collect(Map $map, array $rectangles = []) + { + return $this->collectValues($map->getOverlayManager()->getRectangles(), $rectangles); + } +} diff --git a/src/Helper/Collector/Place/AutocompleteBoundCollector.php b/src/Helper/Collector/Place/AutocompleteBoundCollector.php new file mode 100644 index 00000000..009eabff --- /dev/null +++ b/src/Helper/Collector/Place/AutocompleteBoundCollector.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Place; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class AutocompleteBoundCollector extends AbstractCollector +{ + /** + * @param Autocomplete $autocomplete + * @param Bound[] $bounds + * + * @return Bound[] + */ + public function collect(Autocomplete $autocomplete, array $bounds = []) + { + if ($autocomplete->hasBound()) { + $bounds = $this->collectValue($autocomplete->getBound(), $bounds); + } + + return $bounds; + } +} diff --git a/src/Helper/Collector/Place/AutocompleteCoordinateCollector.php b/src/Helper/Collector/Place/AutocompleteCoordinateCollector.php new file mode 100644 index 00000000..bb4438c4 --- /dev/null +++ b/src/Helper/Collector/Place/AutocompleteCoordinateCollector.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Collector\Place; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Collector\AbstractCollector; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class AutocompleteCoordinateCollector extends AbstractCollector +{ + /** + * @var AutocompleteBoundCollector + */ + private $boundCollector; + + /** + * @param AutocompleteBoundCollector $boundCollector + */ + public function __construct(AutocompleteBoundCollector $boundCollector) + { + $this->setBoundCollector($boundCollector); + } + + /** + * @return AutocompleteBoundCollector + */ + public function getBoundCollector() + { + return $this->boundCollector; + } + + /** + * @param AutocompleteBoundCollector $boundCollector + */ + public function setBoundCollector(AutocompleteBoundCollector $boundCollector) + { + $this->boundCollector = $boundCollector; + } + + /** + * @param Autocomplete $autocomplete + * @param Coordinate[] $coordinates + * + * @return Coordinate[] + */ + public function collect(Autocomplete $autocomplete, array $coordinates = []) + { + foreach ($this->boundCollector->collect($autocomplete) as $bound) { + if ($bound->hasSouthWest()) { + $coordinates = $this->collectValue($bound->getSouthWest(), $coordinates); + } + + if ($bound->hasNorthEast()) { + $coordinates = $this->collectValue($bound->getNorthEast(), $coordinates); + } + } + + return $coordinates; + } +} diff --git a/src/Helper/Controls/ControlPositionHelper.php b/src/Helper/Controls/ControlPositionHelper.php deleted file mode 100644 index 54383eb6..00000000 --- a/src/Helper/Controls/ControlPositionHelper.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Exception\HelperException; - -/** - * Control position helper. - * - * @author GeLo - */ -class ControlPositionHelper -{ - /** - * Renders a control position. - * - * @param string $controlPosition The control position. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If the control position is not valid. - * - * @return The JS output. - */ - public function render($controlPosition) - { - switch ($controlPosition) { - case ControlPosition::BOTTOM_CENTER: - case ControlPosition::BOTTOM_LEFT: - case ControlPosition::BOTTOM_RIGHT: - case ControlPosition::LEFT_BOTTOM: - case ControlPosition::LEFT_CENTER: - case ControlPosition::LEFT_TOP: - case ControlPosition::RIGHT_BOTTOM: - case ControlPosition::RIGHT_CENTER: - case ControlPosition::RIGHT_TOP: - case ControlPosition::TOP_CENTER: - case ControlPosition::TOP_LEFT: - case ControlPosition::TOP_RIGHT: - return sprintf('google.maps.ControlPosition.%s', strtoupper($controlPosition)); - default: - throw HelperException::invalidControlPosition(); - } - } -} diff --git a/src/Helper/Controls/MapTypeControlHelper.php b/src/Helper/Controls/MapTypeControlHelper.php deleted file mode 100644 index 142ab5ac..00000000 --- a/src/Helper/Controls/MapTypeControlHelper.php +++ /dev/null @@ -1,159 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\MapTypeControl; -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Helper\MapTypeIdHelper; - -/** - * Map type control helper. - * - * @author GeLo - */ -class MapTypeControlHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\MapTypeIdHelper */ - protected $mapTypeIdHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper */ - protected $controlPositionHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\MapTypeControleStyleHelper */ - protected $mapTypeControlStyleHelper; - - /** - * Construct a map type control helper. - * - * @param \Ivory\GoogleMap\Helper\MapTypeIdHelper $mapTypeIdHelper The map type ID helper. - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - * @param \Ivory\GoogleMap\Helper\Controls\MapTypeControleStyleHelper $mapTypeControlStyleHelper The map type control style helper. - */ - public function __construct( - MapTypeIdHelper $mapTypeIdHelper = null, - ControlPositionHelper $controlPositionHelper = null, - MapTypeControlStyleHelper $mapTypeControlStyleHelper = null - ) { - parent::__construct(); - - if ($mapTypeIdHelper === null) { - $mapTypeIdHelper = new MapTypeIdHelper(); - } - - if ($controlPositionHelper === null) { - $controlPositionHelper = new ControlPositionHelper(); - } - - if ($mapTypeControlStyleHelper === null) { - $mapTypeControlStyleHelper = new MapTypeControlStyleHelper(); - } - - $this->setMapTypeIdHelper($mapTypeIdHelper); - $this->setControlPositionHelper($controlPositionHelper); - $this->setMapTypeControlStyleHelper($mapTypeControlStyleHelper); - } - - /** - * Gets the map type ID helper. - * - * @return \Ivory\GoogleMap\Helper\MapTypeIdHelper The map type ID helper. - */ - public function getMapTypeIdHelper() - { - return $this->mapTypeIdHelper; - } - - /** - * Sets the map type ID helper. - * - * @param \Ivory\GoogleMap\Helper\MapTypeIdHelper $mapTypeIdHelper The map type ID helper. - */ - public function setMapTypeIdHelper(MapTypeIdHelper $mapTypeIdHelper) - { - $this->mapTypeIdHelper = $mapTypeIdHelper; - } - - /** - * Gets the control position helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper The control position helper. - */ - public function getControlPositionHelper() - { - return $this->controlPositionHelper; - } - - /** - * Sets the control position helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function setControlPositionHelper(ControlPositionHelper $controlPositionHelper) - { - $this->controlPositionHelper = $controlPositionHelper; - } - - /** - * Gets the map type control style helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\MapTypeControlStyleHelper The map type control style helper. - */ - public function getMapTypeControlStyleHelper() - { - return $this->mapTypeControlStyleHelper; - } - - /** - * Sets the map type control style helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\MapTypeControlStyleHelper $mapTypeControlStyleHelper The map type - * control style - * helper. - */ - public function setMapTypeControlStyleHelper(MapTypeControlStyleHelper $mapTypeControlStyleHelper) - { - $this->mapTypeControlStyleHelper = $mapTypeControlStyleHelper; - } - - /** - * Renders a map type control. - * - * @param \Ivory\GoogleMap\Controls\MapTypeControl $mapTypeControl The map type control. - * - * @return string The JS output. - */ - public function render(MapTypeControl $mapTypeControl) - { - $this->jsonBuilder->reset(); - - foreach ($mapTypeControl->getMapTypeIds() as $index => $mapTypeId) { - $this->jsonBuilder->setValue( - sprintf('[mapTypeIds][%d]', $index), - $this->mapTypeIdHelper->render($mapTypeId), - false - ); - } - - return $this->jsonBuilder - ->setValue( - '[position]', - $this->controlPositionHelper->render($mapTypeControl->getControlPosition()), - false - ) - ->setValue( - '[style]', - $this->mapTypeControlStyleHelper->render($mapTypeControl->getMapTypeControlStyle()), - false - ) - ->build(); - } -} diff --git a/src/Helper/Controls/MapTypeControlStyleHelper.php b/src/Helper/Controls/MapTypeControlStyleHelper.php deleted file mode 100644 index 80ee9256..00000000 --- a/src/Helper/Controls/MapTypeControlStyleHelper.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\Exception\HelperException; - -/** - * Map type control style helper. - * - * @author GeLo - */ -class MapTypeControlStyleHelper -{ - /** - * Renders a map type control style. - * - * @param string $mapTypeControlStyle The map type control style. - * - * @throws \Ivory\GoogleMap\Exception\ControlException If the map type control style is not valid. - * - * @return string The JS output. - */ - public function render($mapTypeControlStyle) - { - switch ($mapTypeControlStyle) { - case MapTypeControlStyle::DEFAULT_: - case MapTypeControlStyle::DROPDOWN_MENU: - case MapTypeControlStyle::HORIZONTAL_BAR: - return sprintf('google.maps.MapTypeControlStyle.%s', strtoupper($mapTypeControlStyle)); - default: - throw HelperException::invalidMapTypeControlStyle(); - } - } -} diff --git a/src/Helper/Controls/OverviewMapControlHelper.php b/src/Helper/Controls/OverviewMapControlHelper.php deleted file mode 100644 index 1923dd1b..00000000 --- a/src/Helper/Controls/OverviewMapControlHelper.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\OverviewMapControl; -use Ivory\GoogleMap\Helper\AbstractHelper; - -/** - * Overview map control helper. - * - * @author GeLo - */ -class OverviewMapControlHelper extends AbstractHelper -{ - /** - * Renders an overview map control. - * - * @param \Ivory\GoogleMap\Controls\OverviewMapControl $overviewMapControl The overview map control. - * - * @return string The JS output. - */ - public function render(OverviewMapControl $overviewMapControl) - { - return $this->jsonBuilder - ->reset() - ->setValue('[opened]', $overviewMapControl->isOpened()) - ->build(); - } -} diff --git a/src/Helper/Controls/PanControlHelper.php b/src/Helper/Controls/PanControlHelper.php deleted file mode 100644 index 20e1c405..00000000 --- a/src/Helper/Controls/PanControlHelper.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\PanControl; -use Ivory\GoogleMap\Helper\AbstractHelper; - -/** - * Pan control helper. - * - * @author GeLo - */ -class PanControlHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper */ - protected $controlPositionHelper; - - /** - * Creates a pan control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function __construct(ControlPositionHelper $controlPositionHelper = null) - { - parent::__construct(); - - if ($controlPositionHelper === null) { - $controlPositionHelper = new ControlPositionHelper(); - } - - $this->setControlPositionHelper($controlPositionHelper); - } - - /** - * Gets the control position helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper The control position helper. - */ - public function getControlPositionHelper() - { - return $this->controlPositionHelper; - } - - /** - * Sets the control position helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function setControlPositionHelper(ControlPositionHelper $controlPositionHelper) - { - $this->controlPositionHelper = $controlPositionHelper; - } - - /** - * Renders a pan control. - * - * @param \Ivory\GoogleMap\Controls\PanControl $panControl The pan control. - * - * @return string The JS output. - */ - public function render(PanControl $panControl) - { - return $this->jsonBuilder - ->reset() - ->setValue('[position]', $this->controlPositionHelper->render($panControl->getControlPosition()), false) - ->build(); - } -} diff --git a/src/Helper/Controls/RotateControlHelper.php b/src/Helper/Controls/RotateControlHelper.php deleted file mode 100644 index 43ef4165..00000000 --- a/src/Helper/Controls/RotateControlHelper.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\RotateControl; -use Ivory\GoogleMap\Helper\AbstractHelper; - -/** - * Rotate control helper. - * - * @author GeLo - */ -class RotateControlHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper */ - protected $controlPositionHelper; - - /** - * Creates a rotate control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function __construct(ControlPositionHelper $controlPositionHelper = null) - { - parent::__construct(); - - if ($controlPositionHelper === null) { - $controlPositionHelper = new ControlPositionHelper(); - } - - $this->setControlPositionHelper($controlPositionHelper); - } - - /** - * Gets the control position helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper The control position helper. - */ - public function getControlPositionHelper() - { - return $this->controlPositionHelper; - } - - /** - * Sets the control position helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function setControlPositionHelper(ControlPositionHelper $controlPositionHelper) - { - $this->controlPositionHelper = $controlPositionHelper; - } - - /** - * Renders a rotate control. - * - * @param \Ivory\GoogleMap\Controls\RotateControl $rotateControl The rotate control. - * - * @return string The JS output. - */ - public function render(RotateControl $rotateControl) - { - return $this->jsonBuilder - ->reset() - ->setValue('[position]', $this->controlPositionHelper->render($rotateControl->getControlPosition()), false) - ->build(); - } -} diff --git a/src/Helper/Controls/ScaleControlHelper.php b/src/Helper/Controls/ScaleControlHelper.php deleted file mode 100644 index 4c3fddc6..00000000 --- a/src/Helper/Controls/ScaleControlHelper.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ScaleControl; -use Ivory\GoogleMap\Helper\AbstractHelper; - -/** - * Scale control helper. - * - * @author GeLo - */ -class ScaleControlHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper */ - protected $controlPositionHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\ScaleControleStyleHelper */ - protected $scaleControlStyleHelper; - - /** - * Construct a scale control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position - * helper. - * @param \Ivory\GoogleMap\Helper\Controls\ScaleControleStyleHelper $scaleControlStyleHelper The scale control - * style helper. - */ - public function __construct( - ControlPositionHelper $controlPositionHelper = null, - ScaleControlStyleHelper $scaleControlStyleHelper = null - ) { - parent::__construct(); - - if ($controlPositionHelper === null) { - $controlPositionHelper = new ControlPositionHelper(); - } - - if ($scaleControlStyleHelper === null) { - $scaleControlStyleHelper = new ScaleControlStyleHelper(); - } - - $this->setControlPositionHelper($controlPositionHelper); - $this->setScaleControlStyleHelper($scaleControlStyleHelper); - } - - /** - * Gets the control position helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper The control position helper. - */ - public function getControlPositionHelper() - { - return $this->controlPositionHelper; - } - - /** - * Sets the control position helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function setControlPositionHelper(ControlPositionHelper $controlPositionHelper) - { - $this->controlPositionHelper = $controlPositionHelper; - } - - /** - * Gets the scale control style helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ScaleControlStyleHelper The scale control style helper. - */ - public function getScaleControlStyleHelper() - { - return $this->scaleControlStyleHelper; - } - - /** - * Sets the scale control style helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ScaleControlStyleHelper $scaleControlStyleHelper The scale control style - * helper. - */ - public function setScaleControlStyleHelper(ScaleControlStyleHelper $scaleControlStyleHelper) - { - $this->scaleControlStyleHelper = $scaleControlStyleHelper; - } - - /** - * Renders a scale control. - * - * @param \Ivory\GoogleMap\Controls\ScaleControl $scaleControl The scale control. - * - * @return string The JS output. - */ - public function render(ScaleControl $scaleControl) - { - return $this->jsonBuilder - ->reset() - ->setValue('[position]', $this->controlPositionHelper->render($scaleControl->getControlPosition()), false) - ->setValue('[style]', $this->scaleControlStyleHelper->render($scaleControl->getScaleControlStyle()), false) - ->build(); - } -} diff --git a/src/Helper/Controls/ScaleControlStyleHelper.php b/src/Helper/Controls/ScaleControlStyleHelper.php deleted file mode 100644 index bda47d86..00000000 --- a/src/Helper/Controls/ScaleControlStyleHelper.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ScaleControlStyle; -use Ivory\GoogleMap\Exception\HelperException; - -/** - * Scale control style helper. - * - * @author GeLo - */ -class ScaleControlStyleHelper -{ - /** - * Renders a scale control style. - * - * @param string $scaleControlStyle The scale control style. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If the scale control style is not valid. - * - * @return string The JS output. - */ - public function render($scaleControlStyle) - { - switch ($scaleControlStyle) { - case ScaleControlStyle::DEFAULT_: - return sprintf('google.maps.ScaleControlStyle.%s', strtoupper($scaleControlStyle)); - default: - throw HelperException::invalidScaleControlStyle(); - } - } -} diff --git a/src/Helper/Controls/StreetViewControlHelper.php b/src/Helper/Controls/StreetViewControlHelper.php deleted file mode 100644 index 69dd3f36..00000000 --- a/src/Helper/Controls/StreetViewControlHelper.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\StreetViewControl; -use Ivory\GoogleMap\Helper\AbstractHelper; - -/** - * Street view control helper. - * - * @author GeLo - */ -class StreetViewControlHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper */ - protected $controlPositionHelper; - - /** - * Creates a street view control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function __construct(ControlPositionHelper $controlPositionHelper = null) - { - parent::__construct(); - - if ($controlPositionHelper === null) { - $controlPositionHelper = new ControlPositionHelper(); - } - - $this->setControlPositionHelper($controlPositionHelper); - } - - /** - * Gets the control position helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper The control position helper. - */ - public function getControlPositionHelper() - { - return $this->controlPositionHelper; - } - - /** - * Sets the control position helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function setControlPositionHelper(ControlPositionHelper $controlPositionHelper) - { - $this->controlPositionHelper = $controlPositionHelper; - } - - /** - * Renders the street view control - * - * @param Ivory\GoogleMapBundle\Model\Controls\StreetViewControl $streetViewControl - * @return string HTML output - */ - public function render(StreetViewControl $streetViewControl) - { - return $this->jsonBuilder - ->reset() - ->setValue( - '[position]', - $this->controlPositionHelper->render($streetViewControl->getControlPosition()), - false - ) - ->build(); - } -} diff --git a/src/Helper/Controls/ZoomControlHelper.php b/src/Helper/Controls/ZoomControlHelper.php deleted file mode 100644 index 41e8dbf0..00000000 --- a/src/Helper/Controls/ZoomControlHelper.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ZoomControl; -use Ivory\GoogleMap\Helper\AbstractHelper; - -/** - * Zoom control helper. - * - * @author GeLo - */ -class ZoomControlHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper */ - protected $controlPositionHelper; - - /** @var \vory\GoogleMap\Templating\Helper\Controls\ZoomControlStyleHelper */ - protected $zoomControlStyleHelper; - - /** - * Create a zoom control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position - * helper. - * @param \Ivory\GoogleMap\Helper\Controls\ZoomControlStyleHelper $zoomControlStyleHelper The zoom control style - * helper. - */ - public function __construct( - ControlPositionHelper $controlPositionHelper = null, - ZoomControlStyleHelper $zoomControlStyleHelper = null - ) { - parent::__construct(); - - if ($controlPositionHelper === null) { - $controlPositionHelper = new ControlPositionHelper(); - } - - if ($zoomControlStyleHelper === null) { - $zoomControlStyleHelper = new ZoomControlStyleHelper(); - } - - $this->setControlPositionHelper($controlPositionHelper); - $this->setZoomControlStyleHelper($zoomControlStyleHelper); - } - - /** - * Gets the control position helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper The control position helper. - */ - public function getControlPositionHelper() - { - return $this->controlPositionHelper; - } - - /** - * Sets the control position helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper $controlPositionHelper The control position helper. - */ - public function setControlPositionHelper(ControlPositionHelper $controlPositionHelper) - { - $this->controlPositionHelper = $controlPositionHelper; - } - - /** - * Gets the zoom control style helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ZoomControlStyleHelper The zoom control style helper. - */ - public function getZoomControlStyleHelper() - { - return $this->zoomControlStyleHelper; - } - - /** - * Sets the zoom control style helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ZoomControlStyleHelper $zoomControlStyleHelper The zoom control style - * helper. - */ - public function setZoomControlStyleHelper(ZoomControlStyleHelper $zoomControlStyleHelper) - { - $this->zoomControlStyleHelper = $zoomControlStyleHelper; - } - - /** - * Renders a zoom control. - * - * @param \Ivory\GoogleMap\Controls\ZoomControl $zoomControl The zoom control. - * - * @return string The JS output. - */ - public function render(ZoomControl $zoomControl) - { - return $this->jsonBuilder - ->reset() - ->setValue('[position]', $this->controlPositionHelper->render($zoomControl->getControlPosition()), false) - ->setValue('[style]', $this->zoomControlStyleHelper->render($zoomControl->getZoomControlStyle()), false) - ->build(); - } -} diff --git a/src/Helper/Controls/ZoomControlStyleHelper.php b/src/Helper/Controls/ZoomControlStyleHelper.php deleted file mode 100644 index b6ebbe1d..00000000 --- a/src/Helper/Controls/ZoomControlStyleHelper.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ZoomControlStyle; -use Ivory\GoogleMap\Exception\HelperException; - -/** - * Zoom control style helper. - * - * @author GeLo - */ -class ZoomControlStyleHelper -{ - /** - * Renders a zoom control style. - * - * @param string $zoomControlStyle The zoom control style. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If thhe zoom control style is not valid. - * - * @return string The JS output. - */ - public function render($zoomControlStyle) - { - switch ($zoomControlStyle) { - case ZoomControlStyle::DEFAULT_: - case ZoomControlStyle::LARGE: - case ZoomControlStyle::SMALL: - return sprintf('google.maps.ZoomControlStyle.%s', strtoupper($zoomControlStyle)); - default: - throw HelperException::invalidZoomControlStyle(); - } - } -} diff --git a/src/Helper/Event/AbstractEvent.php b/src/Helper/Event/AbstractEvent.php new file mode 100644 index 00000000..c74d0c98 --- /dev/null +++ b/src/Helper/Event/AbstractEvent.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Event; + +use Symfony\Component\EventDispatcher\Event; + +/** + * @author GeLo + */ +class AbstractEvent extends Event +{ + /** + * @var string + */ + private $code = ''; + + /** + * @return bool + */ + public function hasCode() + { + return !empty($this->code); + } + + /** + * @return string|null + */ + public function getCode() + { + return $this->code; + } + + /** + * @param string $code + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * @param string $code + */ + public function addCode($code) + { + $this->code .= $code; + } +} diff --git a/src/Helper/Event/ApiEvent.php b/src/Helper/Event/ApiEvent.php new file mode 100644 index 00000000..fe75675e --- /dev/null +++ b/src/Helper/Event/ApiEvent.php @@ -0,0 +1,442 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Event; + +/** + * @author GeLo + */ +class ApiEvent extends AbstractEvent +{ + /** + * @var object[] + */ + private $objects; + + /** + * @var string + */ + private $language = 'en'; + + /** + * @var string[] + */ + private $sources = []; + + /** + * @var string[] + */ + private $libraries = []; + + /** + * @var \SplObjectStorage + */ + private $callbacks; + + /** + * @var \SplObjectStorage + */ + private $requirements; + + /** + * @param object[] $objects + */ + public function __construct(array $objects) + { + $this->objects = $objects; + $this->callbacks = new \SplObjectStorage(); + $this->requirements = new \SplObjectStorage(); + } + + /** + * @param string|null $class + * + * @return bool + */ + public function hasObjects($class = null) + { + $objects = $this->getObjects($class); + + return !empty($objects); + } + + /** + * @param string|null $class + * + * @return object[] + */ + public function getObjects($class = null) + { + if ($class === null) { + return $this->objects; + } + + $objects = []; + + foreach ($this->objects as $object) { + if ($object instanceof $class) { + $objects[] = $object; + } + } + + return $objects; + } + + /** + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * @param string $language + */ + public function setLanguage($language) + { + $this->language = $language; + } + + /** + * @return bool + */ + public function hasSources() + { + return !empty($this->sources); + } + + /** + * @return string[] + */ + public function getSources() + { + return $this->sources; + } + + /** + * @param string[] $sources + */ + public function setSources(array $sources) + { + $this->sources = []; + $this->addSources($sources); + } + + /** + * @param string[] $sources + */ + public function addSources(array $sources) + { + foreach ($sources as $source) { + $this->addSource($source); + } + } + + /** + * @param string $source + * + * @return bool + */ + public function hasSource($source) + { + return in_array($source, $this->sources, true); + } + + /** + * @param string $source + */ + public function addSource($source) + { + if (!$this->hasSource($source)) { + $this->sources[] = $source; + } + } + + /** + * @param string $source + */ + public function removeSource($source) + { + unset($this->sources[array_search($source, $this->sources, true)]); + $this->sources = array_values($this->sources); + } + + /** + * @return bool + */ + public function hasLibraries() + { + return !empty($this->libraries); + } + + /** + * @return string[] + */ + public function getLibraries() + { + return $this->libraries; + } + + /** + * @param string[] $libraries + */ + public function setLibraries(array $libraries) + { + $this->libraries = []; + $this->addLibraries($libraries); + } + + /** + * @param string[] $libraries + */ + public function addLibraries(array $libraries) + { + foreach ($libraries as $library) { + $this->addLibrary($library); + } + } + + /** + * @param string $library + * + * @return bool + */ + public function hasLibrary($library) + { + return in_array($library, $this->libraries, true); + } + + /** + * @param string $library + */ + public function addLibrary($library) + { + if (!$this->hasLibrary($library)) { + $this->libraries[] = $library; + } + } + + /** + * @param string $library + */ + public function removeLibrary($library) + { + unset($this->libraries[array_search($library, $this->libraries, true)]); + $this->libraries = array_values($this->libraries); + } + + /** + * @return bool + */ + public function hasCallbacks() + { + return count($this->callbacks) > 0; + } + + /** + * @return \SplObjectStorage + */ + public function getCallbacks() + { + return $this->callbacks; + } + + /** + * @param string $callback + * @param object|null $object + * + * @return bool + */ + public function hasCallback($callback, $object = null) + { + foreach ($this->callbacks as $rawObject) { + if ($this->callbacks[$rawObject] === $callback && ($object === null || $object === $rawObject)) { + return true; + } + } + + return false; + } + + /** + * @param object $object + * @param string|null $callback + * + * @return bool + */ + public function hasCallbackObject($object, $callback = null) + { + return isset($this->callbacks[$object]) && ($callback === null || $this->callbacks[$object] === $callback); + } + + /** + * @param $object + * + * @return string|null + */ + public function getCallback($object) + { + return $this->hasCallbackObject($object) ? $this->callbacks[$object] : null; + } + + /** + * @param string $callback + * + * @return object + */ + public function getCallbackObject($callback) + { + foreach ($this->callbacks as $object) { + if ($this->callbacks[$object] === $callback) { + return $object; + } + } + } + + /** + * @param object $object + * @param string $callback + */ + public function addCallback($object, $callback) + { + if (!$this->hasCallback($callback, $object)) { + $this->callbacks[$object] = $callback; + } + } + + /** + * @param object $object + */ + public function removeCallbackObject($object) + { + unset($this->callbacks[$object]); + } + + /** + * @param string $callback + */ + public function removeCallback($callback) + { + if ($this->hasCallback($callback)) { + $this->removeCallbackObject($this->getCallbackObject($callback)); + } + } + + /** + * @param object|null $object + * + * @return bool + */ + public function hasRequirements($object = null) + { + if ($object === null) { + return count($this->requirements) > 0; + } + + $requirements = $this->getRequirementsObject($object); + + return !empty($requirements); + } + + /** + * @return \SplObjectStorage + */ + public function getRequirements() + { + return $this->requirements; + } + + /** + * @param object $object + * + * @return string[] + */ + public function getRequirementsObject($object) + { + return $this->hasRequirement($object) ? $this->requirements[$object] : []; + } + + /** + * @param object $object + * @param string[] $requirements + */ + public function setRequirements($object, array $requirements) + { + $this->requirements = new \SplObjectStorage(); + $this->addRequirements($object, $requirements); + } + + /** + * @param object $object + * @param string[] $requirements + */ + public function addRequirements($object, array $requirements) + { + foreach ($requirements as $requirement) { + $this->addRequirement($object, $requirement); + } + } + + /** + * @param object $object + * @param string|null $requirement + * + * @return bool + */ + public function hasRequirement($object, $requirement = null) + { + return isset($this->requirements[$object]) + && ($requirement === null || in_array($requirement, $this->requirements[$object], true)); + } + + /** + * @param object $object + * @param string $requirement + */ + public function addRequirement($object, $requirement) + { + if (!$this->hasRequirement($object)) { + $this->requirements[$object] = []; + } + + if (!$this->hasRequirement($object, $requirement)) { + $this->requirements[$object] = array_merge( + $this->requirements[$object], + [$requirement] + ); + } + } + + /** + * @param object $object + * @param string|null $requirement + */ + public function removeRequirement($object, $requirement = null) + { + if ($requirement === null) { + unset($this->requirements[$object]); + + return; + } + + if ($this->hasRequirement($object, $requirement)) { + $requirements = $this->requirements[$object]; + unset($requirements[array_search($requirement, $requirements, true)]); + + if (!empty($requirements)) { + $this->requirements[$object] = array_values($requirements); + } else { + $this->removeRequirement($object); + } + } + } +} diff --git a/src/Helper/Event/ApiEvents.php b/src/Helper/Event/ApiEvents.php new file mode 100644 index 00000000..c32c5da1 --- /dev/null +++ b/src/Helper/Event/ApiEvents.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Event; + +/** + * @author GeLo + */ +final class ApiEvents +{ + const JAVASCRIPT = 'api.javascript'; + const JAVASCRIPT_MAP = 'api.javascript.map'; + const JAVASCRIPT_AUTOCOMPLETE = 'api.javascript.autocomplete'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Helper/Event/MapEvent.php b/src/Helper/Event/MapEvent.php new file mode 100644 index 00000000..aba2c17e --- /dev/null +++ b/src/Helper/Event/MapEvent.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Event; + +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class MapEvent extends AbstractEvent +{ + /** + * @var Map + */ + private $map; + + /** + * @param Map $map + */ + public function __construct(Map $map) + { + $this->map = $map; + } + + /** + * @return Map + */ + public function getMap() + { + return $this->map; + } +} diff --git a/src/Helper/Event/MapEvents.php b/src/Helper/Event/MapEvents.php new file mode 100644 index 00000000..bf1308e6 --- /dev/null +++ b/src/Helper/Event/MapEvents.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Event; + +/** + * @author GeLo + */ +final class MapEvents +{ + const HTML = 'map.renderHtml'; + const STYLESHEET = 'map.stylesheet'; + const JAVASCRIPT = 'map.javascript'; + const JAVASCRIPT_INIT = 'map.javascript.init'; + const JAVASCRIPT_INIT_CONTAINER = 'map.javascript.init.container'; + const JAVASCRIPT_INIT_FUNCTION = 'map.javascript.init.function'; + const JAVASCRIPT_BASE = 'map.javascript.base'; + const JAVASCRIPT_BASE_COORDINATE = 'map.javascript.base.coordinate'; + const JAVASCRIPT_BASE_BOUND = 'map.javascript.base.bound'; + const JAVASCRIPT_BASE_POINT = 'map.javascript.base.point'; + const JAVASCRIPT_BASE_SIZE = 'map.javascript.base.size'; + const JAVASCRIPT_MAP = 'map.javascript.map'; + const JAVASCRIPT_OVERLAY = 'map.javascript.overlay'; + const JAVASCRIPT_OVERLAY_CIRCLE = 'map.javascript.overlay.circle'; + const JAVASCRIPT_OVERLAY_ENCODED_POLYLINE = 'map.javascript.overlay.encoded_polyline'; + const JAVASCRIPT_OVERLAY_GROUND_OVERLAY = 'map.javascript.overlay.ground_overlay'; + const JAVASCRIPT_OVERLAY_POLYGON = 'map.javascript.overlay.polygon'; + const JAVASCRIPT_OVERLAY_POLYLINE = 'map.javascript.overlay.polyline'; + const JAVASCRIPT_OVERLAY_RECTANGLE = 'map.javascript.overlay.rectangle'; + const JAVASCRIPT_OVERLAY_INFO_WINDOW = 'map.javascript.overlay.info_window'; + const JAVASCRIPT_OVERLAY_MARKER_IMAGE = 'map.javascript.overlay.marker_image'; + const JAVASCRIPT_OVERLAY_MARKER_SHAPE = 'map.javascript.overlay.marker_shape'; + const JAVASCRIPT_OVERLAY_MARKER = 'map.javascript.overlay.marker'; + const JAVASCRIPT_OVERLAY_MARKER_CLUSTER = 'map.javascript.overlay.marker_cluster'; + const JAVASCRIPT_LAYER = 'map.javascript.layer'; + const JAVASCRIPT_LAYER_KML_LAYER = 'map.javascript.layer.kml_layer'; + const JAVASCRIPT_EVENT = 'map.javascript.event'; + const JAVASCRIPT_EVENT_DOM_EVENT = 'map.javascript.event.dom_event'; + const JAVASCRIPT_EVENT_DOM_EVENT_ONCE = 'map.javascript.event.dom_event_once'; + const JAVASCRIPT_EVENT_EVENT = 'map.javascript.event.event'; + const JAVASCRIPT_EVENT_EVENT_ONCE = 'map.javascript.event.event_once'; + const JAVASCRIPT_FINISH = 'map.javascript.finish'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Helper/Event/PlaceAutocompleteEvent.php b/src/Helper/Event/PlaceAutocompleteEvent.php new file mode 100644 index 00000000..6db4afde --- /dev/null +++ b/src/Helper/Event/PlaceAutocompleteEvent.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Event; + +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class PlaceAutocompleteEvent extends AbstractEvent +{ + /** + * @var Autocomplete + */ + private $autocomplete; + + /** + * @param Autocomplete $autocomplete + */ + public function __construct(Autocomplete $autocomplete) + { + $this->autocomplete = $autocomplete; + } + + /** + * @return Autocomplete + */ + public function getAutocomplete() + { + return $this->autocomplete; + } +} diff --git a/src/Helper/Event/PlaceAutocompleteEvents.php b/src/Helper/Event/PlaceAutocompleteEvents.php new file mode 100644 index 00000000..7fd375a7 --- /dev/null +++ b/src/Helper/Event/PlaceAutocompleteEvents.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Event; + +/** + * @author GeLo + */ +final class PlaceAutocompleteEvents +{ + const HTML = 'autocomplete.renderHtml'; + const JAVASCRIPT = 'autocomplete.javascript'; + const JAVASCRIPT_INIT = 'autocomplete.javascript.init'; + const JAVASCRIPT_INIT_CONTAINER = 'autocomplete.javascript.init.container'; + const JAVASCRIPT_BASE = 'autocomplete.javascript.base'; + const JAVASCRIPT_BASE_COORDINATE = 'autocomplete.javascript.base.coordinate'; + const JAVASCRIPT_BASE_BOUND = 'autocomplete.javascript.base.bound'; + const JAVASCRIPT_AUTOCOMPLETE = 'autocomplete.javascript.autocomplete'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Helper/Events/EventManagerHelper.php b/src/Helper/Events/EventManagerHelper.php deleted file mode 100644 index c86549bf..00000000 --- a/src/Helper/Events/EventManagerHelper.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Events; - -use Ivory\GoogleMap\Events\Event; - -/** - * Event manager helper. - * - * @author GeLo - */ -class EventManagerHelper -{ - /** - * Renders a dom event. - * - * @param \Ivory\GoogleMap\Events\Event $domEvent The dom event. - * - * @return string The JS output. - */ - public function renderDomEvent(Event $domEvent) - { - return sprintf( - '%s = google.maps.event.addDomListener(%s, "%s", %s, %s);'.PHP_EOL, - $domEvent->getJavascriptVariable(), - $domEvent->getInstance(), - $domEvent->getEventName(), - $domEvent->getHandle(), - json_encode($domEvent->isCapture()) - ); - } - - /** - * Renders a dom event once. - * - * @param \Ivory\GoogleMap\Events\Event $domEventOnce The dom event once. - * - * @return string The JS output. - */ - public function renderDomEventOnce(Event $domEventOnce) - { - return sprintf( - '%s = google.maps.event.addDomListenerOnce(%s, "%s", %s, %s);'.PHP_EOL, - $domEventOnce->getJavascriptVariable(), - $domEventOnce->getInstance(), - $domEventOnce->getEventName(), - $domEventOnce->getHandle(), - json_encode($domEventOnce->isCapture()) - ); - } - - /** - * Renders an event. - * - * @param \Ivory\GoogleMap\Events\Event $event The event. - * - * @return string The JS output. - */ - public function renderEvent(Event $event) - { - return sprintf( - '%s = google.maps.event.addListener(%s, "%s", %s);'.PHP_EOL, - $event->getJavascriptVariable(), - $event->getInstance(), - $event->getEventName(), - $event->getHandle() - ); - } - - /** - * Renders an event once. - * - * @param \Ivory\GoogleMap\Events\Event $eventOnce The event once. - * - * @return string The JS output. - */ - public function renderEventOnce(Event $eventOnce) - { - return sprintf( - '%s = google.maps.event.addListenerOnce(%s, "%s", %s);'.PHP_EOL, - $eventOnce->getJavascriptVariable(), - $eventOnce->getInstance(), - $eventOnce->getEventName(), - $eventOnce->getHandle() - ); - } -} diff --git a/src/Helper/Extension/AbstractExtensionHelper.php b/src/Helper/Extension/AbstractExtensionHelper.php deleted file mode 100644 index 5e704afc..00000000 --- a/src/Helper/Extension/AbstractExtensionHelper.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Extension; - -/** - * Abstract extension. - * - * @author GeLo - */ -abstract class AbstractExtensionHelper implements ExtensionHelperInterface -{ - /** - * Renders a library. - * - * @param string $source The library source. - * @param string|null $callback The javascript callback. - * - * @return string The HTML output. - */ - protected function renderLibrary($source, $callback = null) - { - if ($callback === null) { - return sprintf(''.PHP_EOL, $source); - } - - $output = array(); - - $output[] = 'var s = document.createElement("script");'.PHP_EOL; - $output[] = 's.type = "text/javascript";'.PHP_EOL; - $output[] = 's.async = true;'.PHP_EOL; - $output[] = sprintf('s.src = "%s";'.PHP_EOL, $source); - $output[] = sprintf('s.addEventListener("load", function () { %s(); }, false);'.PHP_EOL, $callback); - $output[] = 'document.getElementsByTagName("head")[0].appendChild(s);'.PHP_EOL; - - return implode('', $output); - } -} diff --git a/src/Helper/Extension/CoreExtensionHelper.php b/src/Helper/Extension/CoreExtensionHelper.php deleted file mode 100644 index c697a25b..00000000 --- a/src/Helper/Extension/CoreExtensionHelper.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Extension; - -use Ivory\GoogleMap\Helper\ApiHelper; -use Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper; -use Ivory\GoogleMap\Map; - -/** - * Core extension helper. - * - * @author GeLo - */ -class CoreExtensionHelper implements ExtensionHelperInterface -{ - /** @var \Ivory\GoogleMap\Helper\ApiHelper */ - protected $apiHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper */ - protected $markerClusterHelper; - - /** - * Creates a core extension helper. - * - * @param \Ivory\GoogleMap\Helper\ApiHelper $apiHelper The api helper. - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper $markerClusterHelper The marker cluster helper. - */ - public function __construct(ApiHelper $apiHelper = null, MarkerClusterHelper $markerClusterHelper = null) - { - if ($apiHelper === null) { - $apiHelper = new ApiHelper(); - } - - if ($markerClusterHelper === null) { - $markerClusterHelper = new MarkerClusterHelper(); - } - - $this->setApiHelper($apiHelper); - $this->setMarkerClusterHelper($markerClusterHelper); - } - - /** - * Gets the api helper. - * - * @return \Ivory\GoogleMap\Helper\ApiHelper The api helper. - */ - public function getApiHelper() - { - return $this->apiHelper; - } - - /** - * Sets the api helper. - * - * @param \Ivory\GoogleMap\Helper\ApiHelper $apiHelper The api helper. - */ - public function setApiHelper(ApiHelper $apiHelper) - { - $this->apiHelper = $apiHelper; - } - - /** - * Gets the marker cluster helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper The marker cluster helper. - */ - public function getMarkerClusterHelper() - { - return $this->markerClusterHelper; - } - - /** - * Sets the marker cluster helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper $markerClusterHelper The marker cluster helper. - */ - public function setMarkerClusterHelper(MarkerClusterHelper $markerClusterHelper) - { - $this->markerClusterHelper = $markerClusterHelper; - } - - /** - * {@inheritdoc} - */ - public function renderLibraries(Map $map) - { - if ($this->apiHelper->isLoaded()) { - return; - } - - $callback = null; - - if ($map->isAsync()) { - $callback = 'load_ivory_google_map'; - } - - $output = array(); - - $output[] = $this->apiHelper->render($map->getLanguage(), $this->getLibraries($map), $callback); - $output[] = $this->markerClusterHelper->renderLibraries($map->getMarkerCluster(), $map); - - return implode('', $output); - } - - /** - * {@inheritdoc} - */ - public function renderBefore(Map $map) - { - if ($map->isAsync()) { - return 'function load_ivory_google_map() {'.PHP_EOL; - } - } - - /** - * {@inheritdoc} - */ - public function renderAfter(Map $map) - { - if ($map->isAsync()) { - return '}'.PHP_EOL; - } - } - - /** - * Gets the libraries needed for the map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return array The map libraries. - */ - protected function getLibraries(Map $map) - { - $libraries = $map->getLibraries(); - - $encodedPolylines = $map->getEncodedPolylines(); - if (!empty($encodedPolylines)) { - $libraries[] = 'geometry'; - } - - return array_unique($libraries); - } -} diff --git a/src/Helper/Extension/ExtensionHelperInterface.php b/src/Helper/Extension/ExtensionHelperInterface.php deleted file mode 100644 index 0cd3d451..00000000 --- a/src/Helper/Extension/ExtensionHelperInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Extension; - -use Ivory\GoogleMap\Map; - -/** - * Extension helper. - * - * @author GeLo - */ -interface ExtensionHelperInterface -{ - /** - * Renders libraires. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The html output. - */ - public function renderLibraries(Map $map); - - /** - * Renders JS code just before the generated one. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderBefore(Map $map); - - /** - * Renders JS code just after the generated one. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderAfter(Map $map); -} diff --git a/src/Helper/Extension/InfoBoxExtensionHelper.php b/src/Helper/Extension/InfoBoxExtensionHelper.php deleted file mode 100644 index f78b4299..00000000 --- a/src/Helper/Extension/InfoBoxExtensionHelper.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Extension; - -use Ivory\GoogleMap\Map; - -/** - * InfoBox extension helper. - * - * @author GeLo - */ -class InfoBoxExtensionHelper extends AbstractExtensionHelper -{ - /** @var string */ - protected $source; - - /** @var string */ - protected $callback; - - /** - * Creates an info box extension helper. - * - * @param string $source The info box source URL. - * @param string $callback The info box callback. - */ - public function __construct( - $source = '//google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox_packed.js', - $callback = 'load_ivory_google_map_info_box' - ) { - $this->setSource($source); - $this->setCallback($callback); - } - - /** - * Gets the info box source URL. - * - * @return string The info box source URL. - */ - public function getSource() - { - return $this->source; - } - - /** - * Sets the info box source URL. - * - * @param string $source The info box source URL. - */ - public function setSource($source) - { - $this->source = $source; - } - - /** - * Gets the javascript callback. - * - * @return string The javascript callback. - */ - public function getCallback() - { - return $this->callback; - } - - /** - * Sets the javascript callback. - * - * @param string $callback The javascript callback. - */ - public function setCallback($callback) - { - $this->callback = $callback; - } - - /** - * {@inheritdoc} - */ - public function renderLibraries(Map $map) - { - if (!$map->isAsync()) { - return $this->renderLibrary($this->source); - } - } - - /** - * {@inheritdoc} - */ - public function renderBefore(Map $map) - { - if ($map->isAsync()) { - return sprintf('function %s () {'.PHP_EOL, $this->callback); - } - } - - /** - * {@inheritdoc} - */ - public function renderAfter(Map $map) - { - if ($map->isAsync()) { - return '}'.PHP_EOL.$this->renderLibrary($this->source, $this->callback); - } - } -} diff --git a/src/Helper/Formatter/Formatter.php b/src/Helper/Formatter/Formatter.php new file mode 100644 index 00000000..4e370cf9 --- /dev/null +++ b/src/Helper/Formatter/Formatter.php @@ -0,0 +1,449 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source declaration. + */ + +namespace Ivory\GoogleMap\Helper\Formatter; + +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class Formatter +{ + /** + * @var int + */ + private $defaultIndentation; + + /** + * @var int + */ + private $indentationStep; + + /** + * @var bool + */ + private $debug; + + /** + * @param int $defaultIndentation + * @param int $indentationStep + * @param bool $debug + */ + public function __construct($defaultIndentation = 0, $indentationStep = 4, $debug = false) + { + $this->setDefaultIndentation($defaultIndentation); + $this->setIndentationStep($indentationStep); + $this->setDebug($debug); + } + + /** + * @return int + */ + public function getDefaultIndentation() + { + return $this->defaultIndentation; + } + + /** + * @param int $defaultIndentation + */ + public function setDefaultIndentation($defaultIndentation) + { + $this->defaultIndentation = $defaultIndentation; + } + + /** + * @return int + */ + public function getIndentationStep() + { + return $this->indentationStep; + } + + /** + * @param int $indentationStep + */ + public function setIndentationStep($indentationStep) + { + $this->indentationStep = $indentationStep; + } + + /** + * @return bool + */ + public function isDebug() + { + return $this->debug; + } + + /** + * @param bool $debug + */ + public function setDebug($debug) + { + $this->debug = $debug; + } + + /** + * @param string|null $name + * @param string|false|null $namespace + * + * @return string + */ + public function renderClass($name = null, $namespace = null) + { + if ($namespace === null) { + $namespace = $this->renderProperty('google', 'maps'); + } + + if (empty($namespace)) { + return $name; + } + + return $this->renderProperty($namespace, $name); + } + + /** + * @param string $class + * @param string $value + * @param string|false|null $namespace + * + * @return string + */ + public function renderConstant($class, $value, $namespace = null) + { + return $this->renderClass($this->renderProperty($class, strtoupper($value)), $namespace); + } + + /** + * @param string $class + * @param string[] $arguments + * @param string|false|null $namespace + * @param bool $semicolon + * @param bool $newLine + * + * @return string + */ + public function renderObject( + $class, + array $arguments = [], + $namespace = null, + $semicolon = false, + $newLine = false + ) { + return $this->renderCall( + 'new '.$this->renderClass($class, $namespace), + $arguments, + $semicolon, + $newLine + ); + } + + /** + * @param string $object + * @param string|null $property + * + * @return string + */ + public function renderProperty($object, $property = null) + { + if (!empty($property)) { + $property = '.'.$property; + } + + return $object.$property; + } + + /** + * @param VariableAwareInterface $object + * @param string $method + * @param string[] $arguments + * @param bool $semicolon + * @param bool $newLine + * + * @return string + */ + public function renderObjectCall( + VariableAwareInterface $object, + $method, + array $arguments = [], + $semicolon = false, + $newLine = false + ) { + return $this->renderCall( + $this->renderProperty($object->getVariable(), $method), + $arguments, + $semicolon, + $newLine + ); + } + + /** + * @param string|null $method + * @param string[] $arguments + * @param bool $semicolon + * @param bool $newLine + * + * @return string + */ + public function renderCall($method, array $arguments = [], $semicolon = false, $newLine = false) + { + return $this->renderCode( + $method.$this->renderArguments($arguments), + $semicolon, + $newLine + ); + } + + /** + * @param string|null $code + * @param string[] $arguments + * @param string|null $name + * @param bool $semicolon + * @param bool $newLine + * + * @return string + */ + public function renderClosure( + $code = null, + array $arguments = [], + $name = null, + $semicolon = false, + $newLine = false + ) { + $separator = $this->renderSeparator(); + + if ($name !== null) { + $name = ' '.$name; + } + + return $this->renderCode($this->renderLines([ + 'function'.$name.$separator.$this->renderArguments($arguments).$separator.'{', + $this->renderIndentation($code), + '}', + ], !empty($code), $newLine && !$semicolon), $semicolon, $newLine && $semicolon); + } + + /** + * @param VariableAwareInterface $object + * @param string $declaration + * @param bool $semicolon + * @param bool $newLine + * + * @return string + */ + public function renderObjectAssignment( + VariableAwareInterface $object, + $declaration, + $semicolon = false, + $newLine = false + ) { + return $this->renderAssignment($object->getVariable(), $declaration, $semicolon, $newLine); + } + + /** + * @param VariableAwareInterface $root + * @param string $declaration + * @param string|null $propertyPath + * @param VariableAwareInterface|null $object + * @param bool $semicolon + * @param bool $newLine + * + * @return string + */ + public function renderContainerAssignment( + VariableAwareInterface $root, + $declaration, + $propertyPath = null, + VariableAwareInterface $object = null, + $semicolon = true, + $newLine = true + ) { + return $this->renderAssignment( + $this->renderContainerVariable($root, $propertyPath, $object), + $declaration, + $semicolon, + $newLine + ); + } + + /** + * @param VariableAwareInterface $root + * @param string|null $propertyPath + * @param VariableAwareInterface|null $object + * + * @return string + */ + public function renderContainerVariable( + VariableAwareInterface $root, + $propertyPath = null, + VariableAwareInterface $object = null + ) { + $variable = $root->getVariable().'_container'; + + if ($propertyPath !== null) { + $variable = $this->renderProperty($variable, $propertyPath); + } + + if ($object !== null) { + $variable = $this->renderProperty($variable, $object->getVariable()); + } + + return $variable; + } + + /** + * @param string $variable + * @param string $declaration + * @param bool $semicolon + * @param bool $newLine + * + * @return string + */ + public function renderAssignment($variable, $declaration, $semicolon = false, $newLine = false) + { + $separator = $this->renderSeparator(); + + return $this->renderCode($variable.$separator.'='.$separator.$declaration, $semicolon, $newLine); + } + + /** + * @param string $statement + * @param string $code + * @param string|null $condition + * @param string|null $next + * @param bool $newLine + * + * @return string + */ + public function renderStatement($statement, $code, $condition = null, $next = null, $newLine = true) + { + $separator = $this->renderSeparator(); + $statement .= $separator; + + if (!empty($condition)) { + $statement .= $this->renderArguments([$condition]).$separator; + } + + if (!empty($next)) { + $next = $separator.$next; + } + + return $this->renderLines([ + $statement.'{', + $this->renderIndentation($code), + '}'.$next, + ], true, $newLine); + } + + /** + * @param string $code + * @param bool $semicolon + * @param bool $newLine + * + * @return string + */ + public function renderCode($code, $semicolon = true, $newLine = true) + { + if ($semicolon) { + $code .= ';'; + } + + return $this->renderLine($code, $newLine); + } + + /** + * @param string|null $code + * + * @return string + */ + public function renderIndentation($code = null) + { + if ($this->debug && !empty($code)) { + $indentation = str_repeat(' ', $this->indentationStep); + $code = $indentation.str_replace(PHP_EOL, PHP_EOL.$indentation, $code); + } + + return (string) $code; + } + + /** + * @param string[] $codes + * @param bool $newLine + * @param bool $eolLine + * + * @return string + */ + public function renderLines(array $codes, $newLine = true, $eolLine = true) + { + $result = ''; + + foreach ($codes as $code) { + $result .= $this->renderLine($code, $newLine); + } + + if (empty($result)) { + return $result; + } + + if (!$newLine) { + $result = $this->renderLine($result, $eolLine); + } elseif (!$eolLine) { + $result = substr($result, 0, $position = strrpos($result, PHP_EOL)).substr($result, ++$position); + } + + return $result; + } + + /** + * @param string|null $code + * @param bool $newLine + * + * @return string + */ + public function renderLine($code = null, $newLine = true) + { + if ($newLine && !empty($code) && $this->debug) { + $code = str_repeat(' ', $this->defaultIndentation).$code.PHP_EOL; + } + + return (string) $code; + } + + /** + * @param string $argument + * + * @return string + */ + public function renderEscape($argument) + { + return json_encode($argument, JSON_UNESCAPED_SLASHES); + } + + /** + * @return string + */ + public function renderSeparator() + { + return $this->debug ? ' ' : ''; + } + + /** + * @param string[] $arguments + * + * @return string + */ + private function renderArguments(array $arguments) + { + return '('.implode(','.$this->renderSeparator(), $arguments).')'; + } +} diff --git a/src/Helper/Geometry/EncodingHelper.php b/src/Helper/Geometry/EncodingHelper.php deleted file mode 100644 index 5a02f2ef..00000000 --- a/src/Helper/Geometry/EncodingHelper.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Geometry; - -use Ivory\GoogleMap\Exception\HelperException; - -/** - * Encoding helper. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#encoding - * @author GeLo - */ -class EncodingHelper -{ - /** - * Renders the decode path method. - * - * @param string $encodedPath The encoded path. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If the encoded path is not valid. - * - * @return string The JS output. - */ - public function renderDecodePath($encodedPath) - { - if (!is_string($encodedPath)) { - throw HelperException::invalidEncodedPath(); - } - - return sprintf('google.maps.geometry.encoding.decodePath("%s")', addslashes($encodedPath)); - } -} diff --git a/src/Helper/Layers/KMLLayerHelper.php b/src/Helper/Layers/KMLLayerHelper.php deleted file mode 100644 index cb6d0cfd..00000000 --- a/src/Helper/Layers/KMLLayerHelper.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Layers; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Layers\KMLLayer; -use Ivory\GoogleMap\Map; - -/** - * KML Layer helper. - * - * @author GeLo - */ -class KMLLayerHelper extends AbstractHelper -{ - /** - * Renders a kml layer. - * - * @param \Ivory\GoogleMap\Layers\KMLLayer $kmlLayer The KML layer. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function render(KMLLayer $kmlLayer, Map $map) - { - $this->jsonBuilder - ->reset() - ->setValue('[map]', $map->getJavascriptVariable(), false) - ->setValues($kmlLayer->getOptions()); - - return sprintf( - '%s = new google.maps.KmlLayer("%s", %s);'.PHP_EOL, - $kmlLayer->getJavascriptVariable(), - $kmlLayer->getUrl(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/MapHelper.php b/src/Helper/MapHelper.php index abf12d98..d0e409e8 100644 --- a/src/Helper/MapHelper.php +++ b/src/Helper/MapHelper.php @@ -11,1927 +11,65 @@ namespace Ivory\GoogleMap\Helper; -use Ivory\GoogleMap\Exception\HelperException; -use Ivory\GoogleMap\Helper\Base\BoundHelper; -use Ivory\GoogleMap\Helper\Base\CoordinateHelper; -use Ivory\GoogleMap\Helper\Base\PointHelper; -use Ivory\GoogleMap\Helper\Base\SizeHelper; -use Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper; -use Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper; -use Ivory\GoogleMap\Helper\Controls\PanControlHelper; -use Ivory\GoogleMap\Helper\Controls\RotateControlHelper; -use Ivory\GoogleMap\Helper\Controls\ScaleControlHelper; -use Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper; -use Ivory\GoogleMap\Helper\Controls\ZoomControlHelper; -use Ivory\GoogleMap\Helper\Events\EventManagerHelper; -use Ivory\GoogleMap\Helper\Extension\CoreExtensionHelper; -use Ivory\GoogleMap\Helper\Extension\ExtensionHelperInterface; -use Ivory\GoogleMap\Helper\Layers\KMLLayerHelper; -use Ivory\GoogleMap\Helper\MapTypeIdHelper; -use Ivory\GoogleMap\Helper\Overlays\CircleHelper; -use Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper; -use Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper; -use Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper; -use Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper; -use Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface; -use Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper; -use Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper; -use Ivory\GoogleMap\Helper\Overlays\PolygonHelper; -use Ivory\GoogleMap\Helper\Overlays\PolylineHelper; -use Ivory\GoogleMap\Helper\Overlays\RectangleHelper; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; use Ivory\GoogleMap\Map; /** - * Map helper. - * * @author GeLo */ class MapHelper extends AbstractHelper { - /** @var \Ivory\GoogleMap\Helper\Base\CoordinateHelper */ - protected $coordinateHelper; - - /** @var \Ivory\GoogleMap\Helper\Base\BoundHelper */ - protected $boundHelper; - - /** @var \Ivory\GoogleMap\Helper\Base\PointHelper */ - protected $pointHelper; - - /** @var \Ivory\GoogleMap\Helper\Base\SizeHelper */ - protected $sizeHelper; - - /** @var \Ivory\GoogleMap\Helper\MapTypeIdHelper */ - protected $mapTypeIdHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper */ - protected $mapTypeControlHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper */ - protected $overviewMapControlHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\PanControlHelper */ - protected $panControlHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\RotateControlHelper */ - protected $rotateControlHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\ScaleControlHelper */ - protected $scaleControlHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper */ - protected $streetViewControlHelper; - - /** @var \Ivory\GoogleMap\Helper\Controls\ZoomControlHelper */ - protected $zoomControlHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface */ - protected $markerClusterHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper */ - protected $markerImageHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper */ - protected $markerShapeHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper */ - protected $infoWindowHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\PolylineHelper */ - protected $polylineHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper */ - protected $encodedPolylineHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\PolygonHelper */ - protected $polygonHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\RectangleHelper */ - protected $rectangleHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\CircleHelper */ - protected $circleHelper; - - /** @var \Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper */ - protected $groundOverlayHelper; - - /** @var \Ivory\GoogleMap\Helper\Layers\KMLLayerHelper */ - protected $kmlLayerHelper; - - /** @var \Ivory\GoogleMap\Helper\Events\EventManagerHelper */ - protected $eventManagerHelper; - - /** @var array */ - protected $extensionHelpers; - - /** - * Creates a map helper. - * - * @param \Ivory\GoogleMap\Helper\Base\CoordinateHelper $coordinateHelper The coordinate helper. - * @param \Ivory\GoogleMap\Helper\Base\BoundHelper $boundHelper The bound helper. - * @param \Ivory\GoogleMap\Helper\Base\PointHelper $pointHelper The point helper. - * @param \Ivory\GoogleMap\Helper\Base\SizeHelper $sizeHelper The size helper. - * @param \Ivory\GoogleMap\Helper\MapTypeIdHelper $mapTypeIdHelper The map type id helper. - * @param \Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper $mapTypeControlHelper The map type control helper. - * @param \Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper $overviewMapControlHelper The overview map control helper. - * @param \Ivory\GoogleMap\Helper\Controls\PanControlHelper $panControlHelper The pan control helper. - * @param \Ivory\GoogleMap\Helper\Controls\RotateControlHelper $rotateControlHelper The rotate control helper. - * @param \Ivory\GoogleMap\Helper\Controls\ScaleControlHelper $scaleControlHelper The scale control helper. - * @param \Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper $streetViewControlHelper The street view control helper. - * @param \Ivory\GoogleMap\Helper\Controls\ZoomControlHelper $zoomControlHelper The zoom control helper. - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerClusterHelperInterface $markerClusterHelper The marker cluster helper. - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper $markerImageHelper The marker image helper. - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper $markerShapeHelper The marker shape helper. - * @param \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper $infoWindowHelper The info window helper. - * @param \Ivory\GoogleMap\Helper\Overlays\PolylineHelper $polylineHelper The polyline helper. - * @param \Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper $encodedPolylineHelper The encoded polyline helper. - * @param \Ivory\GoogleMap\Helper\Overlays\PolygonHelper $polygonHelper The polygon helper. - * @param \Ivory\GoogleMap\Helper\Overlays\RectangleHelper $rectangleHelper The rectangle helper. - * @param \Ivory\GoogleMap\Helper\Overlays\CircleHelper $circleHelper The circle helper. - * @param \Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper $groundOverlayHelper The ground overlay helper. - * @param \Ivory\GoogleMap\Helper\Layers\KMLLayerHelper $kmlLayerHelper The KML layer helper. - * @param \Ivory\GoogleMap\Helper\Events\EventManagerHelper $eventManagerHelper The event manager helper. - * @param array $extensionHelpers The extension helpers. - */ - public function __construct( - CoordinateHelper $coordinateHelper = null, - BoundHelper $boundHelper = null, - PointHelper $pointHelper = null, - SizeHelper $sizeHelper = null, - MapTypeIdHelper $mapTypeIdHelper = null, - MapTypeControlHelper $mapTypeControlHelper = null, - OverviewMapControlHelper $overviewMapControlHelper = null, - PanControlHelper $panControlHelper = null, - RotateControlHelper $rotateControlHelper = null, - ScaleControlHelper $scaleControlHelper = null, - StreetViewControlHelper $streetViewControlHelper = null, - ZoomControlHelper $zoomControlHelper = null, - MarkerClusterHelperInterface $markerClusterHelper = null, - MarkerImageHelper $markerImageHelper = null, - MarkerShapeHelper $markerShapeHelper = null, - InfoWindowHelper $infoWindowHelper = null, - PolylineHelper $polylineHelper = null, - EncodedPolylineHelper $encodedPolylineHelper = null, - PolygonHelper $polygonHelper = null, - RectangleHelper $rectangleHelper = null, - CircleHelper $circleHelper = null, - GroundOverlayHelper $groundOverlayHelper = null, - KMLLayerHelper $kmlLayerHelper = null, - EventManagerHelper $eventManagerHelper = null, - array $extensionHelpers = array() - ) { - parent::__construct(); - - if ($coordinateHelper === null) { - $coordinateHelper = new CoordinateHelper(); - } - - if ($boundHelper === null) { - $boundHelper = new BoundHelper(); - } - - if ($pointHelper === null) { - $pointHelper = new PointHelper(); - } - - if ($sizeHelper === null) { - $sizeHelper = new SizeHelper(); - } - - if ($mapTypeIdHelper === null) { - $mapTypeIdHelper = new MapTypeIdHelper(); - } - - if ($mapTypeControlHelper === null) { - $mapTypeControlHelper = new MapTypeControlHelper(); - } - - if ($overviewMapControlHelper === null) { - $overviewMapControlHelper = new OverviewMapControlHelper(); - } - - if ($panControlHelper === null) { - $panControlHelper = new PanControlHelper(); - } - - if ($rotateControlHelper === null) { - $rotateControlHelper = new RotateControlHelper(); - } - - if ($scaleControlHelper === null) { - $scaleControlHelper = new ScaleControlHelper(); - } - - if ($streetViewControlHelper === null) { - $streetViewControlHelper = new StreetViewControlHelper(); - } - - if ($zoomControlHelper === null) { - $zoomControlHelper = new ZoomControlHelper(); - } - - if ($markerClusterHelper === null) { - $markerClusterHelper = new MarkerClusterHelper(); - } - - if ($markerImageHelper === null) { - $markerImageHelper = new MarkerImageHelper(); - } - - if ($markerShapeHelper === null) { - $markerShapeHelper = new MarkerShapeHelper(); - } - - if ($infoWindowHelper === null) { - $infoWindowHelper = new InfoWindowHelper(); - } - - if ($polylineHelper === null) { - $polylineHelper = new PolylineHelper(); - } - - if ($encodedPolylineHelper === null) { - $encodedPolylineHelper = new EncodedPolylineHelper(); - } - - if ($polygonHelper === null) { - $polygonHelper = new PolygonHelper(); - } - - if ($rectangleHelper === null) { - $rectangleHelper = new RectangleHelper(); - } - - if ($circleHelper === null) { - $circleHelper = new CircleHelper(); - } - - if ($groundOverlayHelper === null) { - $groundOverlayHelper = new GroundOverlayHelper(); - } - - if ($kmlLayerHelper === null) { - $kmlLayerHelper = new KMLLayerHelper(); - } - - if ($eventManagerHelper === null) { - $eventManagerHelper = new EventManagerHelper(); - } - - if (empty($extensionHelpers)) { - $extensionHelpers['core'] = new CoreExtensionHelper(); - } - - $this->setCoordinateHelper($coordinateHelper); - $this->setBoundHelper($boundHelper); - $this->setPointHelper($pointHelper); - $this->setSizeHelper($sizeHelper); - - $this->setMapTypeIdHelper($mapTypeIdHelper); - $this->setMapTypeControlHelper($mapTypeControlHelper); - $this->setOverviewMapControlHelper($overviewMapControlHelper); - $this->setPanControlHelper($panControlHelper); - $this->setRotateControlHelper($rotateControlHelper); - $this->setScaleControlHelper($scaleControlHelper); - $this->setStreetViewControlHelper($streetViewControlHelper); - $this->setZoomControlHelper($zoomControlHelper); - - $this->setMarkerClusterHelper($markerClusterHelper); - $this->setMarkerImageHelper($markerImageHelper); - $this->setMarkerShapeHelper($markerShapeHelper); - $this->setInfoWindowHelper($infoWindowHelper); - $this->setPolylineHelper($polylineHelper); - $this->setEncodedPolylineHelper($encodedPolylineHelper); - $this->setPolygonHelper($polygonHelper); - $this->setRectangleHelper($rectangleHelper); - $this->setCircleHelper($circleHelper); - $this->setGroundOverlayHelper($groundOverlayHelper); - - $this->setKmlLayerHelper($kmlLayerHelper); - - $this->setEventManagerHelper($eventManagerHelper); - - $this->setExtensionHelpers($extensionHelpers); - } - - /** - * Gets the coordinate helper. - * - * @return \Ivory\GoogleMap\Helper\Base\CoordinateHelper The coordinate helper. - */ - public function getCoordinateHelper() - { - return $this->coordinateHelper; - } - - /** - * Sets the coordinate helper. - * - * @param \Ivory\GoogleMap\Helper\Base\CoordinateHelper $coordinateHelper The coordinate helper. - */ - public function setCoordinateHelper(CoordinateHelper $coordinateHelper) - { - $this->coordinateHelper = $coordinateHelper; - } - - /** - * Gets the bound helper. - * - * @return \Ivory\GoogleMap\Helper\Base\BoundHelper The bound helper. - */ - public function getBoundHelper() - { - return $this->boundHelper; - } - - /** - * Sets the bound helper. - * - * @param \Ivory\GoogleMap\Helper\Base\BoundHelper $boundHelper The bound helper. - */ - public function setBoundHelper(BoundHelper $boundHelper) - { - $this->boundHelper = $boundHelper; - } - - /** - * Gets the point helper. - * - * @return \Ivory\GoogleMap\Helper\Base\PointHelper The point helper. - */ - public function getPointHelper() - { - return $this->pointHelper; - } - - /** - * Sets the point helper. - * - * @param \Ivory\GoogleMap\Helper\Base\PointHelper $pointHelper The point helper. - */ - public function setPointHelper(PointHelper $pointHelper) - { - $this->pointHelper = $pointHelper; - } - - /** - * Gets the size helper. - * - * @return \Ivory\GoogleMap\Helper\Base\SizeHelper The size helper. - */ - public function getSizeHelper() - { - return $this->sizeHelper; - } - - /** - * Sets the size helper. - * - * @param \Ivory\GoogleMap\Helper\Base\SizeHelper $sizeHelper The size helper. - */ - public function setSizeHelper(SizeHelper $sizeHelper) - { - $this->sizeHelper = $sizeHelper; - } - - /** - * Gets the map type id helper. - * - * @return \Ivory\GoogleMap\Helper\MapTypeIdHelper The map type id helper. - */ - public function getMapTypeIdHelper() - { - return $this->mapTypeIdHelper; - } - - /** - * Sets the map type id helper. - * - * @param \Ivory\GoogleMap\Helper\MapTypeIdHelper $mapTypeIdHelper The map type id helper. - */ - public function setMapTypeIdHelper(MapTypeIdHelper $mapTypeIdHelper) - { - $this->mapTypeIdHelper = $mapTypeIdHelper; - } - - /** - * Gets the map type control helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper The map type control helper. - */ - public function getMapTypeControlHelper() - { - return $this->mapTypeControlHelper; - } - /** - * Sets the map type control helper. + * @param Map $map * - * @param \Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper $mapTypeControlHelper The map type control helper. + * @return string */ - public function setMapTypeControlHelper(MapTypeControlHelper $mapTypeControlHelper) - { - $this->mapTypeControlHelper = $mapTypeControlHelper; - } - - /** - * Gets the overview map control helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper The overview map control helper. - */ - public function getOverviewMapControlHelper() - { - return $this->overviewMapControlHelper; - } - - /** - * Sets the overview map control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper $overviewMapControlHelper The overview map - * control helper. - */ - public function setOverviewMapControlHelper(OverviewMapControlHelper $overviewMapControlHelper) - { - $this->overviewMapControlHelper = $overviewMapControlHelper; - } - - /** - * Gets the pan control helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\PanControlHelper The pan control helper. - */ - public function getPanControlHelper() - { - return $this->panControlHelper; - } - - /** - * Sets the pan control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\PanControlHelper $panControlHelper The pan control helper. - */ - public function setPanControlHelper(PanControlHelper $panControlHelper) - { - $this->panControlHelper = $panControlHelper; - } - - /** - * Gets the rotate control helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\RotateControlHelper The rotate control helper. - */ - public function getRotateControlHelper() - { - return $this->rotateControlHelper; - } - - /** - * Sets the rotate control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\RotateControlHelper $rotateControlHelper The rotate control helper. - */ - public function setRotateControlHelper(RotateControlHelper $rotateControlHelper) - { - $this->rotateControlHelper = $rotateControlHelper; - } - - /** - * Gets the scale control helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ScaleControlHelper The scale control helper. - */ - public function getScaleControlHelper() - { - return $this->scaleControlHelper; - } - - /** - * Sets the scale control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ScaleControlHelper $scaleControlHelper The scale control helper. - */ - public function setScaleControlHelper(ScaleControlHelper $scaleControlHelper) - { - $this->scaleControlHelper = $scaleControlHelper; - } - - /** - * Gets the street view control helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper The street view control helper. - */ - public function getStreetViewControlHelper() - { - return $this->streetViewControlHelper; - } - - /** - * Sets the street view control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper $streetViewControlHelper The street view control - * helper. - */ - public function setStreetViewControlHelper(StreetViewControlHelper $streetViewControlHelper) - { - $this->streetViewControlHelper = $streetViewControlHelper; - } - - /** - * Gets the zoom control helper. - * - * @return \Ivory\GoogleMap\Helper\Controls\ZoomControlHelper The zoom control helper. - */ - public function getZoomControlHelper() - { - return $this->zoomControlHelper; - } - - /** - * Sets the zoom control helper. - * - * @param \Ivory\GoogleMap\Helper\Controls\ZoomControlHelper $zoomControlHelper The zoom control helper. - */ - public function setZoomControlHelper(ZoomControlHelper $zoomControlHelper) - { - $this->zoomControlHelper = $zoomControlHelper; - } - - /** - * Gets the marker cluster helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface The marker cluster helper. - */ - public function getMarkerClusterHelper() - { - return $this->markerClusterHelper; - } - - /** - * Sets the marker cluster helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface $markerClusterHelper The marker cluster helper. - */ - public function setMarkerClusterHelper(MarkerClusterHelperInterface $markerClusterHelper) - { - $this->markerClusterHelper = $markerClusterHelper; - } - - /** - * Gets the marker image helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper The marker image helper. - */ - public function getMarkerImageHelper() - { - return $this->markerImageHelper; - } - - /** - * Sets the marker image helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper $markerImageHelper The marker image helper. - */ - public function setMarkerImageHelper(MarkerImageHelper $markerImageHelper) - { - $this->markerImageHelper = $markerImageHelper; - } - - /** - * Gets the marker shape helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper The marker shape helper. - */ - public function getMarkerShapeHelper() - { - return $this->markerShapeHelper; - } - - /** - * Sets the marker shape helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper $markerShapeHelper The marker shape helper. - */ - public function setMarkerShapeHelper(MarkerShapeHelper $markerShapeHelper) - { - $this->markerShapeHelper = $markerShapeHelper; - } - - /** - * Gets the info window helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper The info window helper. - */ - public function getInfoWindowHelper() - { - return $this->infoWindowHelper; - } - - /** - * Sets the info window helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper $infoWindowHelper The info window helper. - */ - public function setInfoWindowHelper(InfoWindowHelper $infoWindowHelper) - { - $this->infoWindowHelper = $infoWindowHelper; - } - - /** - * Gets the polyline helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\PolylineHelper The polyline helper. - */ - public function getPolylineHelper() + public function render(Map $map) { - return $this->polylineHelper; + return $this->renderHtml($map).$this->renderStylesheet($map).$this->renderJavascript($map); } /** - * Sets the polyline helper. + * @param Map $map * - * @param \Ivory\GoogleMap\Helper\Overlays\PolylineHelper $polylineHelper The polyline helper. + * @return string */ - public function setPolylineHelper(PolylineHelper $polylineHelper) + public function renderHtml(Map $map) { - $this->polylineHelper = $polylineHelper; + return $this->doRender($map, MapEvents::HTML); } /** - * Gets the encoded polyline helper. + * @param Map $map * - * @return \Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper The encoded polyline helper. + * @return string */ - public function getEncodedPolylineHelper() + public function renderStylesheet(Map $map) { - return $this->encodedPolylineHelper; + return $this->doRender($map, MapEvents::STYLESHEET); } /** - * Sets the encoded polyline helper. + * @param Map $map * - * @param \Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper $encodedPolylineHelper The encoded polyline helper. + * @return string */ - public function setEncodedPolylineHelper(EncodedPolylineHelper $encodedPolylineHelper) + public function renderJavascript(Map $map) { - $this->encodedPolylineHelper = $encodedPolylineHelper; + return $this->doRender($map, MapEvents::JAVASCRIPT); } /** - * Gets the polygon helper. + * @param Map $map + * @param string $eventName * - * @return \Ivory\GoogleMap\Helper\Overlays\PolygonHelper The polygon helper. + * @return string */ - public function getPolygonHelper() + private function doRender(Map $map, $eventName) { - return $this->polygonHelper; - } - - /** - * Sets the polygon helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\PolygonHelper $polygonHelper The polygon helper. - */ - public function setPolygonHelper(PolygonHelper $polygonHelper) - { - $this->polygonHelper = $polygonHelper; - } - - /** - * Gets the rectangle helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\RectangleHelper The rectangle helper. - */ - public function getRectangleHelper() - { - return $this->rectangleHelper; - } - - /** - * Sets the rectangle helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\RectangleHelper $rectangleHelper The rectangle helper. - */ - public function setRectangleHelper(RectangleHelper $rectangleHelper) - { - $this->rectangleHelper = $rectangleHelper; - } - - /** - * Gets the circle helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\CircleHelper The circle helper. - */ - public function getCircleHelper() - { - return $this->circleHelper; - } - - /** - * Sets the circle helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\CircleHelper $circleHelper The circle helper. - */ - public function setCircleHelper(CircleHelper $circleHelper) - { - $this->circleHelper = $circleHelper; - } - - /** - * Gets the ground overlay helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper The ground overlay helper. - */ - public function getGroundOverlayHelper() - { - return $this->groundOverlayHelper; - } - - /** - * Sets the ground overlay helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper $groundOverlayHelper The ground overlay helper. - */ - public function setGroundOverlayHelper(GroundOverlayHelper $groundOverlayHelper) - { - $this->groundOverlayHelper = $groundOverlayHelper; - } - - /** - * Gets the KML layer helper. - * - * @return \Ivory\GoogleMap\Helper\Layers\KMLLayerHelper The KML layer helper. - */ - public function getKmlLayerHelper() - { - return $this->kmlLayerHelper; - } - - /** - * Sets the KML layer helper. - * - * @param \Ivory\GoogleMap\Helper\Layers\KMLLayerHelper $kmlLayerHelper The KML layer helper. - */ - public function setKmlLayerHelper(KMLLayerHelper $kmlLayerHelper) - { - $this->kmlLayerHelper = $kmlLayerHelper; - } - - /** - * Gets the event manager helper. - * - * @return \Ivory\GoogleMap\Helper\Events\EventManagerHelper The event manager helper. - */ - public function getEventManagerHelper() - { - return $this->eventManagerHelper; - } - - /** - * Sets the event manager helper. - * - * @param \Ivory\GoogleMap\Helper\Events\EventManagerHelper $eventManagerHelper The event manager helper. - */ - public function setEventManagerHelper(EventManagerHelper $eventManagerHelper) - { - $this->eventManagerHelper = $eventManagerHelper; - } - - /** - * Checks if the map helper has extensions. - * - * @return boolean TRUE if the map helper has extensions else FALSE. - */ - public function hasExtensionHelpers() - { - return !empty($this->extensionHelpers); - } - - /** - * Gets the map extension helpers. - * - * @return array The map extension helpers. - */ - public function getExtensionHelpers() - { - return $this->extensionHelpers; - } - - /** - * Sets the map extension helpers. - * - * @param array $extensionHelpers The map extension helpers. - */ - public function setExtensionHelpers(array $extensionHelpers) - { - $this->extensionHelpers = array(); - - foreach ($extensionHelpers as $name => $extensionHelper) { - $this->setExtensionHelper($name, $extensionHelper); - } - } - - /** - * Checks if the map helper has a specific extension helper. - * - * @param string $name The extension helper name. - * - * @return boolean TRUE if the map helper has a specific extension helper else FALSE. - */ - public function hasExtensionHelper($name) - { - return isset($this->extensionHelpers[$name]); - } - - /** - * Gets a specific extension helper. - * - * @param string $name The extension helper name. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If the extension helper does not exist. - * - * @return \Ivory\GoogleMap\Helper\Extension\ExtensionHelperInterface The extension helper. - */ - public function getExtensionHelper($name) - { - if (!$this->hasExtensionHelper($name)) { - throw HelperException::invalidExtension($name); - } - - return $this->extensionHelpers[$name]; - } - - /** - * Sets an extension helper. - * - * @param string $name The extension helper name. - * @param \Ivory\GoogleMap\Helper\Extension\ExtensionHelperInterface $extensionHelper The extension helper. - */ - public function setExtensionHelper($name, ExtensionHelperInterface $extensionHelper) - { - $this->extensionHelpers[$name] = $extensionHelper; - } - - /** - * Removes an extension helper. - * - * @param string $name The extension helper name. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If the extension helper does not exist. - */ - public function removeExtensionHelper($name) - { - if (!$this->hasExtensionHelper($name)) { - throw HelperException::invalidExtension($name); - } - - unset($this->extensionHelpers[$name]); - } - - /** - * Renders the html (container & stylesheets). - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The HTML output. - */ - public function render(Map $map) - { - return implode('', array( - $this->renderHtmlContainer($map), - $this->renderStylesheets($map), - $this->renderJavascripts($map) - )); - } - - /** - * Renders the map container. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The HTML output. - */ - public function renderHtmlContainer(Map $map) - { - return sprintf( - '
'.PHP_EOL, - $map->getHtmlContainerId(), - $map->getStylesheetOption('width'), - $map->getStylesheetOption('height') - ); - } - - /** - * Renders the html map stylesheets. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The HTML output. - */ - public function renderStylesheets(Map $map) - { - $html = array(); - - $html[] = ''.PHP_EOL; - - return implode('', $html); - } - - /** - * Renders the map javascripts. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The HTML output. - */ - public function renderJavascripts(Map $map) - { - $output = array(); - - if (!$map->isAsync()) { - $output[] = $this->renderJsLibraries($map); - } - - $output[] = ''.PHP_EOL; - - if ($map->isAsync()) { - $output[] = $this->renderJsLibraries($map); - } - - return implode('', $output); - } - - /** - * Renders the javascript libraries. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The HTML output. - */ - public function renderJsLibraries(Map $map) - { - $output = array(); - - foreach ($this->getExtensionHelpers() as $extension) { - $output[] = $extension->renderLibraries($map); - } - - return implode('', $output); - } - - /** - * Renders JS code just before the generated one. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsBefore(Map $map) - { - $output = array(); - - foreach ($this->getExtensionHelpers() as $extension) { - $output[] = $extension->renderBefore($map); - } - - return implode('', $output); - } - - /** - * Renders JS code just after the generated one. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsAfter(Map $map) - { - $output = array(); - - foreach (array_reverse($this->getExtensionHelpers()) as $extension) { - $output[] = $extension->renderAfter($map); - } - - return implode('', $output); - } - - /** - * Renders the javascript container. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainer(Map $map) - { - $output = array(); - - $output[] = $this->renderJsContainerInit($map); - - $output[] = $this->renderJsContainerCoordinates($map); - $output[] = $this->renderJsContainerBounds($map); - $output[] = $this->renderJsContainerPoints($map); - $output[] = $this->renderJsContainerSizes($map); - - $output[] = $this->renderJsContainerMap($map); - - $output[] = $this->renderJsContainerCircles($map); - $output[] = $this->renderJsContainerEncodedPolylines($map); - $output[] = $this->renderJsContainerGroundOverlays($map); - $output[] = $this->renderJsContainerPolygons($map); - $output[] = $this->renderJsContainerPolylines($map); - $output[] = $this->renderJsContainerRectangles($map); - $output[] = $this->renderJsContainerInfoWindows($map); - $output[] = $this->renderJsContainerMarkerImages($map); - $output[] = $this->renderJsContainerMarkerShapes($map); - $output[] = $this->renderJsContainerMarkerCluster($map); - - $output[] = $this->renderJsContainerKMLLayers($map); - - $output[] = $this->renderJsContainerEventManager($map); - - $output[] = $this->renderJsContainerExtra($map); - - return implode('', $output); - } - - /** - * Renders the javascript container initialization (empty container). - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerInit(Map $map) - { - $this->jsonBuilder - ->reset() - ->setJsonEncodeOptions(JSON_FORCE_OBJECT) - // Map - ->setValue('[map]', null) - // Base - ->setValue('[coordinates]', array()) - ->setValue('[bounds]', array()) - ->setValue('[points]', array()) - ->setValue('[sizes]', array()) - // Overlays - ->setValue('[circles]', array()) - ->setValue('[encoded_polylines]', array()) - ->setValue('[ground_overlays]', array()) - ->setValue('[polygons]', array()) - ->setValue('[polylines]', array()) - ->setValue('[rectangles]', array()) - ->setValue('[info_windows]', array()) - ->setValue('[marker_images]', array()) - ->setValue('[marker_shapes]', array()) - ->setValue('[markers]', array()) - ->setValue('[marker_cluster]', null) - // Layers - ->setValue('[kml_layers]', array()) - // Event Manager - ->setValue('[event_manager][dom_events]', array()) - ->setValue('[event_manager][dom_events_once]', array()) - ->setValue('[event_manager][events]', array()) - ->setValue('[event_manager][events_once]', array()) - // Internal - ->setValue('[closable_info_windows]', array()) - ->setValue( - '[functions][to_array]', - 'function (object) { var array = []; for (var key in object) { array.push(object[key]); } return array; }', - false - ); - - return sprintf('%s = %s;'.PHP_EOL, $this->getJsContainerName($map), $this->jsonBuilder->build()); - } - - /** - * Renders the javascript container coordinates. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerCoordinates(Map $map) - { - $output = array(); - - foreach ($this->computeCoordinates($map) as $coordinate) { - $output[] = sprintf( - '%s.coordinates.%s = %s', - $this->getJsContainerName($map), - $coordinate->getJavascriptVariable(), - $this->coordinateHelper->render($coordinate) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container bounds. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerBounds(Map $map) - { - $output = array(); - - foreach ($this->computeBounds($map) as $bound) { - $output[] = sprintf( - '%s.bounds.%s = %s', - $this->getJsContainerName($map), - $bound->getJavascriptVariable(), - $this->boundHelper->render($bound) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container points. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerPoints(Map $map) - { - $output = array(); - - foreach ($this->computePoints($map) as $point) { - $output[] = sprintf( - '%s.points.%s = %s', - $this->getJsContainerName($map), - $point->getJavascriptVariable(), - $this->pointHelper->render($point) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container sizes. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerSizes(Map $map) - { - $output = array(); - - foreach ($this->computeSizes($map) as $size) { - $output[] = sprintf( - '%s.sizes.%s = %s', - $this->getJsContainerName($map), - $size->getJavascriptVariable(), - $this->sizeHelper->render($size) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerMap(Map $map) - { - return sprintf('%s.map = %s', $this->getJsContainerName($map), $this->renderMap($map)); - } - - /** - * Renders the javascript container circles. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerCircles(Map $map) - { - $output = array(); - - foreach ($map->getCircles() as $circle) { - $output[] = sprintf( - '%s.circles.%s = %s', - $this->getJsContainerName($map), - $circle->getJavascriptVariable(), - $this->circleHelper->render($circle, $map) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container encoded polylines. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerEncodedPolylines(Map $map) - { - $output = array(); - - foreach ($map->getEncodedPolylines() as $encodedPolyline) { - $output[] = sprintf( - '%s.encoded_polylines.%s = %s', - $this->getJsContainerName($map), - $encodedPolyline->getJavascriptVariable(), - $this->encodedPolylineHelper->render($encodedPolyline, $map) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container ground overlays. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerGroundOverlays(Map $map) - { - $output = array(); - - foreach ($map->getGroundOverlays() as $groundOverlay) { - $output[] = sprintf( - '%s.ground_overlays.%s = %s', - $this->getJsContainerName($map), - $groundOverlay->getJavascriptVariable(), - $this->groundOverlayHelper->render($groundOverlay, $map) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container polygons. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerPolygons(Map $map) - { - $output = array(); - - foreach ($map->getPolygons() as $polygon) { - $output[] = sprintf( - '%s.polygons.%s = %s', - $this->getJsContainerName($map), - $polygon->getJavascriptVariable(), - $this->polygonHelper->render($polygon, $map) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container polylines. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerPolylines(Map $map) - { - $output = array(); - - foreach ($map->getPolylines() as $polyline) { - $output[] = sprintf( - '%s.polylines.%s = %s', - $this->getJsContainerName($map), - $polyline->getJavascriptVariable(), - $this->polylineHelper->render($polyline, $map) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container rectangles. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerRectangles(Map $map) - { - $output = array(); - - foreach ($map->getRectangles() as $rectangle) { - $output[] = sprintf( - '%s.rectangles.%s = %s', - $this->getJsContainerName($map), - $rectangle->getJavascriptVariable(), - $this->rectangleHelper->render($rectangle, $map) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container info windows. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerInfoWindows(Map $map) - { - $output = array(); - - $mapInfoWindows = $map->getInfoWindows(); - $markerInfoWindows = $this->computeMarkerInfoWindows($map); - - foreach ($mapInfoWindows as $mapInfoWindow) { - $output[] = sprintf( - '%s.info_windows.%s = %s', - $this->getJsContainerName($map), - $mapInfoWindow->getJavascriptVariable(), - $this->infoWindowHelper->render($mapInfoWindow) - ); - } - - foreach ($markerInfoWindows as $markerInfoWindow) { - $output[] = sprintf( - '%s.info_windows.%s = %s', - $this->getJsContainerName($map), - $markerInfoWindow->getJavascriptVariable(), - $this->infoWindowHelper->render($markerInfoWindow, false) - ); - } - - foreach (array_merge($mapInfoWindows, $markerInfoWindows) as $infoWindow) { - if ($infoWindow->isAutoClose()) { - $output[] = sprintf( - '%s.closable_info_windows.%s = %s;'.PHP_EOL, - $this->getJsContainerName($map), - $infoWindow->getJavascriptVariable(), - $infoWindow->getJavascriptVariable() - ); - } - } - - return implode('', $output); - } - - /** - * Renders the javascript container maker images. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerMarkerImages(Map $map) - { - $output = array(); - - foreach ($this->computeMarkerImages($map) as $markerImage) { - $output[] = sprintf( - '%s.marker_images.%s = %s', - $this->getJsContainerName($map), - $markerImage->getJavascriptVariable(), - $this->markerImageHelper->render($markerImage) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container marker shapes. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerMarkerShapes(Map $map) - { - $output = array(); - - foreach ($this->computeMarkerShapes($map) as $markerShape) { - $output[] = sprintf( - '%s.marker_shapes.%s = %s', - $this->getJsContainerName($map), - $markerShape->getJavascriptVariable(), - $this->markerShapeHelper->render($markerShape) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container marker cluster. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerMarkerCluster(Map $map) - { - $output = array( - $this->markerClusterHelper->renderMarkers($map->getMarkerCluster(), $map), - $this->markerClusterHelper->render($map->getMarkerCluster(), $map), - ); - - return implode('', $output); - } - - /** - * Renders the javascript container KML layer. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerKMLLayers(Map $map) - { - $output = array(); - - foreach ($map->getKMLLayers() as $kmlLayer) { - $output[] = sprintf( - '%s.kml_layers.%s = %s', - $this->getJsContainerName($map), - $kmlLayer->getJavascriptVariable(), - $this->kmlLayerHelper->render($kmlLayer, $map) - ); - } - - return implode('', $output); - } - - /** - * Renders the javascript container event manager. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerEventManager(Map $map) - { - $output = array(); - - foreach ($map->getEventManager()->getDomEvents() as $domEvent) { - $output[] = sprintf( - '%s.event_manager.dom_events.%s = %s', - $this->getJsContainerName($map), - $domEvent->getJavascriptVariable(), - $this->eventManagerHelper->renderDomEvent($domEvent) - ); - } - - foreach ($map->getEventManager()->getDomEventsOnce() as $domEventOnce) { - $output[] = sprintf( - '%s.event_manager.dom_events_once.%s = %s', - $this->getJsContainerName($map), - $domEventOnce->getJavascriptVariable(), - $this->eventManagerHelper->renderDomEventOnce($domEventOnce) - ); - } - - foreach ($map->getEventManager()->getEvents() as $event) { - $output[] = sprintf( - '%s.event_manager.events.%s = %s', - $this->getJsContainerName($map), - $event->getJavascriptVariable(), - $this->eventManagerHelper->renderEvent($event) - ); - } - - foreach ($map->getEventManager()->getEventsOnce() as $eventOnce) { - $output[] = sprintf( - '%s.event_manager.events_once.%s = %s', - $this->getJsContainerName($map), - $eventOnce->getJavascriptVariable(), - $this->eventManagerHelper->renderEventOnce($eventOnce) - ); - } - - return implode('', $output); - } - - /** - * Renders the js container extra. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderJsContainerExtra(Map $map) - { - $output = array(); - - foreach ($map->getInfoWindows() as $infoWindow) { - if ($infoWindow->isOpen()) { - $output[] = $this->infoWindowHelper->renderOpen($infoWindow, $map); - } - } - - foreach ($map->getMarkers() as $marker) { - if ($marker->hasInfoWindow() && $marker->getInfoWindow()->isOpen()) { - $output[] = $this->infoWindowHelper->renderOpen($marker->getInfoWindow(), $map, $marker); - } - } - - foreach ($this->computeBounds($map) as $bound) { - if ($bound->hasExtends()) { - $output[] = $this->boundHelper->renderExtends($bound); - } - } - - if ($map->isAutoZoom()) { - $output[] = $this->renderMapBound($map); - } else { - $output[] = $this->renderMapCenter($map); - } - - return implode('', $output); - } - - /** - * Renders the map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderMap(Map $map) - { - $mapTypeId = $map->getMapOption('mapTypeId'); - $map->removeMapOption('mapTypeId'); - - $this->jsonBuilder - ->reset() - ->setValue('[mapTypeId]', $this->mapTypeIdHelper->render($mapTypeId), false); - - $this->renderMapControls($map); - - if ($map->isAutoZoom()) { - $map->removeMapOption('zoom'); - } - - $this->jsonBuilder->setValues($map->getMapOptions()); - - return sprintf( - '%s = new google.maps.Map(document.getElementById("%s"), %s);'.PHP_EOL, - $map->getJavascriptVariable(), - $map->getHtmlContainerId(), - $this->jsonBuilder->build() - ); - } - - /** - * Renders the map center. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string Ths JS output. - */ - public function renderMapCenter(Map $map) - { - return sprintf( - '%s.setCenter(%s);'.PHP_EOL, - $map->getJavascriptVariable(), - $map->getCenter()->getJavascriptVariable() - ); - } - - /** - * Renders the map bound. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderMapBound(Map $map) - { - return sprintf( - '%s.fitBounds(%s);'.PHP_EOL, - $map->getJavascriptVariable(), - $map->getBound()->getJavascriptVariable() - ); - } - - /** - * Computes the coordinates of a map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return array The computed coordinated. - */ - protected function computeCoordinates(Map $map) - { - $coordinates = array(); - - if (!$map->isAutoZoom() && !in_array($map->getCenter(), $coordinates)) { - $coordinates[] = $map->getCenter(); - } - - foreach ($this->computeBounds($map) as $bound) { - if (!$bound->hasExtends() && $bound->hasCoordinates()) { - if (!in_array($bound->getSouthWest(), $coordinates)) { - $coordinates[] = $bound->getSouthWest(); - } - - if (!in_array($bound->getNorthEast(), $coordinates)) { - $coordinates[] = $bound->getNorthEast(); - } - } - } - - foreach ($map->getCircles() as $circle) { - if (!in_array($circle->getCenter(), $coordinates)) { - $coordinates[] = $circle->getCenter(); - } - } - - foreach ($map->getInfoWindows() as $infoWindow) { - if (!in_array($infoWindow->getPosition(), $coordinates)) { - $coordinates[] = $infoWindow->getPosition(); - } - } - - foreach ($map->getMarkers() as $marker) { - if (!in_array($marker->getPosition(), $coordinates)) { - $coordinates[] = $marker->getPosition(); - } - } - - foreach ($map->getPolygons() as $polygon) { - foreach ($polygon->getCoordinates() as $polygonCoordinate) { - if (!in_array($polygonCoordinate, $coordinates)) { - $coordinates[] = $polygonCoordinate; - } - } - } - - foreach ($map->getPolylines() as $polyline) { - foreach ($polyline->getCoordinates() as $polylineCoordinate) { - if (!in_array($polylineCoordinate, $coordinates)) { - $coordinates[] = $polylineCoordinate; - } - } - } - - return $coordinates; - } - - /** - * Computes the bounds of a map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return array The computed bounds. - */ - protected function computeBounds(Map $map) - { - $bounds = array(); - - if ($map->isAutoZoom() && !in_array($map->getBound(), $bounds)) { - $bounds[] = $map->getBound(); - } - - foreach ($map->getGroundOverlays() as $groundOverlay) { - if (!in_array($groundOverlay->getBound(), $bounds)) { - $bounds[] = $groundOverlay->getBound(); - } - } - - foreach ($map->getRectangles() as $rectangle) { - if (!in_array($rectangle->getBound(), $bounds)) { - $bounds[] = $rectangle->getBound(); - } - } - - return $bounds; - } - - /** - * Computes the points of a map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return array The computed points. - */ - protected function computePoints(Map $map) - { - $points = array(); - - foreach ($map->getMarkers() as $marker) { - if ($marker->hasIcon()) { - if ($marker->getIcon()->hasAnchor() && !in_array($marker->getIcon()->getAnchor(), $points)) { - $points[] = $marker->getIcon()->getAnchor(); - } - - if ($marker->getIcon()->hasOrigin() && !in_array($marker->getIcon()->getOrigin(), $points)) { - $points[] = $marker->getIcon()->getOrigin(); - } - } - - if ($marker->hasShadow()) { - if ($marker->getShadow()->hasAnchor() && !in_array($marker->getShadow()->getAnchor(), $points)) { - $points[] = $marker->getShadow()->getAnchor(); - } - - if ($marker->getShadow()->hasOrigin() && !in_array($marker->getShadow()->getOrigin(), $points)) { - $points[] = $marker->getShadow()->getOrigin(); - } - } - } - - return $points; - } - - /** - * Computes the sizes of a map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return array The computed sizes. - */ - protected function computeSizes(Map $map) - { - $sizes = array(); - - foreach (array_merge($map->getInfoWindows(), $this->computeMarkerInfoWindows($map)) as $infoWindow) { - if ($infoWindow->hasPixelOffset() && !in_array($infoWindow->getPixelOffset(), $sizes)) { - $sizes[] = $infoWindow->getPixelOffset(); - } - } - - foreach ($map->getMarkers() as $marker) { - if ($marker->hasIcon()) { - if ($marker->getIcon()->hasSize() && !in_array($marker->getIcon()->getSize(), $sizes)) { - $sizes[] = $marker->getIcon()->getSize(); - } - - if ($marker->getIcon()->hasScaledSize() && !in_array($marker->getIcon()->getScaledSize(), $sizes)) { - $sizes[] = $marker->getIcon()->getScaledSize(); - } - } - - if ($marker->hasShadow()) { - if ($marker->getShadow()->hasSize() && !in_array($marker->getShadow()->getSize(), $sizes)) { - $sizes[] = $marker->getShadow()->getSize(); - } - - if ($marker->getShadow()->hasScaledSize() && !in_array($marker->getShadow()->getScaledSize(), $sizes)) { - $sizes[] = $marker->getShadow()->getScaledSize(); - } - } - } - - return $sizes; - } - - /** - * Computes the marker images of a map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return array The computed marker images. - */ - protected function computeMarkerImages(Map $map) - { - $markerImages = array(); - - foreach ($map->getMarkers() as $marker) { - if ($marker->hasIcon() && !in_array($marker->getIcon(), $markerImages)) { - $markerImages[] = $marker->getIcon(); - } - - if ($marker->hasShadow() && !in_array($marker->getShadow(), $markerImages)) { - $markerImages[] = $marker->getShadow(); - } - } - - return $markerImages; - } - - /** - * Computes the marker shapes of a map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return array The computed marker shapes. - */ - protected function computeMarkerShapes(Map $map) - { - $markerShapes = array(); - - foreach ($map->getMarkers() as $marker) { - if ($marker->hasShape() && !in_array($marker->getShape(), $markerShapes)) { - $markerShapes[] = $marker->getShape(); - } - } - - return $markerShapes; - } - - /** - * Computes the marker info windows of a map. - * - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return array The computed marker info windows. - */ - protected function computeMarkerInfoWindows(Map $map) - { - $infoWinfows = array(); - - foreach ($map->getMarkers() as $marker) { - if ($marker->hasInfoWindow() && !in_array($marker->getInfoWindow(), $infoWinfows)) { - $infoWinfows[] = $marker->getInfoWindow(); - } - } - - return $infoWinfows; - } - - /** - * Renders the map controls in the json builder. - * - * @param \Ivory\GoogleMap\Map $map The map. - */ - protected function renderMapControls(Map $map) - { - $controlNames = array( - 'MapTypeControl', - 'OverviewMapControl', - 'PanControl', - 'RotateControl', - 'ScaleControl', - 'StreetViewControl', - 'ZoomControl', - ); - - foreach ($controlNames as $controlName) { - $controlHelper = lcfirst($controlName).'Helper'; - $this->renderMapControl($map, $controlName, $this->$controlHelper); - } - } - - /** - * Renders a map control in the json builder. - * - * @param \Ivory\GoogleMap\Map $map The map. - * @param string $controlName The control name. - * @param mixed $controlHelper The control helper. - */ - protected function renderMapControl(Map $map, $controlName, $controlHelper) - { - $lcFirstControlName = lcfirst($controlName); - - if (!$map->hasMapOption($lcFirstControlName)) { - return; - } - - $this->jsonBuilder->setValue( - sprintf('[%s]', $lcFirstControlName), - (bool) $map->getMapOption($lcFirstControlName) - ); - - if ($map->getMapOption($lcFirstControlName)) { - $hasControlMethod = 'has'.$controlName; - if ($map->$hasControlMethod()) { - $getControlMethod = 'get'.$controlName; - - $this->jsonBuilder->setValue( - sprintf('[%sOptions]', $lcFirstControlName), - $controlHelper->render($map->$getControlMethod()), - false - ); - } - } + $this->getEventDispatcher()->dispatch($eventName, $event = new MapEvent($map)); - $map->removeMapOption($lcFirstControlName); + return $event->getCode(); } } diff --git a/src/Helper/MapTypeIdHelper.php b/src/Helper/MapTypeIdHelper.php deleted file mode 100644 index 8c18f551..00000000 --- a/src/Helper/MapTypeIdHelper.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper; - -use Ivory\GoogleMap\Exception\HelperException; -use Ivory\GoogleMap\MapTypeId; - -/** - * Map type ID helper. - * - * @author GeLo - */ -class MapTypeIdHelper -{ - /** - * Renders a map map type ID. - * - * @param string $mapTypeId The map type ID. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If the map type ID is not valid. - * - * @return string The JS output. - */ - public function render($mapTypeId) - { - switch ($mapTypeId) { - case MapTypeId::HYBRID: - case MapTypeId::ROADMAP: - case MapTypeId::SATELLITE: - case MapTypeId::TERRAIN: - return sprintf('google.maps.MapTypeId.%s', strtoupper($mapTypeId)); - default: - throw HelperException::invalidMapTypeId(); - } - } -} diff --git a/src/Helper/Overlays/AnimationHelper.php b/src/Helper/Overlays/AnimationHelper.php deleted file mode 100644 index bdc13fa5..00000000 --- a/src/Helper/Overlays/AnimationHelper.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Exception\HelperException; -use Ivory\GoogleMap\Overlays\Animation; - -/** - * Animation helper. - * - * @author GeLo - */ -class AnimationHelper -{ - /** - * Renders an animation. - * - * @param string $animation The animation. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If the animation is not valid. - * - * @return string The JS output. - */ - public function render($animation) - { - switch ($animation) { - case Animation::BOUNCE: - case Animation::DROP: - return sprintf('google.maps.Animation.%s', strtoupper($animation)); - default: - throw HelperException::invalidAnimation(); - } - } -} diff --git a/src/Helper/Overlays/CircleHelper.php b/src/Helper/Overlays/CircleHelper.php deleted file mode 100644 index 8266503b..00000000 --- a/src/Helper/Overlays/CircleHelper.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Circle; - -/** - * Circle helper. - * - * @author GeLo - */ -class CircleHelper extends AbstractHelper -{ - /** - * Renders a circle. - * - * @param \Ivory\GoogleMap\Overlays\Circle $circle The circle. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function render(Circle $circle, Map $map) - { - $this->jsonBuilder - ->reset() - ->setValue('[map]', $map->getJavascriptVariable(), false) - ->setValue('[center]', $circle->getCenter()->getJavascriptVariable(), false) - ->setValue('[radius]', $circle->getRadius()) - ->setValues($circle->getOptions()); - - return sprintf( - '%s = new google.maps.Circle(%s);'.PHP_EOL, - $circle->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/Overlays/EncodedPolylineHelper.php b/src/Helper/Overlays/EncodedPolylineHelper.php deleted file mode 100644 index 2dc89aa0..00000000 --- a/src/Helper/Overlays/EncodedPolylineHelper.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\EncodedPolyline; -use Ivory\GoogleMap\Helper\Geometry\EncodingHelper; - -/** - * Encoded polyline helper. - * - * @author GeLo - */ -class EncodedPolylineHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\Geometry\EncodingHelper */ - protected $encodingHelper; - - /** - * Creates an encoded polyline helper. - * - * @param \Ivory\GoogleMap\Helper\Geometry\EncodingHelper $encodingHelper The encoding helper. - */ - public function __construct(EncodingHelper $encodingHelper = null) - { - parent::__construct(); - - if ($encodingHelper === null) { - $encodingHelper = new EncodingHelper(); - } - - $this->setEncodingHelper($encodingHelper); - } - - /** - * Gets the encoding helper. - * - * @return \Ivory\GoogleMap\Helper\Geometry\EncodingHelper The encoding helper. - */ - public function getEncodingHelper() - { - return $this->encodingHelper; - } - - /** - * Sets the encoding helper. - * - * @param \Ivory\GoogleMap\Helper\Geometry\EncodingHelper $encodingHelper The encoding helper. - */ - public function setEncodingHelper(EncodingHelper $encodingHelper) - { - $this->encodingHelper = $encodingHelper; - } - - /** - * Renders an encoded polyline. - * - * @param \Ivory\GoogleMap\Overlays\EncodedPolyline $encodedPolyline The encoded polyline. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function render(EncodedPolyline $encodedPolyline, Map $map) - { - $this->jsonBuilder - ->reset() - ->setValue('[map]', $map->getJavascriptVariable(), false) - ->setValue('[path]', $this->encodingHelper->renderDecodePath($encodedPolyline->getValue()), false) - ->setValues($encodedPolyline->getOptions()); - - return sprintf( - '%s = new google.maps.Polyline(%s);'.PHP_EOL, - $encodedPolyline->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/Overlays/GroundOverlayHelper.php b/src/Helper/Overlays/GroundOverlayHelper.php deleted file mode 100644 index 889e33cc..00000000 --- a/src/Helper/Overlays/GroundOverlayHelper.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\GroundOverlay; - -/** - * Ground overlay helper. - * - * @author GeLo - */ -class GroundOverlayHelper extends AbstractHelper -{ - /** - * Renders a ground overlay. - * - * @param \Ivory\GoogleMap\Overlays\GroundOverlay $groundOverlay The ground overlay. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function render(GroundOverlay $groundOverlay, Map $map) - { - $this->jsonBuilder - ->reset() - ->setValue('[map]', $map->getJavascriptVariable(), false) - ->setValues($groundOverlay->getOptions()); - - return sprintf( - '%s = new google.maps.GroundOverlay("%s", %s, %s);'.PHP_EOL, - $groundOverlay->getJavascriptVariable(), - $groundOverlay->getUrl(), - $groundOverlay->getBound()->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/Overlays/InfoBoxHelper.php b/src/Helper/Overlays/InfoBoxHelper.php deleted file mode 100644 index daee2d64..00000000 --- a/src/Helper/Overlays/InfoBoxHelper.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\InfoWindow; - -/** - * InfoBox helper. - * - * @author GeLo - */ -class InfoBoxHelper extends InfoWindowHelper -{ - /** - * {@inheritdoc} - */ - public function render(InfoWindow $infoWindow, $renderPosition = true) - { - $this->doRender($infoWindow, $renderPosition); - - return sprintf( - '%s = new InfoBox(%s);'.PHP_EOL, - $infoWindow->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/Overlays/InfoWindowHelper.php b/src/Helper/Overlays/InfoWindowHelper.php deleted file mode 100644 index b1b84667..00000000 --- a/src/Helper/Overlays/InfoWindowHelper.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Marker; -use Ivory\GoogleMap\Overlays\InfoWindow; - -/** - * Info window helper. - * - * @author GeLo - */ -class InfoWindowHelper extends AbstractHelper -{ - /** - * Renders an info window. - * - * @param \Ivory\GoogleMap\Overlays\InfoWindow $infoWindow The info window. - * @param boolean $renderPosition TRUE if the position is rendered else FALSE. - * - * @return string The JS output. - */ - public function render(InfoWindow $infoWindow, $renderPosition = true) - { - $this->doRender($infoWindow, $renderPosition); - - return sprintf( - '%s = new google.maps.InfoWindow(%s);'.PHP_EOL, - $infoWindow->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } - - /** - * Renders the info window open flag. - * - * @param \Ivory\GoogleMap\Overlays\InfoWindow $infoWindow The info window. - * @param \Ivory\GoogleMap\Map $map The map. - * @param \Ivory\GoogleMap\Overlays\Marker $marker The marker. - * - * @return string The JS output. - */ - public function renderOpen(InfoWindow $infoWindow, Map $map, Marker $marker = null) - { - if ($marker !== null) { - return sprintf( - '%s.open(%s, %s);'.PHP_EOL, - $infoWindow->getJavascriptVariable(), - $map->getJavascriptVariable(), - $marker->getJavascriptVariable() - ); - } - - return sprintf('%s.open(%s);'.PHP_EOL, $infoWindow->getJavascriptVariable(), $map->getJavascriptVariable()); - } - - /** - * Configures the json builder in order to render an info window. - * - * @param \Ivory\GoogleMap\Helper\Overlays\InfoWinfow $infoWindow The info window. - * @param boolean $renderPosition TRUE if the position is rendered else FALSE. - */ - protected function doRender(InfoWindow $infoWindow, $renderPosition) - { - $this->jsonBuilder->reset(); - - if ($renderPosition) { - $this->jsonBuilder->setValue('[position]', $infoWindow->getPosition()->getJavascriptVariable(), false); - } - - if ($infoWindow->hasPixelOffset()) { - $this->jsonBuilder->setValue( - '[pixelOffset]', - $infoWindow->getPixelOffset()->getJavascriptVariable(), - false - ); - } - - $this->jsonBuilder - ->setValue('[content]', $infoWindow->getContent()) - ->setValues($infoWindow->getOptions()); - } -} diff --git a/src/Helper/Overlays/MarkerCluster/AbstractMarkerClusterHelper.php b/src/Helper/Overlays/MarkerCluster/AbstractMarkerClusterHelper.php deleted file mode 100644 index 4a31a964..00000000 --- a/src/Helper/Overlays/MarkerCluster/AbstractMarkerClusterHelper.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays\MarkerCluster; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Helper\Overlays\MarkerHelper; - -/** - * Abstract marker cluster helper. - * - * @author GeLo - */ -abstract class AbstractMarkerClusterHelper extends AbstractHelper implements MarkerClusterHelperInterface -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerHelper */ - protected $markerHelper; - - /** - * Creates a default marker cluster helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerHelper $markerHelper The marker helper. - */ - public function __construct(MarkerHelper $markerHelper = null) - { - parent::__construct(); - - if ($markerHelper === null) { - $markerHelper = new MarkerHelper(); - } - - $this->setMarkerHelper($markerHelper); - } - - /** - * Gets the marker helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\MarkerHelper The marker helper. - */ - public function getMarkerHelper() - { - return $this->markerHelper; - } - - /** - * Sets the marker helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerHelper $markerHelper The marker helper. - */ - public function setMarkerHelper(MarkerHelper $markerHelper) - { - $this->markerHelper = $markerHelper; - } -} diff --git a/src/Helper/Overlays/MarkerCluster/DefaultMarkerClusterHelper.php b/src/Helper/Overlays/MarkerCluster/DefaultMarkerClusterHelper.php deleted file mode 100644 index 2cfcfe00..00000000 --- a/src/Helper/Overlays/MarkerCluster/DefaultMarkerClusterHelper.php +++ /dev/null @@ -1,147 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays\MarkerCluster; - -use Ivory\GoogleMap\Events\Event; -use Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper; -use Ivory\GoogleMap\Helper\Overlays\MarkerHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Marker; -use Ivory\GoogleMap\Overlays\MarkerCluster; - -/** - * Default marker cluster helper. - * - * @author GeLo - */ -class DefaultMarkerClusterHelper extends AbstractMarkerClusterHelper -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper */ - protected $infoWindowHelper; - - /** - * Creates a default marker cluster helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerHelper $markerHelper The marker helper. - * @param \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper $infoWindowHelper The info window helper. - */ - public function __construct(MarkerHelper $markerHelper = null, InfoWindowHelper $infoWindowHelper = null) - { - parent::__construct($markerHelper); - - if ($infoWindowHelper === null) { - $infoWindowHelper = new InfoWindowHelper(); - } - - $this->setInfoWindowHelper($infoWindowHelper); - } - - /** - * Gets the info window helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper The info window helper. - */ - public function getInfoWindowHelper() - { - return $this->infoWindowHelper; - } - - /** - * Sets the info window helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper $infoWindowHelper The info window helper. - */ - public function setInfoWindowHelper(InfoWindowHelper $infoWindowHelper) - { - $this->infoWindowHelper = $infoWindowHelper; - } - - /** - * {@inheritdoc} - */ - public function render(MarkerCluster $markerCluster, Map $map) - { - - } - - /** - * {@inheritdoc} - */ - public function renderLibraries(MarkerCluster $markerCluster, Map $map) - { - - } - - /** - * {@inheritdoc} - */ - public function renderMarkers(MarkerCluster $markerCluster, Map $map) - { - $output = array(); - - foreach ($markerCluster->getMarkers() as $marker) { - $output[] = $this->renderMarker($marker, $map); - - if ($marker->hasInfoWindow() && $marker->getInfoWindow()->isAutoOpen()) { - $this->registerInfoWindowEvent($marker, $map); - } - } - - return implode('', $output); - } - - /** - * Renders a marker with the js map container. - * - * @param \Ivory\GoogleMap\Overlays\Marker $marker The marker. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - protected function renderMarker(Marker $marker, Map $map) - { - return sprintf( - '%s.markers.%s = %s', - $this->getJsContainerName($map), - $marker->getJavascriptVariable(), - $this->markerHelper->render($marker, $map) - ); - } - - /** - * Registers the info window event (auto open). - * - * @param \Ivory\GoogleMap\Overlays\Marker $marker The marker. - * @param \Ivory\GoogleMap\Map $map The map. - */ - protected function registerInfoWindowEvent(Marker $marker, Map $map) - { - $closableInfoWindows = sprintf('%s.closable_info_windows', $this->getJsContainerName($map)); - - $handle = <<infoWindowHelper->renderOpen($marker->getInfoWindow(), $map, $marker)} -} -EOF; - - $event = new Event(); - $event->setJavascriptVariable(sprintf('%s_%s', $marker->getJavascriptVariable(), 'info_window_event')); - $event->setInstance($marker->getJavascriptVariable()); - $event->setEventName($marker->getInfoWindow()->getOpenEvent()); - $event->setHandle($handle); - - $map->getEventManager()->addEvent($event); - } -} diff --git a/src/Helper/Overlays/MarkerCluster/JsMarkerClusterHelper.php b/src/Helper/Overlays/MarkerCluster/JsMarkerClusterHelper.php deleted file mode 100644 index cf9032e1..00000000 --- a/src/Helper/Overlays/MarkerCluster/JsMarkerClusterHelper.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays\MarkerCluster; - -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Marker; -use Ivory\GoogleMap\Overlays\MarkerCluster; - -/** - * Javascript marker cluster helper. - * - * @author GeLo - */ -class JsMarkerClusterHelper extends DefaultMarkerClusterHelper -{ - /** - * {@inheritdoc} - */ - public function render(MarkerCluster $markerCluster, Map $map) - { - $this->jsonBuilder - ->reset() - ->setValues($markerCluster->getOptions()); - - return sprintf('%s = new MarkerClusterer(%s, %s, %s);'.PHP_EOL, - $markerCluster->getJavascriptVariable(), - $map->getJavascriptVariable(), - sprintf( - '%s.functions.to_array(%s.markers)', - $this->getJsContainerName($map), - $this->getJsContainerName($map) - ), - $this->jsonBuilder->build() - ); - } - - /** - * {@inheritdoc} - */ - public function renderLibraries(MarkerCluster $markerCluster, Map $map) - { - $url = '//google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer_compiled.js'; - - return sprintf(''.PHP_EOL, $url); - } - - /** - * Renders a marker with the js map container. - * - * @param \Ivory\GoogleMap\Overlays\Marker $marker The marker. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - protected function renderMarker(Marker $marker, Map $map) - { - return sprintf( - '%s.markers.%s = %s', - $this->getJsContainerName($map), - $marker->getJavascriptVariable(), - $this->markerHelper->render($marker) - ); - } -} diff --git a/src/Helper/Overlays/MarkerCluster/MarkerClusterHelper.php b/src/Helper/Overlays/MarkerCluster/MarkerClusterHelper.php deleted file mode 100644 index c7073fcb..00000000 --- a/src/Helper/Overlays/MarkerCluster/MarkerClusterHelper.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays\MarkerCluster; - -use Ivory\GoogleMap\Exception\HelperException; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\MarkerCluster; - -/** - * Marker cluster helper. - * - * @author GeLo - */ -class MarkerClusterHelper implements MarkerClusterHelperInterface -{ - /** @var array */ - protected $helpers; - - /** - * Creates a marker cluster helper. - */ - public function __construct(array $helpers = array()) - { - if (empty($helpers)) { - $helpers = array( - MarkerCluster::_DEFAULT => new DefaultMarkerClusterHelper(), - MarkerCluster::MARKER_CLUSTER => new JsMarkerClusterHelper(), - ); - } - - $this->setHelpers($helpers); - } - - /** - * Checks if the marker cluster helper has helpers. - * - * @return boolean TRUE if the marker cluster helper has helpers else FALSE. - */ - public function hasHelpers() - { - return !empty($this->helpers); - } - - /** - * Gets the marker cluster helper helpers. - * - * @return array The marker cluster helper helpers. - */ - public function getHelpers() - { - return $this->helpers; - } - - /** - * Sets the marker cluster helper helpers. - * - * @param array $helpers The marker cluster helper helpers. - */ - public function setHelpers(array $helpers) - { - $this->helpers = array(); - - foreach ($helpers as $name => $helper) { - $this->setHelper($name, $helper); - } - } - - /** - * Checks if the marker cluster helper has a specific helper. - * - * @param string $name The marker cluster type. - * - * @return \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface The marker cluster helper. - */ - public function hasHelper($name) - { - return isset($this->helpers[$name]); - } - - /** - * Gets a specific marker cluster helper. - * - * @param string $name The marker cluster type. - * - * @throws \Ivory\GoogleMap\Exception\HelperException If the helper does not exist. - * - * @return \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface The marker cluster helper. - */ - public function getHelper($name) - { - if (!$this->hasHelper($name)) { - throw HelperException::invalidMarkerClusterHelper(); - } - - return $this->helpers[$name]; - } - - /** - * Sets a specific marker cluster helper. - * - * @param string $name The marker cluster type. - * @param \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface $helper The marker cluster helper. - */ - public function setHelper($name, MarkerClusterHelperInterface $helper = null) - { - $this->helpers[$name] = $helper; - } - - /** - * {@inheritdoc} - */ - public function render(MarkerCluster $markerCluster, Map $map) - { - return $this->getHelper($markerCluster->getType())->render($markerCluster, $map); - } - - /** - * {@inheritdoc} - */ - public function renderMarkers(MarkerCluster $markerCluster, Map $map) - { - return $this->getHelper($markerCluster->getType())->renderMarkers($markerCluster, $map); - } - - /** - * {@inheritdoc} - */ - public function renderLibraries(MarkerCluster $markerCluster, Map $map) - { - return $this->getHelper($markerCluster->getType())->renderLibraries($markerCluster, $map); - } -} diff --git a/src/Helper/Overlays/MarkerCluster/MarkerClusterHelperInterface.php b/src/Helper/Overlays/MarkerCluster/MarkerClusterHelperInterface.php deleted file mode 100644 index 95889270..00000000 --- a/src/Helper/Overlays/MarkerCluster/MarkerClusterHelperInterface.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays\MarkerCluster; - -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\MarkerCluster; - -/** - * Marker cluster helper. - * - * @author GeLo - */ -interface MarkerClusterHelperInterface -{ - /** - * Renders a marker cluster with the js map container. - * - * @param \Ivory\GoogleMap\Overlays\MarkerCluster $markerCluster The marker cluster. - * @param \Ivory\GoogleMap\Map $map The map - * - * @return string The JS output. - */ - public function render(MarkerCluster $markerCluster, Map $map); - - /** - * Renders the markers of a marker cluster with the js container. - * - * @param \Ivory\GoogleMap\Overlays\MarkerCluster $markerCluster The marker cluster. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function renderMarkers(MarkerCluster $markerCluster, Map $map); - - /** - * Renders the marker cluster libraries. - * - * @param \Ivory\GoogleMap\Overlays\MarkerCluster $markerCluster The marker cluster. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The html output. - */ - public function renderLibraries(MarkerCluster $markerCluster, Map $map); -} diff --git a/src/Helper/Overlays/MarkerHelper.php b/src/Helper/Overlays/MarkerHelper.php deleted file mode 100644 index 64462fa1..00000000 --- a/src/Helper/Overlays/MarkerHelper.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Marker; - -/** - * Marker helper. - * - * @author GeLo - */ -class MarkerHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\AnimationHelper */ - protected $animationHelper; - - /** - * Creates a marker helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\AnimationHelper $animationHelper The animation helper. - */ - public function __construct(AnimationHelper $animationHelper = null) - { - parent::__construct(); - - if ($animationHelper === null) { - $animationHelper = new AnimationHelper(); - } - - $this->setAnimationHelper($animationHelper); - } - - /** - * Gets the animation helper. - * - * @return \Ivory\GoogleMap\Helper\Overlays\AnimationHelper The animation helper. - */ - public function getAnimationHelper() - { - return $this->animationHelper; - } - - /** - * Sets the animation helper. - * - * @param \Ivory\GoogleMap\Helper\Overlays\AnimationHelper $animationHelper The animation helper. - */ - public function setAnimationHelper(AnimationHelper $animationHelper) - { - $this->animationHelper = $animationHelper; - } - - /** - * Renders a marker. - * - * @param Ivory\GoogleMap\Overlays\Marker $marker The marker. - * @param Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function render(Marker $marker, Map $map = null) - { - $this->jsonBuilder - ->reset() - ->setValue('[position]', $marker->getPosition()->getJavascriptVariable(), false); - - if ($map !== null) { - $this->jsonBuilder->setValue('[map]', $map->getJavascriptVariable(), false); - } - - if ($marker->hasAnimation()) { - $this->jsonBuilder->setValue('[animation]', $this->animationHelper->render($marker->getAnimation()), false); - } - - if ($marker->hasIcon()) { - $this->jsonBuilder->setValue('[icon]', $marker->getIcon()->getJavascriptVariable(), false); - } - - if ($marker->hasShadow()) { - $this->jsonBuilder->setValue('[shadow]', $marker->getShadow()->getJavascriptVariable(), false); - } - - if ($marker->hasShape()) { - $this->jsonBuilder->setValue('[shape]', $marker->getShape()->getJavascriptVariable(), false); - } - - $this->jsonBuilder->setValues($marker->getOptions()); - - return sprintf( - '%s = new google.maps.Marker(%s);'.PHP_EOL, - $marker->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/Overlays/MarkerImageHelper.php b/src/Helper/Overlays/MarkerImageHelper.php deleted file mode 100644 index d8315a86..00000000 --- a/src/Helper/Overlays/MarkerImageHelper.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\MarkerImage; - -/** - * Marker image helper. - * - * @author GeLo - */ -class MarkerImageHelper -{ - /** - * Renders a marker image. - * - * @param \Ivory\GoogleMap\Overlays\MarkerImage $markerImage The marker image. - * - * @return string The JS output. - */ - public function render(MarkerImage $markerImage) - { - return sprintf( - '%s = new google.maps.MarkerImage("%s", %s, %s, %s, %s);'.PHP_EOL, - $markerImage->getJavascriptVariable(), - $markerImage->getUrl(), - $markerImage->hasSize() ? $markerImage->getSize()->getJavascriptVariable() : 'null', - $markerImage->hasOrigin() ? $markerImage->getOrigin()->getJavascriptVariable() : 'null', - $markerImage->hasAnchor() ? $markerImage->getAnchor()->getJavascriptVariable() : 'null', - $markerImage->hasScaledSize() ? $markerImage->getScaledSize()->getJavascriptVariable() : 'null' - ); - } -} diff --git a/src/Helper/Overlays/MarkerShapeHelper.php b/src/Helper/Overlays/MarkerShapeHelper.php deleted file mode 100644 index 64dfb329..00000000 --- a/src/Helper/Overlays/MarkerShapeHelper.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\MarkerShape; - -/** - * Marker shape helper. - * - * @author GeLo - */ -class MarkerShapeHelper -{ - /** - * Renders a marker shape. - * - * @param \Ivory\GoogleMap\Overlays\MarkerShape $markerShape The marker shape. - * - * @return string The JS output. - */ - public function render(MarkerShape $markerShape) - { - return sprintf( - '%s = new google.maps.MarkerShape(%s);'.PHP_EOL, - $markerShape->getJavascriptVariable(), - json_encode(array('type' => $markerShape->getType(), 'coords' => $markerShape->getCoordinates())) - ); - } -} diff --git a/src/Helper/Overlays/PolygonHelper.php b/src/Helper/Overlays/PolygonHelper.php deleted file mode 100644 index 682f993b..00000000 --- a/src/Helper/Overlays/PolygonHelper.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Polygon; - -/** - * Polygon helper. - * - * @author GeLo - */ -class PolygonHelper extends AbstractHelper -{ - /** - * Renders a polygon. - * - * @param \Ivory\GoogleMap\Overlays\Polygon $polygon The polygon. - * @param \Ivory\GoogleMapl\Map $map The map. - * - * @return string Ths JS output. - */ - public function render(Polygon $polygon, Map $map) - { - $this->jsonBuilder - ->reset() - ->setValue('[map]', $map->getJavascriptVariable(), false) - ->setValue('[paths]', array()); - - foreach ($polygon->getCoordinates() as $index => $coordinate) { - $this->jsonBuilder->setValue(sprintf('[paths][%d]', $index), $coordinate->getJavascriptVariable(), false); - } - - $this->jsonBuilder->setValues($polygon->getOptions()); - - return sprintf( - '%s = new google.maps.Polygon(%s);'.PHP_EOL, - $polygon->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/Overlays/PolylineHelper.php b/src/Helper/Overlays/PolylineHelper.php deleted file mode 100644 index c9bdff2b..00000000 --- a/src/Helper/Overlays/PolylineHelper.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Polyline; - -/** - * Polyline helper. - * - * @author GeLo - */ -class PolylineHelper extends AbstractHelper -{ - /** - * Renders a polyline. - * - * @param \Ivory\GoogleMap\Overlays\Polyline $polyline The polyline. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function render(Polyline $polyline, Map $map) - { - $this->jsonBuilder - ->reset() - ->setValue('[map]', $map->getJavascriptVariable(), false) - ->setValue('[path]', array()); - - foreach ($polyline->getCoordinates() as $index => $coordinate) { - $this->jsonBuilder->setValue(sprintf('[path][%d]', $index), $coordinate->getJavascriptVariable(), false); - } - - $this->jsonBuilder->setValues($polyline->getOptions()); - - return sprintf( - '%s = new google.maps.Polyline(%s);'.PHP_EOL, - $polyline->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/Overlays/RectangleHelper.php b/src/Helper/Overlays/RectangleHelper.php deleted file mode 100644 index f5d79382..00000000 --- a/src/Helper/Overlays/RectangleHelper.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Rectangle; - -/** - * Rectangle helper. - * - * @author GeLo - */ -class RectangleHelper extends AbstractHelper -{ - /** - * Renders a rectangle. - * - * @param \Ivory\GoogleMap\Overlays\Rectangle $rectangle The rectangle. - * @param \Ivory\GoogleMap\Map $map The map. - * - * @return string The JS output. - */ - public function render(Rectangle $rectangle, Map $map) - { - $this->jsonBuilder - ->reset() - ->setValue('[map]', $map->getJavascriptVariable(), false) - ->setValue('[bounds]', $rectangle->getBound()->getJavascriptVariable(), false) - ->setValues($rectangle->getOptions()); - - return sprintf( - '%s = new google.maps.Rectangle(%s);'.PHP_EOL, - $rectangle->getJavascriptVariable(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/PlaceAutocompleteHelper.php b/src/Helper/PlaceAutocompleteHelper.php new file mode 100644 index 00000000..619b4574 --- /dev/null +++ b/src/Helper/PlaceAutocompleteHelper.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper; + +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class PlaceAutocompleteHelper extends AbstractHelper +{ + /** + * @param Autocomplete $autocomplete + * + * @return string + */ + public function render(Autocomplete $autocomplete) + { + return $this->renderHtml($autocomplete).$this->renderJavascript($autocomplete); + } + + /** + * @param Autocomplete $autocomplete + * + * @return string + */ + public function renderHtml(Autocomplete $autocomplete) + { + return $this->doRender($autocomplete, PlaceAutocompleteEvents::HTML); + } + + /** + * @param Autocomplete $autocomplete + * + * @return string + */ + public function renderJavascript(Autocomplete $autocomplete) + { + return $this->doRender($autocomplete, PlaceAutocompleteEvents::JAVASCRIPT); + } + + /** + * @param Autocomplete $autocomplete + * @param string $eventName + * + * @return string + */ + private function doRender(Autocomplete $autocomplete, $eventName) + { + $this->getEventDispatcher()->dispatch($eventName, $event = new PlaceAutocompleteEvent($autocomplete)); + + return $event->getCode(); + } +} diff --git a/src/Helper/Places/AutocompleteHelper.php b/src/Helper/Places/AutocompleteHelper.php deleted file mode 100644 index 1a9fb08d..00000000 --- a/src/Helper/Places/AutocompleteHelper.php +++ /dev/null @@ -1,240 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Helper\Places; - -use Ivory\GoogleMap\Exception\HelperException; -use Ivory\GoogleMap\Helper\AbstractHelper; -use Ivory\GoogleMap\Helper\ApiHelper; -use Ivory\GoogleMap\Helper\Base\CoordinateHelper; -use Ivory\GoogleMap\Helper\Base\BoundHelper; -use Ivory\GoogleMap\Places\Autocomplete; - -/** - * Places autocomplete helper. - * - * @author GeLo - */ -class AutocompleteHelper extends AbstractHelper -{ - /** @var \Ivory\GoogleMap\Helper\ApiHelper */ - protected $apiHelper; - - /** @var \Ivory\GoogleMap\Helper\Base\CoordinateHelper */ - protected $coordinateHelper; - - /** @var \Ivory\GoogleMap\Helper\Base\BoundHelper */ - protected $boundHelper; - - /** - * Creates an autocomplete helper. - * - * @param \Ivory\GoogleMap\Helper\ApiHelper $apiHelper The API helper. - * @param \Ivory\GoogleMap\Helper\Base\CoordinateHelper $coordinateHelper The coordinate helper. - * @param \Ivory\GoogleMap\Helper\Base\BoundHelper $boundHelper The bound helper. - */ - public function __construct( - ApiHelper $apiHelper = null, - CoordinateHelper $coordinateHelper = null, - BoundHelper $boundHelper = null - ) - { - parent::__construct(); - - if ($apiHelper === null) { - $apiHelper = new ApiHelper(); - } - - if ($coordinateHelper === null) { - $coordinateHelper = new CoordinateHelper(); - } - - if ($boundHelper === null) { - $boundHelper = new BoundHelper(); - } - - $this->setApiHelper($apiHelper); - $this->setCoordinateHelper($coordinateHelper); - $this->setBoundHelper($boundHelper); - } - - /** - * Gets the API helper. - * - * @return \Ivory\GoogleMap\Helper\ApiHelper The API helper. - */ - public function getApiHelper() - { - return $this->apiHelper; - } - - /** - * Sets the API helper. - * - * @param \Ivory\GoogleMap\Helper\ApiHelper $apiHelper The API helper. - */ - public function setApiHelper(ApiHelper $apiHelper) - { - $this->apiHelper = $apiHelper; - } - - /** - * Gets the coordinate helper. - * - * @return \Ivory\GoogleMap\Helper\Base\CoordinateHelper The coordinate helper. - */ - public function getCoordinateHelper() - { - return $this->coordinateHelper; - } - - /** - * Sets the coordinate helper. - * - * @param \Ivory\GoogleMap\Helper\Base\CoordinateHelper $coordinateHelper The coordinate helper. - */ - public function setCoordinateHelper(CoordinateHelper $coordinateHelper) - { - $this->coordinateHelper = $coordinateHelper; - } - - /** - * Gets the bound helper. - * - * @return \Ivory\GoogleMap\Helper\Base\BoundHelper The bound helper. - */ - public function getBoundHelper() - { - return $this->boundHelper; - } - - /** - * Sets the bound helper. - * - * @param \Ivory\GoogleMap\Helper\Base\BoundHelper $boundHelper The bound helper. - */ - public function setBoundHelper(BoundHelper $boundHelper) - { - $this->boundHelper = $boundHelper; - } - - /** - * Renders the autocomplete HTML container. - * - * @param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete. - * - * @return string The HTML output. - */ - public function renderHtmlContainer(Autocomplete $autocomplete) - { - $inputAttributes = $autocomplete->getInputAttributes(); - - $inputAttributes['id'] = $autocomplete->getInputId(); - - if ($autocomplete->hasValue()) { - $inputAttributes['value'] = $autocomplete->getValue(); - } - - $htmlAttributes = array(); - foreach ($inputAttributes as $attribute => $value) { - $htmlAttributes[] = sprintf('%s="%s"', $attribute, $value); - } - - return sprintf(''.PHP_EOL, implode(' ', $htmlAttributes)); - } - - /** - * Renders the autocomplete javascripts. - * - * @param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete. - * - * @throws \Ivory\GoogleMap\Exception\HelperException if the autocomplete bound does not have coordinates. - * - * @return string The HTML output. - */ - public function renderJavascripts(Autocomplete $autocomplete) - { - $output = array(); - - if (!$this->apiHelper->isLoaded() && !$autocomplete->isAsync()) { - $output[] = $this->apiHelper->render($autocomplete->getLanguage(), array('places')); - } - - $output[] = ''.PHP_EOL; - - if (!$this->apiHelper->isLoaded() && $autocomplete->isAsync()) { - $output[] = $this->apiHelper->render( - $autocomplete->getLanguage(), - array('places'), - 'load_ivory_google_place' - ); - } - - return implode('', $output); - } - - /** - * Renders the autocomplete. - * - * @param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete. - * - * @return string The JS output. - */ - public function renderAutocomplete(Autocomplete $autocomplete) - { - $this->jsonBuilder->reset(); - - if ($autocomplete->hasTypes()) { - $this->jsonBuilder->setValue('[types]', $autocomplete->getTypes()); - } - - if ($autocomplete->hasBound()) { - $this->jsonBuilder->setValue('[bounds]', $autocomplete->getBound()->getJavascriptVariable(), false); - } - - if ($autocomplete->hasComponentRestrictions()) { - $this->jsonBuilder->setValue('[componentRestrictions]', $autocomplete->getComponentRestrictions()); - } - - if (!$this->jsonBuilder->hasValues()) { - $this->jsonBuilder->setJsonEncodeOptions(JSON_FORCE_OBJECT); - } - - return sprintf( - '%s = new google.maps.places.Autocomplete(document.getElementById(\'%s\'), %s);'.PHP_EOL, - $autocomplete->getJavascriptVariable(), - $autocomplete->getInputId(), - $this->jsonBuilder->build() - ); - } -} diff --git a/src/Helper/Renderer/AbstractJsonRenderer.php b/src/Helper/Renderer/AbstractJsonRenderer.php new file mode 100644 index 00000000..b1192f43 --- /dev/null +++ b/src/Helper/Renderer/AbstractJsonRenderer.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +abstract class AbstractJsonRenderer extends AbstractRenderer +{ + /** + * @var JsonBuilder + */ + private $jsonBuilder; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + */ + public function __construct(Formatter $formatter, JsonBuilder $jsonBuilder) + { + parent::__construct($formatter); + + $this->setJsonBuilder($jsonBuilder); + } + + /** + * @return JsonBuilder + */ + public function getJsonBuilder() + { + $jsonEncodeOptions = $this->jsonBuilder->getJsonEncodeOptions(); + + if ($this->getFormatter()->isDebug()) { + $jsonEncodeOptions |= JSON_PRETTY_PRINT; + } + + $jsonBuilder = clone $this->jsonBuilder; + + return $jsonBuilder + ->reset() + ->setJsonEncodeOptions($jsonEncodeOptions); + } + + /** + * @param JsonBuilder $jsonBuilder + */ + public function setJsonBuilder(JsonBuilder $jsonBuilder) + { + $this->jsonBuilder = $jsonBuilder; + } +} diff --git a/src/Helper/Renderer/AbstractRenderer.php b/src/Helper/Renderer/AbstractRenderer.php new file mode 100644 index 00000000..e27cba4c --- /dev/null +++ b/src/Helper/Renderer/AbstractRenderer.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; + +/** + * @author GeLo + */ +abstract class AbstractRenderer +{ + /** + * @var Formatter + */ + private $formatter; + + /** + * @param Formatter $formatter + */ + public function __construct(Formatter $formatter) + { + $this->setFormatter($formatter); + } + + /** + * @return Formatter + */ + public function getFormatter() + { + return $this->formatter; + } + + /** + * @param Formatter $formatter + */ + public function setFormatter($formatter) + { + $this->formatter = $formatter; + } +} diff --git a/src/Helper/Renderer/ApiInitRenderer.php b/src/Helper/Renderer/ApiInitRenderer.php new file mode 100644 index 00000000..c17a7238 --- /dev/null +++ b/src/Helper/Renderer/ApiInitRenderer.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +/** + * @author GeLo + */ +class ApiInitRenderer extends AbstractRenderer +{ + /** + * @param string $name + * @param \SplObjectStorage $callbacks + * @param \SplObjectStorage $requirements + * @param string[] $sources + * @param string $sourceCallback + * @param string $requirementCallback + * @param bool $newLine + * + * @return string + */ + public function render( + $name, + \SplObjectStorage $callbacks, + \SplObjectStorage $requirements, + array $sources, + $sourceCallback, + $requirementCallback, + $newLine = true + ) { + $formatter = $this->getFormatter(); + $separator = $formatter->renderSeparator(); + $codes = []; + + foreach ($sources as $source) { + $codes[] = $formatter->renderCall($sourceCallback, [$formatter->renderEscape($source)], true); + } + + foreach ($callbacks as $object) { + $codes[] = $formatter->renderCall($requirementCallback, [ + $callbacks[$object], + $formatter->renderClosure($formatter->renderCode( + 'return '.implode( + $separator.'&&'.$separator, + isset($requirements[$object]) ? $requirements[$object] : [] + ), + true, + false + )), + ], true); + } + + return $formatter->renderClosure($formatter->renderLines($codes, true, false), [], $name, true, $newLine); + } +} diff --git a/src/Helper/Renderer/ApiRenderer.php b/src/Helper/Renderer/ApiRenderer.php new file mode 100644 index 00000000..c91cc249 --- /dev/null +++ b/src/Helper/Renderer/ApiRenderer.php @@ -0,0 +1,180 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementLoaderRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\SourceRenderer; + +/** + * @author GeLo + */ +class ApiRenderer extends AbstractRenderer +{ + /** + * @var ApiInitRenderer + */ + private $apiInitRenderer; + + /** + * @var LoaderRenderer + */ + private $loaderRenderer; + + /** + * @var RequirementLoaderRenderer + */ + private $requirementLoaderRenderer; + + /** + * @var SourceRenderer + */ + private $sourceRenderer; + + /** + * @param Formatter $formatter + * @param ApiInitRenderer $apiInitRenderer + * @param LoaderRenderer $loaderRenderer + * @param RequirementLoaderRenderer $requirementLoaderRenderer + * @param SourceRenderer $sourceRenderer + */ + public function __construct( + Formatter $formatter, + ApiInitRenderer $apiInitRenderer, + LoaderRenderer $loaderRenderer, + RequirementLoaderRenderer $requirementLoaderRenderer, + SourceRenderer $sourceRenderer + ) { + parent::__construct($formatter); + + $this->setApiInitRenderer($apiInitRenderer); + $this->setLoaderRenderer($loaderRenderer); + $this->setRequirementLoaderRenderer($requirementLoaderRenderer); + $this->setSourceRenderer($sourceRenderer); + } + + /** + * @return ApiInitRenderer + */ + public function getApiInitRenderer() + { + return $this->apiInitRenderer; + } + + /** + * @param ApiInitRenderer $apiInitRenderer + */ + public function setApiInitRenderer(ApiInitRenderer $apiInitRenderer) + { + $this->apiInitRenderer = $apiInitRenderer; + } + + /** + * @return LoaderRenderer + */ + public function getLoaderRenderer() + { + return $this->loaderRenderer; + } + + /** + * @param LoaderRenderer $loaderRenderer + */ + public function setLoaderRenderer(LoaderRenderer $loaderRenderer) + { + $this->loaderRenderer = $loaderRenderer; + } + + /** + * @return RequirementLoaderRenderer + */ + public function getRequirementLoaderRenderer() + { + return $this->requirementLoaderRenderer; + } + + /** + * @param RequirementLoaderRenderer $requirementLoaderRenderer + */ + public function setRequirementLoaderRenderer(RequirementLoaderRenderer $requirementLoaderRenderer) + { + $this->requirementLoaderRenderer = $requirementLoaderRenderer; + } + + /** + * @return SourceRenderer + */ + public function getSourceRenderer() + { + return $this->sourceRenderer; + } + + /** + * @param SourceRenderer $sourceRenderer + */ + public function setSourceRenderer(SourceRenderer $sourceRenderer) + { + $this->sourceRenderer = $sourceRenderer; + } + + /** + * @param string $language + * @param \SplObjectStorage $callbacks + * @param \SplObjectStorage $requirements + * @param string[] $sources + * @param string[] $libraries + * + * @return string + */ + public function render( + $language, + \SplObjectStorage $callbacks, + \SplObjectStorage $requirements, + array $sources = [], + array $libraries = [] + ) { + $formatter = $this->getFormatter(); + + $loadCallback = $this->getCallbackName('load'); + $initCallback = $this->getCallbackName('init'); + $initSourceCallback = $this->getCallbackName('init_source'); + $initRequirementCallback = $this->getCallbackName('init_requirement'); + + return $formatter->renderLines([ + $this->loaderRenderer->render($loadCallback, $initCallback, $language, $libraries, false), + $this->sourceRenderer->render($initSourceCallback, null, null, false), + $this->requirementLoaderRenderer->render($initRequirementCallback, null, null, null, 100, false), + $this->apiInitRenderer->render( + $initCallback, + $callbacks, + $requirements, + $sources, + $initSourceCallback, + $initRequirementCallback, + false + ), + $formatter->renderCall($initSourceCallback, [ + $formatter->renderEscape($this->loaderRenderer->renderSource($loadCallback)), + ], true), + ], true, false); + } + + /** + * @param string $callback + * + * @return string + */ + private function getCallbackName($callback) + { + return 'ivory_google_map_'.$callback; + } +} diff --git a/src/Helper/Renderer/Base/BoundRenderer.php b/src/Helper/Renderer/Base/BoundRenderer.php new file mode 100644 index 00000000..ea046b3b --- /dev/null +++ b/src/Helper/Renderer/Base/BoundRenderer.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Base; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class BoundRenderer extends AbstractRenderer +{ + /** + * @param Bound $bound + * + * @return string + */ + public function render(Bound $bound) + { + $arguments = []; + $formatter = $this->getFormatter(); + + if (!$bound->hasExtendables() && $bound->hasCoordinates()) { + $arguments[] = $bound->getSouthWest()->getVariable(); + $arguments[] = $bound->getNorthEast()->getVariable(); + } + + return $formatter->renderObjectAssignment($bound, $formatter->renderObject('LatLngBounds', $arguments)); + } +} diff --git a/src/Helper/Base/CoordinateHelper.php b/src/Helper/Renderer/Base/CoordinateRenderer.php similarity index 53% rename from src/Helper/Base/CoordinateHelper.php rename to src/Helper/Renderer/Base/CoordinateRenderer.php index 3d8da451..e0f9d5bf 100644 --- a/src/Helper/Base/CoordinateHelper.php +++ b/src/Helper/Renderer/Base/CoordinateRenderer.php @@ -9,32 +9,29 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Helper\Base; +namespace Ivory\GoogleMap\Helper\Renderer\Base; use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; /** - * Coordinate templating helper. - * * @author GeLo */ -class CoordinateHelper +class CoordinateRenderer extends AbstractRenderer { /** - * Renders a coordinate. - * - * @param \Ivory\GoogleMap\Base\Coordinate $coordinate The coordinate. + * @param Coordinate $coordinate * - * @return string The JS output. + * @return string */ public function render(Coordinate $coordinate) { - return sprintf( - '%s = new google.maps.LatLng(%s, %s, %s);'.PHP_EOL, - $coordinate->getJavascriptVariable(), + $formatter = $this->getFormatter(); + + return $formatter->renderObjectAssignment($coordinate, $formatter->renderObject('LatLng', [ $coordinate->getLatitude(), $coordinate->getLongitude(), - json_encode($coordinate->isNoWrap()) - ); + $formatter->renderEscape($coordinate->isNoWrap()), + ])); } } diff --git a/src/Helper/Base/PointHelper.php b/src/Helper/Renderer/Base/PointRenderer.php similarity index 53% rename from src/Helper/Base/PointHelper.php rename to src/Helper/Renderer/Base/PointRenderer.php index cd3def82..0b52bbaa 100644 --- a/src/Helper/Base/PointHelper.php +++ b/src/Helper/Renderer/Base/PointRenderer.php @@ -9,31 +9,28 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Helper\Base; +namespace Ivory\GoogleMap\Helper\Renderer\Base; use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; /** - * Point helper. - * * @author GeLo */ -class PointHelper +class PointRenderer extends AbstractRenderer { /** - * Renders a point. - * - * @param \Ivory\GoogleMap\Base\Point $point The point. + * @param Point $point * - * @return string The JS output. + * @return string */ public function render(Point $point) { - return sprintf( - '%s = new google.maps.Point(%s, %s);'.PHP_EOL, - $point->getJavascriptVariable(), + $formatter = $this->getFormatter(); + + return $formatter->renderObjectAssignment($point, $formatter->renderObject('Point', [ $point->getX(), - $point->getY() - ); + $point->getY(), + ])); } } diff --git a/src/Helper/Renderer/Base/SizeRenderer.php b/src/Helper/Renderer/Base/SizeRenderer.php new file mode 100644 index 00000000..b558abe4 --- /dev/null +++ b/src/Helper/Renderer/Base/SizeRenderer.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Base; + +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class SizeRenderer extends AbstractRenderer +{ + /** + * @param Size $size + * + * @return string + */ + public function render(Size $size) + { + $formatter = $this->getFormatter(); + $arguments = [ + $size->getWidth(), + $size->getHeight(), + ]; + + if ($size->hasUnits()) { + $arguments[] = $formatter->renderEscape($size->getWidthUnit()); + $arguments[] = $formatter->renderEscape($size->getHeightUnit()); + } + + return $formatter->renderObjectAssignment($size, $formatter->renderObject('Size', $arguments)); + } +} diff --git a/src/Helper/Renderer/Control/ControlManagerRenderer.php b/src/Helper/Renderer/Control/ControlManagerRenderer.php new file mode 100644 index 00000000..0733f369 --- /dev/null +++ b/src/Helper/Renderer/Control/ControlManagerRenderer.php @@ -0,0 +1,115 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ControlManager; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class ControlManagerRenderer +{ + /** + * @var ControlRendererInterface[] + */ + private $renderers = []; + + /** + * @return bool + */ + public function hasRenderers() + { + return !empty($this->renderers); + } + + /** + * @return ControlRendererInterface[] + */ + public function getRenderers() + { + return $this->renderers; + } + + /** + * @param ControlRendererInterface[] $renderers + */ + public function setRenderers(array $renderers) + { + $this->renderers = []; + $this->addRenderers($renderers); + } + + /** + * @param ControlRendererInterface[] $renderers + */ + public function addRenderers(array $renderers) + { + foreach ($renderers as $renderer) { + $this->addRenderer($renderer); + } + } + + /** + * @param ControlRendererInterface $renderer + * + * @return bool + */ + public function hasRenderer(ControlRendererInterface $renderer) + { + return in_array($renderer, $this->renderers, true); + } + + /** + * @param ControlRendererInterface $renderer + */ + public function addRenderer(ControlRendererInterface $renderer) + { + if (!$this->hasRenderer($renderer)) { + $this->renderers[] = $renderer; + } + } + + /** + * @param ControlRendererInterface $renderer + */ + public function removeRenderer(ControlRendererInterface $renderer) + { + unset($this->renderers[array_search($renderer, $this->renderers, true)]); + $this->renderers = array_values($this->renderers); + } + + /** + * @param ControlManager $controlManager + * @param JsonBuilder $jsonBuilder + * + * @return string + */ + public function render(ControlManager $controlManager, JsonBuilder $jsonBuilder) + { + foreach ($this->renderers as $renderer) { + $control = get_class($renderer); + + if (($position = strrpos($control, '\\')) !== false) { + $control = substr($control, ++$position, -8); + } + + if ($controlManager->{'has'.$control}()) { + $lcControl = lcfirst($control); + + $jsonBuilder + ->setValue('['.$lcControl.']', true) + ->setValue('['.$lcControl.'Options]', $renderer->render($controlManager->{'get'.$control}()), false); + } + } + } +} diff --git a/src/Helper/Renderer/Control/ControlPositionRenderer.php b/src/Helper/Renderer/Control/ControlPositionRenderer.php new file mode 100644 index 00000000..35040c18 --- /dev/null +++ b/src/Helper/Renderer/Control/ControlPositionRenderer.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class ControlPositionRenderer extends AbstractRenderer +{ + /** + * @param string $position + * + * @return string + */ + public function render($position) + { + return $this->getFormatter()->renderConstant('ControlPosition', $position); + } +} diff --git a/src/Overlays/ExtendableInterface.php b/src/Helper/Renderer/Control/ControlRendererInterface.php similarity index 59% rename from src/Overlays/ExtendableInterface.php rename to src/Helper/Renderer/Control/ControlRendererInterface.php index 89634ae1..7d0de4f0 100644 --- a/src/Overlays/ExtendableInterface.php +++ b/src/Helper/Renderer/Control/ControlRendererInterface.php @@ -9,13 +9,17 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Overlays; +namespace Ivory\GoogleMap\Helper\Renderer\Control; /** - * Each class implements this interface can be extend by a bound. - * * @author GeLo */ -interface ExtendableInterface +interface ControlRendererInterface { + /** + * @param object $control + * + * @return string + */ + public function render($control); } diff --git a/src/Helper/Renderer/Control/MapTypeControlRenderer.php b/src/Helper/Renderer/Control/MapTypeControlRenderer.php new file mode 100644 index 00000000..828cdd17 --- /dev/null +++ b/src/Helper/Renderer/Control/MapTypeControlRenderer.php @@ -0,0 +1,133 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\MapTypeControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapTypeIdRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MapTypeControlRenderer extends AbstractJsonRenderer implements ControlRendererInterface +{ + /** + * @var MapTypeIdRenderer + */ + private $mapTypeIdRenderer; + + /** + * @var ControlPositionRenderer + */ + private $controlPositionRenderer; + + /** + * @var MapTypeControlStyleRenderer + */ + private $mapTypeControlStyleRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param MapTypeIdRenderer $mapTypeIdRenderer + * @param ControlPositionRenderer $controlPositionRenderer + * @param MapTypeControlStyleRenderer $mapTypeControlStyleRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + MapTypeIdRenderer $mapTypeIdRenderer, + ControlPositionRenderer $controlPositionRenderer, + MapTypeControlStyleRenderer $mapTypeControlStyleRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setMapTypeIdRenderer($mapTypeIdRenderer); + $this->setControlPositionRenderer($controlPositionRenderer); + $this->setMapTypeControlStyleRenderer($mapTypeControlStyleRenderer); + } + + /** + * @return MapTypeIdRenderer + */ + public function getMapTypeIdRenderer() + { + return $this->mapTypeIdRenderer; + } + + /** + * @param MapTypeIdRenderer $mapTypeIdRenderer + */ + public function setMapTypeIdRenderer(MapTypeIdRenderer $mapTypeIdRenderer) + { + $this->mapTypeIdRenderer = $mapTypeIdRenderer; + } + + /** + * @return ControlPositionRenderer + */ + public function getControlPositionRenderer() + { + return $this->controlPositionRenderer; + } + + /** + * @param ControlPositionRenderer $controlPositionRenderer + */ + public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) + { + $this->controlPositionRenderer = $controlPositionRenderer; + } + + /** + * @return MapTypeControlStyleRenderer + */ + public function getMapTypeControlStyleRenderer() + { + return $this->mapTypeControlStyleRenderer; + } + + /** + * @param MapTypeControlStyleRenderer $mapTypeControlStyleRenderer + */ + public function setMapTypeControlStyleRenderer(MapTypeControlStyleRenderer $mapTypeControlStyleRenderer) + { + $this->mapTypeControlStyleRenderer = $mapTypeControlStyleRenderer; + } + + /** + * {@inheritdoc} + */ + public function render($control) + { + if (!$control instanceof MapTypeControl) { + throw new \InvalidArgumentException(sprintf( + 'Expected a "%s", got "%s".', + MapTypeControl::class, + is_object($control) ? get_class($control) : gettype($control) + )); + } + + $jsonBuilder = $this->getJsonBuilder(); + + foreach ($control->getIds() as $index => $id) { + $jsonBuilder->setValue('[mapTypeIds]['.$index.']', $this->mapTypeIdRenderer->render($id), false); + } + + return $jsonBuilder + ->setValue('[position]', $this->controlPositionRenderer->render($control->getPosition()), false) + ->setValue('[style]', $this->mapTypeControlStyleRenderer->render($control->getStyle()), false) + ->build(); + } +} diff --git a/src/Helper/Renderer/Control/MapTypeControlStyleRenderer.php b/src/Helper/Renderer/Control/MapTypeControlStyleRenderer.php new file mode 100644 index 00000000..d9e03a16 --- /dev/null +++ b/src/Helper/Renderer/Control/MapTypeControlStyleRenderer.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class MapTypeControlStyleRenderer extends AbstractRenderer +{ + /** + * @param string $style + * + * @return string + */ + public function render($style) + { + return $this->getFormatter()->renderConstant('MapTypeControlStyle', $style); + } +} diff --git a/src/Helper/Renderer/Control/RotateControlRenderer.php b/src/Helper/Renderer/Control/RotateControlRenderer.php new file mode 100644 index 00000000..3e4251af --- /dev/null +++ b/src/Helper/Renderer/Control/RotateControlRenderer.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\RotateControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class RotateControlRenderer extends AbstractJsonRenderer implements ControlRendererInterface +{ + /** + * @var ControlPositionRenderer + */ + private $controlPositionRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param ControlPositionRenderer $controlPositionRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + ControlPositionRenderer $controlPositionRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setControlPositionRenderer($controlPositionRenderer); + } + + /** + * @return ControlPositionRenderer + */ + public function getControlPositionRenderer() + { + return $this->controlPositionRenderer; + } + + /** + * @param ControlPositionRenderer $controlPositionRenderer + */ + public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) + { + $this->controlPositionRenderer = $controlPositionRenderer; + } + + /** + * {@inheritdoc} + */ + public function render($control) + { + if (!$control instanceof RotateControl) { + throw new \InvalidArgumentException(sprintf( + 'Expected a "%s", got "%s".', + RotateControl::class, + is_object($control) ? get_class($control) : gettype($control) + )); + } + + return $this->getJsonBuilder() + ->setValue('[position]', $this->controlPositionRenderer->render($control->getPosition()), false) + ->build(); + } +} diff --git a/src/Helper/Renderer/Control/ScaleControlRenderer.php b/src/Helper/Renderer/Control/ScaleControlRenderer.php new file mode 100644 index 00000000..18aa50c8 --- /dev/null +++ b/src/Helper/Renderer/Control/ScaleControlRenderer.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ScaleControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class ScaleControlRenderer extends AbstractJsonRenderer implements ControlRendererInterface +{ + /** + * @var ControlPositionRenderer + */ + private $controlPositionRenderer; + + /** + * @var ScaleControlStyleRenderer + */ + private $scaleControlStyleRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param ControlPositionRenderer $controlPositionRenderer + * @param ScaleControlStyleRenderer $scaleControlStyleRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + ControlPositionRenderer $controlPositionRenderer, + ScaleControlStyleRenderer $scaleControlStyleRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setControlPositionRenderer($controlPositionRenderer); + $this->setScaleControlStyleRenderer($scaleControlStyleRenderer); + } + + /** + * @return ControlPositionRenderer + */ + public function getControlPositionRenderer() + { + return $this->controlPositionRenderer; + } + + /** + * @param ControlPositionRenderer $controlPositionRenderer + */ + public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) + { + $this->controlPositionRenderer = $controlPositionRenderer; + } + + /** + * @return ScaleControlStyleRenderer + */ + public function getScaleControlStyleRenderer() + { + return $this->scaleControlStyleRenderer; + } + + /** + * @param ScaleControlStyleRenderer $scaleControlStyleRenderer + */ + public function setScaleControlStyleRenderer(ScaleControlStyleRenderer $scaleControlStyleRenderer) + { + $this->scaleControlStyleRenderer = $scaleControlStyleRenderer; + } + + /** + * @param ScaleControl $control + * + * @return string + */ + public function render($control) + { + if (!$control instanceof ScaleControl) { + throw new \InvalidArgumentException(sprintf( + 'Expected a "%s", got "%s".', + ScaleControl::class, + is_object($control) ? get_class($control) : gettype($control) + )); + } + + return $this->getJsonBuilder() + ->setValue('[position]', $this->controlPositionRenderer->render($control->getPosition()), false) + ->setValue('[style]', $this->scaleControlStyleRenderer->render($control->getStyle()), false) + ->build(); + } +} diff --git a/src/Helper/Renderer/Control/ScaleControlStyleRenderer.php b/src/Helper/Renderer/Control/ScaleControlStyleRenderer.php new file mode 100644 index 00000000..92ed701e --- /dev/null +++ b/src/Helper/Renderer/Control/ScaleControlStyleRenderer.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class ScaleControlStyleRenderer extends AbstractRenderer +{ + /** + * @param string $style + * + * @return string + */ + public function render($style) + { + return $this->getFormatter()->renderConstant('ScaleControlStyle', $style); + } +} diff --git a/src/Helper/Renderer/Control/StreetViewControlRenderer.php b/src/Helper/Renderer/Control/StreetViewControlRenderer.php new file mode 100644 index 00000000..57b06651 --- /dev/null +++ b/src/Helper/Renderer/Control/StreetViewControlRenderer.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\StreetViewControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class StreetViewControlRenderer extends AbstractJsonRenderer implements ControlRendererInterface +{ + /** + * @var ControlPositionRenderer + */ + private $controlPositionRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param ControlPositionRenderer $controlPositionRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + ControlPositionRenderer $controlPositionRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setControlPositionRenderer($controlPositionRenderer); + } + + /** + * @return ControlPositionRenderer + */ + public function getControlPositionRenderer() + { + return $this->controlPositionRenderer; + } + + /** + * @param ControlPositionRenderer $controlPositionRenderer + */ + public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) + { + $this->controlPositionRenderer = $controlPositionRenderer; + } + + /** + * {@inheritdoc} + */ + public function render($control) + { + if (!$control instanceof StreetViewControl) { + throw new \InvalidArgumentException(sprintf( + 'Expected a "%s", got "%s".', + StreetViewControl::class, + is_object($control) ? get_class($control) : gettype($control) + )); + } + + return $this->getJsonBuilder() + ->setValue('[position]', $this->controlPositionRenderer->render($control->getPosition()), false) + ->build(); + } +} diff --git a/src/Helper/Renderer/Control/ZoomControlRenderer.php b/src/Helper/Renderer/Control/ZoomControlRenderer.php new file mode 100644 index 00000000..195d32a0 --- /dev/null +++ b/src/Helper/Renderer/Control/ZoomControlRenderer.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ZoomControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class ZoomControlRenderer extends AbstractJsonRenderer implements ControlRendererInterface +{ + /** + * @var ControlPositionRenderer + */ + private $controlPositionRenderer; + + /** + * @var ZoomControlStyleRenderer + */ + private $zoomControlStyleRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param ControlPositionRenderer $controlPositionRenderer + * @param ZoomControlStyleRenderer $zoomControlStyleRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + ControlPositionRenderer $controlPositionRenderer, + ZoomControlStyleRenderer $zoomControlStyleRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setControlPositionRenderer($controlPositionRenderer); + $this->setZoomControlStyleRenderer($zoomControlStyleRenderer); + } + + /** + * @return ControlPositionRenderer + */ + public function getControlPositionRenderer() + { + return $this->controlPositionRenderer; + } + + /** + * @param ControlPositionRenderer $controlPositionRenderer + */ + public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) + { + $this->controlPositionRenderer = $controlPositionRenderer; + } + + /** + * @return ZoomControlStyleRenderer + */ + public function getZoomControlStyleRenderer() + { + return $this->zoomControlStyleRenderer; + } + + /** + * @param ZoomControlStyleRenderer $zoomControlStyleRenderer + */ + public function setZoomControlStyleRenderer(ZoomControlStyleRenderer $zoomControlStyleRenderer) + { + $this->zoomControlStyleRenderer = $zoomControlStyleRenderer; + } + + /** + * {@inheritdoc} + */ + public function render($control) + { + if (!$control instanceof ZoomControl) { + throw new \InvalidArgumentException(sprintf( + 'Expected a "%s", got "%s".', + ZoomControl::class, + is_object($control) ? get_class($control) : gettype($control) + )); + } + + return $this->getJsonBuilder() + ->setValue('[position]', $this->controlPositionRenderer->render($control->getPosition()), false) + ->setValue('[style]', $this->zoomControlStyleRenderer->render($control->getStyle()), false) + ->build(); + } +} diff --git a/src/Helper/Renderer/Control/ZoomControlStyleRenderer.php b/src/Helper/Renderer/Control/ZoomControlStyleRenderer.php new file mode 100644 index 00000000..2f866b7d --- /dev/null +++ b/src/Helper/Renderer/Control/ZoomControlStyleRenderer.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class ZoomControlStyleRenderer extends AbstractRenderer +{ + /** + * @param string $style + * + * @return string + */ + public function render($style) + { + return $this->getFormatter()->renderConstant('ZoomControlStyle', $style); + } +} diff --git a/src/Helper/Renderer/Event/AbstractEventRenderer.php b/src/Helper/Renderer/Event/AbstractEventRenderer.php new file mode 100644 index 00000000..e7436662 --- /dev/null +++ b/src/Helper/Renderer/Event/AbstractEventRenderer.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +abstract class AbstractEventRenderer extends AbstractRenderer +{ + /** + * @param Event $event + * + * @return string + */ + public function render(Event $event) + { + $formatter = $this->getFormatter(); + + $arguments = [ + $event->getInstance(), + $formatter->renderEscape($event->getTrigger()), + $event->getHandle(), + ]; + + if ($this->hasCapture()) { + $arguments[] = $formatter->renderEscape($event->isCapture()); + } + + return $formatter->renderObjectAssignment($event, $formatter->renderCall( + $formatter->renderProperty($formatter->renderClass('event'), $this->getMethod()), + $arguments + )); + } + + /** + * @return string + */ + abstract protected function getMethod(); + + /** + * @return bool + */ + protected function hasCapture() + { + return true; + } +} diff --git a/src/Helper/Renderer/Event/DomEventOnceRenderer.php b/src/Helper/Renderer/Event/DomEventOnceRenderer.php new file mode 100644 index 00000000..673632e1 --- /dev/null +++ b/src/Helper/Renderer/Event/DomEventOnceRenderer.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Event; + +/** + * @author GeLo + */ +class DomEventOnceRenderer extends AbstractEventRenderer +{ + /** + * {@inheritdoc} + */ + protected function getMethod() + { + return 'addDomListenerOnce'; + } +} diff --git a/src/Helper/Renderer/Event/DomEventRenderer.php b/src/Helper/Renderer/Event/DomEventRenderer.php new file mode 100644 index 00000000..ecb4192f --- /dev/null +++ b/src/Helper/Renderer/Event/DomEventRenderer.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Event; + +/** + * @author GeLo + */ +class DomEventRenderer extends AbstractEventRenderer +{ + /** + * {@inheritdoc} + */ + protected function getMethod() + { + return 'addDomListener'; + } +} diff --git a/src/Helper/Renderer/Event/EventOnceRenderer.php b/src/Helper/Renderer/Event/EventOnceRenderer.php new file mode 100644 index 00000000..8758a6e4 --- /dev/null +++ b/src/Helper/Renderer/Event/EventOnceRenderer.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Event; + +/** + * @author GeLo + */ +class EventOnceRenderer extends AbstractEventRenderer +{ + /** + * {@inheritdoc} + */ + protected function getMethod() + { + return 'addListenerOnce'; + } + + /** + * {@inheritdoc} + */ + protected function hasCapture() + { + return false; + } +} diff --git a/src/Helper/Renderer/Event/EventRenderer.php b/src/Helper/Renderer/Event/EventRenderer.php new file mode 100644 index 00000000..866cccd1 --- /dev/null +++ b/src/Helper/Renderer/Event/EventRenderer.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Event; + +/** + * @author GeLo + */ +class EventRenderer extends AbstractEventRenderer +{ + /** + * {@inheritdoc} + */ + protected function getMethod() + { + return 'addListener'; + } + + /** + * {@inheritdoc} + */ + protected function hasCapture() + { + return false; + } +} diff --git a/src/Helper/Renderer/Geometry/EncodingRenderer.php b/src/Helper/Renderer/Geometry/EncodingRenderer.php new file mode 100644 index 00000000..c9edac95 --- /dev/null +++ b/src/Helper/Renderer/Geometry/EncodingRenderer.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Geometry; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#encoding + * + * @author GeLo + */ +class EncodingRenderer extends AbstractRenderer +{ + /** + * @param string $encodedPath + * + * @return string + */ + public function renderDecodePath($encodedPath) + { + $formatter = $this->getFormatter(); + + return $formatter->renderCall( + $formatter->renderProperty($formatter->renderClass('geometry.encoding'), 'decodePath'), + [$formatter->renderEscape(addslashes($encodedPath))] + ); + } +} diff --git a/src/Helper/Renderer/Html/AbstractTagRenderer.php b/src/Helper/Renderer/Html/AbstractTagRenderer.php new file mode 100644 index 00000000..3d27c6fd --- /dev/null +++ b/src/Helper/Renderer/Html/AbstractTagRenderer.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class AbstractTagRenderer extends AbstractRenderer +{ + /** + * @var TagRenderer + */ + private $tagRenderer; + + /** + * @param Formatter $formatter + * @param TagRenderer $tagRenderer + */ + public function __construct(Formatter $formatter, TagRenderer $tagRenderer) + { + parent::__construct($formatter); + + $this->setTagRenderer($tagRenderer); + } + + /** + * @return TagRenderer + */ + public function getTagRenderer() + { + return $this->tagRenderer; + } + + /** + * @param TagRenderer $tagRenderer + */ + public function setTagRenderer(TagRenderer $tagRenderer) + { + $this->tagRenderer = $tagRenderer; + } +} diff --git a/src/Helper/Renderer/Html/JavascriptTagRenderer.php b/src/Helper/Renderer/Html/JavascriptTagRenderer.php new file mode 100644 index 00000000..67725a1a --- /dev/null +++ b/src/Helper/Renderer/Html/JavascriptTagRenderer.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Html; + +/** + * @author GeLo + */ +class JavascriptTagRenderer extends AbstractTagRenderer +{ + /** + * @param string|null $code + * @param string[] $attributes + * @param bool $newLine + * + * @return string + */ + public function render($code = null, array $attributes = [], $newLine = true) + { + return $this->getTagRenderer()->render( + 'script', + $code, + array_merge(['type' => 'text/javascript'], $attributes), + $newLine + ); + } +} diff --git a/src/Helper/Renderer/Html/StylesheetRenderer.php b/src/Helper/Renderer/Html/StylesheetRenderer.php new file mode 100644 index 00000000..51d9b434 --- /dev/null +++ b/src/Helper/Renderer/Html/StylesheetRenderer.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class StylesheetRenderer extends AbstractRenderer +{ + /** + * @param string $stylesheet + * @param string $value + * + * @return string + */ + public function render($stylesheet, $value) + { + $formatter = $this->getFormatter(); + + return $formatter->renderCode($stylesheet.':'.$formatter->renderSeparator().$value, true, false); + } +} diff --git a/src/Helper/Renderer/Html/StylesheetTagRenderer.php b/src/Helper/Renderer/Html/StylesheetTagRenderer.php new file mode 100644 index 00000000..9df64fbd --- /dev/null +++ b/src/Helper/Renderer/Html/StylesheetTagRenderer.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; + +/** + * @author GeLo + */ +class StylesheetTagRenderer extends AbstractTagRenderer +{ + /** + * @var StylesheetRenderer + */ + private $stylesheetRenderer; + + /** + * @param Formatter $formatter + * @param TagRenderer $tagRenderer + * @param StylesheetRenderer $stylesheetRenderer + */ + public function __construct(Formatter $formatter, TagRenderer $tagRenderer, StylesheetRenderer $stylesheetRenderer) + { + parent::__construct($formatter, $tagRenderer); + + $this->setStylesheetRenderer($stylesheetRenderer); + } + + /** + * @return StylesheetRenderer + */ + public function getStylesheetRenderer() + { + return $this->stylesheetRenderer; + } + + /** + * @param StylesheetRenderer $stylesheetRenderer + */ + public function setStylesheetRenderer(StylesheetRenderer $stylesheetRenderer) + { + $this->stylesheetRenderer = $stylesheetRenderer; + } + + /** + * @param string $name + * @param string[] $stylesheets + * @param string[] $attributes + * @param bool $newLine + * + * @return string + */ + public function render($name, array $stylesheets, array $attributes = [], $newLine = true) + { + $formatter = $this->getFormatter(); + + $tagStylesheets = []; + foreach ($stylesheets as $stylesheet => $value) { + $tagStylesheets[] = $this->stylesheetRenderer->render($stylesheet, $value); + } + + return $this->getTagRenderer()->render( + 'style', + $formatter->renderLines([ + $name.$formatter->renderSeparator().'{', + $formatter->renderIndentation($formatter->renderLines($tagStylesheets, true, false)), + '}', + ], !empty($tagStylesheets), false), + array_merge(['type' => 'test/css'], $attributes), + $newLine + ); + } +} diff --git a/src/Helper/Renderer/Html/TagRenderer.php b/src/Helper/Renderer/Html/TagRenderer.php new file mode 100644 index 00000000..9ae9edb3 --- /dev/null +++ b/src/Helper/Renderer/Html/TagRenderer.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class TagRenderer extends AbstractRenderer +{ + /** + * @param string $name + * @param string|null $code + * @param string[] $attributes + * @param bool $newLine + * + * @return string + */ + public function render($name, $code = null, array $attributes = [], $newLine = true) + { + $formatter = $this->getFormatter(); + + $tagAttributes = []; + foreach ($attributes as $attribute => $value) { + $tagAttributes[] = $attribute.'='.$formatter->renderEscape($value); + } + + if (!empty($tagAttributes)) { + array_unshift($tagAttributes, null); + } + + return $formatter->renderLines([ + '<'.$name.implode(' ', $tagAttributes).'>', + $formatter->renderIndentation($code), + '', + ], !empty($code), $newLine); + } +} diff --git a/src/Helper/Renderer/Layer/KmlLayerRenderer.php b/src/Helper/Renderer/Layer/KmlLayerRenderer.php new file mode 100644 index 00000000..295ee6a6 --- /dev/null +++ b/src/Helper/Renderer/Layer/KmlLayerRenderer.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Layer; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Layer\KmlLayer; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class KmlLayerRenderer extends AbstractJsonRenderer +{ + /** + * @param KmlLayer $kmlLayer + * @param Map $map + * + * @return string + */ + public function render(KmlLayer $kmlLayer, Map $map) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[map]', $map->getVariable(), false) + ->setValues($kmlLayer->getOptions()); + + return $formatter->renderObjectAssignment($kmlLayer, $formatter->renderObject('KmlLayer', [ + $formatter->renderEscape($kmlLayer->getUrl()), + $jsonBuilder->build(), + ])); + } +} diff --git a/src/Helper/Renderer/LoaderRenderer.php b/src/Helper/Renderer/LoaderRenderer.php new file mode 100644 index 00000000..f36ef78d --- /dev/null +++ b/src/Helper/Renderer/LoaderRenderer.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +/** + * @author GeLo + */ +class LoaderRenderer extends AbstractJsonRenderer +{ + /** + * @param string $name + * @param string $callback + * @param string $language + * @param string[] $libraries + * @param bool $newLine + * + * @return string + */ + public function render( + $name, + $callback, + $language, + array $libraries = [], + $newLine = true + ) { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder(); + + $parameters = ['language' => $language]; + if (!empty($libraries)) { + $parameters['libraries'] = implode(',', $libraries); + } + + $jsonBuilder + ->setValue('[other_params]', urldecode(http_build_query($parameters, '', '&'))) + ->setValue('[callback]', $callback, false); + + return $formatter->renderClosure($formatter->renderCall($formatter->renderProperty('google', 'load'), [ + $formatter->renderEscape('maps'), + $formatter->renderEscape('3'), + $jsonBuilder->build(), + ]), [], $name, true, $newLine); + } + + /** + * @param string $callback + * + * @return string + */ + public function renderSource($callback) + { + return 'https://www.google.com/jsapi?callback='.$callback; + } +} diff --git a/src/Helper/Renderer/MapBoundRenderer.php b/src/Helper/Renderer/MapBoundRenderer.php new file mode 100644 index 00000000..1fbd154a --- /dev/null +++ b/src/Helper/Renderer/MapBoundRenderer.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class MapBoundRenderer extends AbstractRenderer +{ + /** + * @param Map $map + * + * @return string + */ + public function render(Map $map) + { + return $this->getFormatter()->renderObjectCall( + $map, + 'fitBounds', + [$map->getBound()->getVariable()] + ); + } +} diff --git a/src/Helper/Renderer/MapCenterRenderer.php b/src/Helper/Renderer/MapCenterRenderer.php new file mode 100644 index 00000000..7d141f6c --- /dev/null +++ b/src/Helper/Renderer/MapCenterRenderer.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class MapCenterRenderer extends AbstractRenderer +{ + /** + * @param Map $map + * + * @return string + */ + public function render(Map $map) + { + return $this->getFormatter()->renderObjectCall( + $map, + 'setCenter', + [$map->getCenter()->getVariable()] + ); + } +} diff --git a/src/Helper/Renderer/MapContainerRenderer.php b/src/Helper/Renderer/MapContainerRenderer.php new file mode 100644 index 00000000..1e1ff176 --- /dev/null +++ b/src/Helper/Renderer/MapContainerRenderer.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +/** + * @author GeLo + */ +class MapContainerRenderer extends AbstractJsonRenderer +{ + /** + * @return string + */ + public function render() + { + return $this->getJsonBuilder() + ->setValue('[base][coordinates]', []) + ->setValue('[base][bounds]', []) + ->setValue('[base][points]', []) + ->setValue('[base][sizes]', []) + ->setValue('[map]', null) + ->setValue('[overlays][circles]', []) + ->setValue('[overlays][encoded_polylines]', []) + ->setValue('[overlays][ground_overlays]', []) + ->setValue('[overlays][polygons]', []) + ->setValue('[overlays][polylines]', []) + ->setValue('[overlays][rectangles]', []) + ->setValue('[overlays][info_windows]', []) + ->setValue('[overlays][info_boxes]', []) + ->setValue('[overlays][marker_images]', []) + ->setValue('[overlays][markers]', []) + ->setValue('[overlays][marker_cluster]', null) + ->setValue('[layers][kml_layers]', []) + ->setValue('[events][dom_events]', []) + ->setValue('[events][dom_events_once]', []) + ->setValue('[events][events]', []) + ->setValue('[events][events_once]', []) + ->setValue('[functions]', []) + ->build(); + } +} diff --git a/src/Helper/Renderer/MapHtmlRenderer.php b/src/Helper/Renderer/MapHtmlRenderer.php new file mode 100644 index 00000000..a96a04f4 --- /dev/null +++ b/src/Helper/Renderer/MapHtmlRenderer.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Html\AbstractTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\StylesheetRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class MapHtmlRenderer extends AbstractTagRenderer +{ + /** + * @var StylesheetRenderer + */ + private $stylesheetRenderer; + + /** + * @param Formatter $formatter + * @param TagRenderer $tagRenderer + * @param StylesheetRenderer $stylesheetRenderer + */ + public function __construct(Formatter $formatter, TagRenderer $tagRenderer, StylesheetRenderer $stylesheetRenderer) + { + parent::__construct($formatter, $tagRenderer); + + $this->setStylesheetRenderer($stylesheetRenderer); + } + + /** + * @return StylesheetRenderer + */ + public function getStylesheetRenderer() + { + return $this->stylesheetRenderer; + } + + /** + * @param StylesheetRenderer $stylesheetRenderer + */ + public function setStylesheetRenderer(StylesheetRenderer $stylesheetRenderer) + { + $this->stylesheetRenderer = $stylesheetRenderer; + } + + /** + * @param Map $map + * + * @return string + */ + public function render(Map $map) + { + $styles = []; + $stylesheets = [ + 'width' => $map->hasStylesheetOption('width') ? $map->getStylesheetOption('width') : '300px', + 'height' => $map->hasStylesheetOption('height') ? $map->getStylesheetOption('height') : '300px', + ]; + + foreach ($stylesheets as $stylesheet => $value) { + $styles[] = $this->stylesheetRenderer->render($stylesheet, $value); + } + + return $this->getTagRenderer()->render('div', null, [ + 'id' => $map->getHtmlId(), + 'style' => implode('', $styles), + ]); + } +} diff --git a/src/Helper/Renderer/MapRenderer.php b/src/Helper/Renderer/MapRenderer.php new file mode 100644 index 00000000..9ed1e903 --- /dev/null +++ b/src/Helper/Renderer/MapRenderer.php @@ -0,0 +1,157 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlManagerRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\MapTypeId; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MapRenderer extends AbstractJsonRenderer +{ + /** + * @var MapTypeIdRenderer + */ + private $mapTypeIdRenderer; + + /** + * @var ControlManagerRenderer + */ + private $controlManagerRenderer; + + /** + * @var RequirementRenderer + */ + private $requirementRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param MapTypeIdRenderer $mapTypeIdRenderer + * @param ControlManagerRenderer $controlManagerRenderer + * @param RequirementRenderer $requirementRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + MapTypeIdRenderer $mapTypeIdRenderer, + ControlManagerRenderer $controlManagerRenderer, + RequirementRenderer $requirementRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setMapTypeIdRenderer($mapTypeIdRenderer); + $this->setControlManagerRenderer($controlManagerRenderer); + $this->setRequirementRenderer($requirementRenderer); + } + + /** + * @return MapTypeIdRenderer + */ + public function getMapTypeIdRenderer() + { + return $this->mapTypeIdRenderer; + } + + /** + * @param MapTypeIdRenderer $mapTypeIdRenderer + */ + public function setMapTypeIdRenderer(MapTypeIdRenderer $mapTypeIdRenderer) + { + $this->mapTypeIdRenderer = $mapTypeIdRenderer; + } + + /** + * @return ControlManagerRenderer + */ + public function getControlManagerRenderer() + { + return $this->controlManagerRenderer; + } + + /** + * @param ControlManagerRenderer $controlManagerRenderer + */ + public function setControlManagerRenderer(ControlManagerRenderer $controlManagerRenderer) + { + $this->controlManagerRenderer = $controlManagerRenderer; + } + + /** + * @return RequirementRenderer + */ + public function getRequirementRenderer() + { + return $this->requirementRenderer; + } + + /** + * @param RequirementRenderer $requirementRenderer + */ + public function setRequirementRenderer($requirementRenderer) + { + $this->requirementRenderer = $requirementRenderer; + } + + /** + * @param Map $map + * + * @return string + */ + public function render(Map $map) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder(); + + $options = $map->getMapOptions(); + unset($options['mapTypeId']); + + if (!$map->isAutoZoom()) { + if (!isset($options['zoom'])) { + $options['zoom'] = 3; + } + } else { + unset($options['zoom']); + } + + $this->controlManagerRenderer->render($map->getControlManager(), $jsonBuilder); + + $jsonBuilder + ->setValue( + '[mapTypeId]', + $this->mapTypeIdRenderer->render($map->getMapOption('mapTypeId') ?: MapTypeId::ROADMAP), + false + ) + ->setValues($options); + + return $formatter->renderObjectAssignment($map, $formatter->renderObject('Map', [ + $formatter->renderCall( + $formatter->renderProperty('document', 'getElementById'), + [$formatter->renderEscape($map->getHtmlId())] + ), + $jsonBuilder->build(), + ])); + } + + /** + * @return string + */ + public function renderRequirement() + { + return $this->requirementRenderer->render($this->getFormatter()->renderClass()); + } +} diff --git a/src/Helper/Renderer/MapTypeIdRenderer.php b/src/Helper/Renderer/MapTypeIdRenderer.php new file mode 100644 index 00000000..456828bd --- /dev/null +++ b/src/Helper/Renderer/MapTypeIdRenderer.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer; + +/** + * @author GeLo + */ +class MapTypeIdRenderer extends AbstractRenderer +{ + /** + * @param string $id + * + * @return string + */ + public function render($id) + { + return $this->getFormatter()->renderConstant('MapTypeId', $id); + } +} diff --git a/src/Helper/Renderer/Overlay/AbstractInfoWindowRenderer.php b/src/Helper/Renderer/Overlay/AbstractInfoWindowRenderer.php new file mode 100644 index 00000000..b19ad7df --- /dev/null +++ b/src/Helper/Renderer/Overlay/AbstractInfoWindowRenderer.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Overlay\InfoWindow; + +/** + * @author GeLo + */ +abstract class AbstractInfoWindowRenderer extends AbstractJsonRenderer implements InfoWindowRendererInterface +{ + /** + * {@inheritdoc} + */ + public function render(InfoWindow $infoWindow, $position = true) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder(); + + if ($position) { + $jsonBuilder->setValue('[position]', $infoWindow->getPosition()->getVariable(), false); + } + + if ($infoWindow->hasPixelOffset()) { + $jsonBuilder->setValue('[pixelOffset]', $infoWindow->getPixelOffset()->getVariable(), false); + } + + $jsonBuilder + ->setValue('[content]', $infoWindow->getContent()) + ->setValues($infoWindow->getOptions()); + + return $formatter->renderObjectAssignment($infoWindow, $formatter->renderObject($this->getClass(), [ + $jsonBuilder->build(), + ], $this->getNamespace())); + } + + /** + * @return string + */ + abstract protected function getClass(); + + /** + * @return string|false|null + */ + protected function getNamespace() + { + } +} diff --git a/tests/Controls/ScaleControlStyleTest.php b/src/Helper/Renderer/Overlay/AnimationRenderer.php similarity index 51% rename from tests/Controls/ScaleControlStyleTest.php rename to src/Helper/Renderer/Overlay/AnimationRenderer.php index 382da344..ea45aa63 100644 --- a/tests/Controls/ScaleControlStyleTest.php +++ b/src/Helper/Renderer/Overlay/AnimationRenderer.php @@ -9,21 +9,22 @@ * file that was distributed with this source code. */ -namespace Ivory\Tests\GoogleMap\Controls; +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; -use Ivory\GoogleMap\Controls\ScaleControlStyle; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; /** - * Scale control style test. - * * @author GeLo */ -class ScaleControlStyleTest extends \PHPUnit_Framework_TestCase +class AnimationRenderer extends AbstractRenderer { - public function testScaleControlStyles() + /** + * @param string $animation + * + * @return string + */ + public function render($animation) { - $expected = array(ScaleControlStyle::DEFAULT_); - - $this->assertSame($expected, ScaleControlStyle::getScaleControlStyles()); + return $this->getFormatter()->renderConstant('Animation', $animation); } } diff --git a/src/Helper/Renderer/Overlay/CircleRenderer.php b/src/Helper/Renderer/Overlay/CircleRenderer.php new file mode 100644 index 00000000..3231ad96 --- /dev/null +++ b/src/Helper/Renderer/Overlay/CircleRenderer.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Circle; + +/** + * @author GeLo + */ +class CircleRenderer extends AbstractJsonRenderer +{ + /** + * @param Circle $circle + * @param Map $map + * + * @return string + */ + public function render(Circle $circle, Map $map) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[map]', $map->getVariable(), false) + ->setValue('[center]', $circle->getCenter()->getVariable(), false) + ->setValue('[radius]', $circle->getRadius()) + ->setValues($circle->getOptions()); + + return $formatter->renderObjectAssignment($circle, $formatter->renderObject('Circle', [ + $jsonBuilder->build(), + ])); + } +} diff --git a/src/Helper/Renderer/Overlay/DefaultInfoWindowRenderer.php b/src/Helper/Renderer/Overlay/DefaultInfoWindowRenderer.php new file mode 100644 index 00000000..a3aebb50 --- /dev/null +++ b/src/Helper/Renderer/Overlay/DefaultInfoWindowRenderer.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +/** + * @author GeLo + */ +class DefaultInfoWindowRenderer extends AbstractInfoWindowRenderer +{ + /** + * {@inheritdoc} + */ + protected function getClass() + { + return 'InfoWindow'; + } +} diff --git a/src/Helper/Renderer/Overlay/EncodedPolylineRenderer.php b/src/Helper/Renderer/Overlay/EncodedPolylineRenderer.php new file mode 100644 index 00000000..feda3043 --- /dev/null +++ b/src/Helper/Renderer/Overlay/EncodedPolylineRenderer.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Geometry\EncodingRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class EncodedPolylineRenderer extends AbstractJsonRenderer +{ + /** + * @var EncodingRenderer + */ + private $encodingRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param EncodingRenderer $encodingRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + EncodingRenderer $encodingRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setEncodingRenderer($encodingRenderer); + } + + /** + * @return EncodingRenderer + */ + public function getEncodingRenderer() + { + return $this->encodingRenderer; + } + + /** + * @param EncodingRenderer $encodingRenderer + */ + public function setEncodingRenderer(EncodingRenderer $encodingRenderer) + { + $this->encodingRenderer = $encodingRenderer; + } + + /** + * @param EncodedPolyline $encodedPolyline + * @param Map $map + * + * @return string + */ + public function render(EncodedPolyline $encodedPolyline, Map $map) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[map]', $map->getVariable(), false) + ->setValue('[path]', $this->encodingRenderer->renderDecodePath($encodedPolyline->getValue()), false) + ->setValues($encodedPolyline->getOptions()); + + return $formatter->renderObjectAssignment($encodedPolyline, $formatter->renderObject('Polyline', [ + $jsonBuilder->build(), + ])); + } +} diff --git a/src/Helper/Renderer/Overlay/Extendable/ExtendableRenderer.php b/src/Helper/Renderer/Overlay/Extendable/ExtendableRenderer.php new file mode 100644 index 00000000..bc1e3dfa --- /dev/null +++ b/src/Helper/Renderer/Overlay/Extendable/ExtendableRenderer.php @@ -0,0 +1,115 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class ExtendableRenderer implements ExtendableRendererInterface +{ + /** + * @var ExtendableRendererInterface[] + */ + private $renderers = []; + + /** + * @return bool + */ + public function hasRenderers() + { + return !empty($this->renderers); + } + + /** + * @return ExtendableRendererInterface[] + */ + public function getRenderers() + { + return $this->renderers; + } + + /** + * @param ExtendableRendererInterface[] $renderers + */ + public function setRenderers(array $renderers) + { + $this->renderers = []; + $this->addRenderers($renderers); + } + + /** + * @param ExtendableRendererInterface[] $renderers + */ + public function addRenderers(array $renderers) + { + foreach ($renderers as $name => $renderer) { + $this->setRenderer($name, $renderer); + } + } + + /** + * @param string $name + * + * @return bool + */ + public function hasRenderer($name) + { + return isset($this->renderers[$name]); + } + + /** + * @param string $name + * + * @return ExtendableRendererInterface|null + */ + public function getRenderer($name) + { + return $this->hasRenderer($name) ? $this->renderers[$name] : null; + } + + /** + * @param string $name + * @param ExtendableRendererInterface $renderer + */ + public function setRenderer($name, ExtendableRendererInterface $renderer) + { + $this->renderers[$name] = $renderer; + } + + /** + * @param string $name + */ + public function removeRenderer($name) + { + unset($this->renderers[$name]); + } + + /** + * {@inheritdoc} + */ + public function render(ExtendableInterface $extendable, Bound $bound) + { + $renderer = $this->getRenderer(get_class($extendable)); + + if ($renderer === null) { + throw new \InvalidArgumentException(sprintf( + 'The extendable renderer for "%s" could not be found.', + get_class($extendable) + )); + } + + return $renderer->render($extendable, $bound); + } +} diff --git a/src/Helper/Renderer/Overlay/Extendable/ExtendableRendererInterface.php b/src/Helper/Renderer/Overlay/Extendable/ExtendableRendererInterface.php new file mode 100644 index 00000000..c422e797 --- /dev/null +++ b/src/Helper/Renderer/Overlay/Extendable/ExtendableRendererInterface.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +interface ExtendableRendererInterface +{ + /** + * @param ExtendableInterface $extendable + * @param Bound $bound + * + * @return string + */ + public function render(ExtendableInterface $extendable, Bound $bound); +} diff --git a/src/Helper/Renderer/Overlay/Extendable/PathExtendableRenderer.php b/src/Helper/Renderer/Overlay/Extendable/PathExtendableRenderer.php new file mode 100644 index 00000000..c773ec56 --- /dev/null +++ b/src/Helper/Renderer/Overlay/Extendable/PathExtendableRenderer.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class PathExtendableRenderer extends AbstractRenderer implements ExtendableRendererInterface +{ + /** + * {@inheritdoc} + */ + public function render(ExtendableInterface $extendable, Bound $bound) + { + $formatter = $this->getFormatter(); + + return $formatter->renderCall( + $formatter->renderProperty($formatter->renderObjectCall($extendable, 'getPath'), 'forEach'), + [ + $formatter->renderClosure( + $formatter->renderObjectCall($bound, 'extend', [$variable = 'b']), + [$variable] + ), + ] + ); + } +} diff --git a/src/Helper/Renderer/Overlay/Extendable/PositionExtendableRenderer.php b/src/Helper/Renderer/Overlay/Extendable/PositionExtendableRenderer.php new file mode 100644 index 00000000..ff652be9 --- /dev/null +++ b/src/Helper/Renderer/Overlay/Extendable/PositionExtendableRenderer.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class PositionExtendableRenderer extends AbstractRenderer implements ExtendableRendererInterface +{ + /** + * {@inheritdoc} + */ + public function render(ExtendableInterface $extendable, Bound $bound) + { + $formatter = $this->getFormatter(); + + return $formatter->renderObjectCall($bound, 'extend', [ + $formatter->renderObjectCall($extendable, 'getPosition'), + ]); + } +} diff --git a/src/Helper/Renderer/Overlay/Extendable/UnionExtendableRenderer.php b/src/Helper/Renderer/Overlay/Extendable/UnionExtendableRenderer.php new file mode 100644 index 00000000..f59e995c --- /dev/null +++ b/src/Helper/Renderer/Overlay/Extendable/UnionExtendableRenderer.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class UnionExtendableRenderer extends AbstractRenderer implements ExtendableRendererInterface +{ + /** + * {@inheritdoc} + */ + public function render(ExtendableInterface $extendable, Bound $bound) + { + $formatter = $this->getFormatter(); + + return $formatter->renderObjectCall($bound, 'union', [ + $formatter->renderObjectCall($extendable, 'getBounds'), + ]); + } +} diff --git a/src/Helper/Renderer/Overlay/GroundOverlayRenderer.php b/src/Helper/Renderer/Overlay/GroundOverlayRenderer.php new file mode 100644 index 00000000..703bc35f --- /dev/null +++ b/src/Helper/Renderer/Overlay/GroundOverlayRenderer.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\GroundOverlay; + +/** + * @author GeLo + */ +class GroundOverlayRenderer extends AbstractJsonRenderer +{ + /** + * @param GroundOverlay $groundOverlay + * @param Map $map + * + * @return string + */ + public function render(GroundOverlay $groundOverlay, Map $map) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[map]', $map->getVariable(), false) + ->setValues($groundOverlay->getOptions()); + + return $formatter->renderObjectAssignment($groundOverlay, $formatter->renderObject('GroundOverlay', [ + $formatter->renderEscape($groundOverlay->getUrl()), + $groundOverlay->getBound()->getVariable(), + $jsonBuilder->build(), + ])); + } +} diff --git a/src/Helper/Renderer/Overlay/IconRenderer.php b/src/Helper/Renderer/Overlay/IconRenderer.php new file mode 100644 index 00000000..295f43fb --- /dev/null +++ b/src/Helper/Renderer/Overlay/IconRenderer.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Overlay\Icon; + +/** + * @author GeLo + */ +class IconRenderer extends AbstractJsonRenderer +{ + /** + * @param Icon $icon + * + * @return string + */ + public function render(Icon $icon) + { + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[url]', $icon->getUrl()); + + if ($icon->hasAnchor()) { + $jsonBuilder->setValue('[anchor]', $icon->getAnchor()->getVariable(), false); + } + + if ($icon->hasOrigin()) { + $jsonBuilder->setValue('[origin]', $icon->getOrigin()->getVariable(), false); + } + + if ($icon->hasScaledSize()) { + $jsonBuilder->setValue('[scaledSize]', $icon->getScaledSize()->getVariable(), false); + } + + if ($icon->hasSize()) { + $jsonBuilder->setValue('[size]', $icon->getScaledSize()->getVariable(), false); + } + + return $jsonBuilder->build(); + } +} diff --git a/src/Helper/Renderer/Overlay/InfoBoxRenderer.php b/src/Helper/Renderer/Overlay/InfoBoxRenderer.php new file mode 100644 index 00000000..7086888b --- /dev/null +++ b/src/Helper/Renderer/Overlay/InfoBoxRenderer.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class InfoBoxRenderer extends AbstractInfoWindowRenderer +{ + /** + * @var RequirementRenderer + */ + private $requirementRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param RequirementRenderer $requirementRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + RequirementRenderer $requirementRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setRequirementRenderer($requirementRenderer); + } + + /** + * @return RequirementRenderer + */ + public function getRequirementRenderer() + { + return $this->requirementRenderer; + } + + /** + * @param RequirementRenderer $requirementRenderer + */ + public function setRequirementRenderer(RequirementRenderer $requirementRenderer) + { + $this->requirementRenderer = $requirementRenderer; + } + + /** + * @return string + */ + public function renderSource() + { + return 'https://cdn.rawgit.com/googlemaps/v3-utility-library/master/infobox/src/infobox_packed.js'; + } + + /** + * @return string + */ + public function renderRequirement() + { + return $this->requirementRenderer->render($this->getClass()); + } + + /** + * {@inheritdoc} + */ + protected function getClass() + { + return 'InfoBox'; + } + + /** + * {@inheritdoc} + */ + protected function getNamespace() + { + return false; + } +} diff --git a/src/Helper/Renderer/Overlay/InfoWindowCloseRenderer.php b/src/Helper/Renderer/Overlay/InfoWindowCloseRenderer.php new file mode 100644 index 00000000..9589fdf5 --- /dev/null +++ b/src/Helper/Renderer/Overlay/InfoWindowCloseRenderer.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Overlay\InfoWindow; + +/** + * @author GeLo + */ +class InfoWindowCloseRenderer extends AbstractRenderer +{ + /** + * @param InfoWindow $infoWindow + * + * @return string + */ + public function render(InfoWindow $infoWindow) + { + return $this->getFormatter()->renderObjectCall($infoWindow, 'close'); + } +} diff --git a/src/Helper/Renderer/Overlay/InfoWindowOpenRenderer.php b/src/Helper/Renderer/Overlay/InfoWindowOpenRenderer.php new file mode 100644 index 00000000..2bc604fe --- /dev/null +++ b/src/Helper/Renderer/Overlay/InfoWindowOpenRenderer.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class InfoWindowOpenRenderer extends AbstractRenderer +{ + /** + * @param InfoWindow $infoWindow + * @param Map $map + * @param Marker|null $marker + * + * @return string + */ + public function render(InfoWindow $infoWindow, Map $map, Marker $marker = null) + { + $arguments = [$map->getVariable()]; + + if ($marker !== null) { + $arguments[] = $marker->getVariable(); + } + + return $this->getFormatter()->renderObjectCall($infoWindow, 'open', $arguments); + } +} diff --git a/src/Helper/Renderer/Overlay/InfoWindowRendererInterface.php b/src/Helper/Renderer/Overlay/InfoWindowRendererInterface.php new file mode 100644 index 00000000..28c4cdb0 --- /dev/null +++ b/src/Helper/Renderer/Overlay/InfoWindowRendererInterface.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Overlay\InfoWindow; + +/** + * @author GeLo + */ +interface InfoWindowRendererInterface +{ + /** + * @param InfoWindow $infoWindow + * @param bool $position + * + * @return string + */ + public function render(InfoWindow $infoWindow, $position = true); +} diff --git a/src/Helper/Renderer/Overlay/MarkerClustererRenderer.php b/src/Helper/Renderer/Overlay/MarkerClustererRenderer.php new file mode 100644 index 00000000..b3b0fac0 --- /dev/null +++ b/src/Helper/Renderer/Overlay/MarkerClustererRenderer.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\MarkerCluster; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MarkerClustererRenderer extends AbstractJsonRenderer +{ + /** + * @var RequirementRenderer + */ + private $requirementRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param RequirementRenderer $requirementRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + RequirementRenderer $requirementRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setRequirementRenderer($requirementRenderer); + } + + /** + * @return RequirementRenderer + */ + public function getRequirementRenderer() + { + return $this->requirementRenderer; + } + + /** + * @param RequirementRenderer $requirementRenderer + */ + public function setRequirementRenderer(RequirementRenderer $requirementRenderer) + { + $this->requirementRenderer = $requirementRenderer; + } + + /** + * @param MarkerCluster $markerCluster + * @param Map $map + * @param string $markers + * + * @return string + */ + public function render(MarkerCluster $markerCluster, Map $map, $markers) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValues($markerCluster->getOptions()); + + return $formatter->renderObjectAssignment($markerCluster, $formatter->renderObject('MarkerClusterer', [ + $map->getVariable(), + $markers, + $jsonBuilder->build(), + ], false)); + } + + /** + * @return string + */ + public function renderSource() + { + return 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/src/markerclusterer.js'; + } + + /** + * @return string + */ + public function renderRequirement() + { + return $this->requirementRenderer->render('MarkerClusterer'); + } +} diff --git a/src/Helper/Renderer/Overlay/MarkerRenderer.php b/src/Helper/Renderer/Overlay/MarkerRenderer.php new file mode 100644 index 00000000..ee4fc355 --- /dev/null +++ b/src/Helper/Renderer/Overlay/MarkerRenderer.php @@ -0,0 +1,147 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MarkerRenderer extends AbstractJsonRenderer +{ + /** + * @var AnimationRenderer + */ + private $animationRenderer; + + /** + * @var IconRenderer + */ + private $iconRenderer; + + /** + * @var MarkerShapeRenderer + */ + private $markerShapeRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param AnimationRenderer $animationRenderer + * @param IconRenderer $iconRenderer + * @param MarkerShapeRenderer $markerShapeRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + AnimationRenderer $animationRenderer, + IconRenderer $iconRenderer, + MarkerShapeRenderer $markerShapeRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setAnimationRenderer($animationRenderer); + $this->setIconRenderer($iconRenderer); + $this->setMarkerShapeRenderer($markerShapeRenderer); + } + + /** + * @return AnimationRenderer + */ + public function getAnimationRenderer() + { + return $this->animationRenderer; + } + + /** + * @param AnimationRenderer $animationRenderer + */ + public function setAnimationRenderer(AnimationRenderer $animationRenderer) + { + $this->animationRenderer = $animationRenderer; + } + + /** + * @return IconRenderer + */ + public function getIconRenderer() + { + return $this->iconRenderer; + } + + /** + * @param IconRenderer $iconRenderer + */ + public function setIconRenderer(IconRenderer $iconRenderer) + { + $this->iconRenderer = $iconRenderer; + } + + /** + * @return MarkerShapeRenderer + */ + public function getMarkerShapeRenderer() + { + return $this->markerShapeRenderer; + } + + /** + * @param MarkerShapeRenderer $markerShapeRenderer + */ + public function setMarkerShapeRenderer(MarkerShapeRenderer $markerShapeRenderer) + { + $this->markerShapeRenderer = $markerShapeRenderer; + } + + /** + * @param Marker $marker + * @param Map|null $map + * + * @return string + */ + public function render(Marker $marker, Map $map = null) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[position]', $marker->getPosition()->getVariable(), false); + + if ($map !== null) { + $jsonBuilder->setValue('[map]', $map->getVariable(), false); + } + + if ($marker->hasAnimation()) { + $jsonBuilder->setValue( + '[animation]', + $this->animationRenderer->render($marker->getAnimation()), + false + ); + } + + if ($marker->hasIcon()) { + $jsonBuilder->setValue('[icon]', $this->iconRenderer->render($marker->getIcon()), false); + } + + if ($marker->hasShape()) { + $jsonBuilder->setValue('[shape]', $this->markerShapeRenderer->render($marker->getShape()), false); + } + + $jsonBuilder->setValues($marker->getOptions()); + + return $formatter->renderObjectAssignment($marker, $formatter->renderObject('Marker', [ + $jsonBuilder->build(), + ])); + } +} diff --git a/src/Helper/Renderer/Overlay/MarkerShapeRenderer.php b/src/Helper/Renderer/Overlay/MarkerShapeRenderer.php new file mode 100644 index 00000000..9a45f581 --- /dev/null +++ b/src/Helper/Renderer/Overlay/MarkerShapeRenderer.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Overlay\MarkerShape; + +/** + * @author GeLo + */ +class MarkerShapeRenderer extends AbstractJsonRenderer +{ + /** + * @param MarkerShape $markerShape + * + * @return string + */ + public function render(MarkerShape $markerShape) + { + return $this->getJsonBuilder() + ->setValue('[type]', $markerShape->getType()) + ->setValue('[coords]', $markerShape->getCoordinates()) + ->build(); + } +} diff --git a/src/Helper/Renderer/Overlay/PolygonRenderer.php b/src/Helper/Renderer/Overlay/PolygonRenderer.php new file mode 100644 index 00000000..8dbec9bf --- /dev/null +++ b/src/Helper/Renderer/Overlay/PolygonRenderer.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polygon; + +/** + * @author GeLo + */ +class PolygonRenderer extends AbstractJsonRenderer +{ + /** + * @param Polygon $polygon + * @param Map $map + * + * @return string + */ + public function render(Polygon $polygon, Map $map) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[map]', $map->getVariable(), false) + ->setValue('[paths]', []); + + foreach ($polygon->getCoordinates() as $index => $coordinate) { + $jsonBuilder->setValue('[paths]['.$index.']', $coordinate->getVariable(), false); + } + + $jsonBuilder->setValues($polygon->getOptions()); + + return $formatter->renderObjectAssignment($polygon, $formatter->renderObject('Polygon', [ + $jsonBuilder->build(), + ])); + } +} diff --git a/src/Helper/Renderer/Overlay/PolylineRenderer.php b/src/Helper/Renderer/Overlay/PolylineRenderer.php new file mode 100644 index 00000000..dcdd0575 --- /dev/null +++ b/src/Helper/Renderer/Overlay/PolylineRenderer.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polyline; + +/** + * @author GeLo + */ +class PolylineRenderer extends AbstractJsonRenderer +{ + /** + * @param Polyline $polyline + * @param Map $map + * + * @return string + */ + public function render(Polyline $polyline, Map $map) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[map]', $map->getVariable(), false) + ->setValue('[path]', []); + + foreach ($polyline->getCoordinates() as $index => $coordinate) { + $jsonBuilder->setValue('[path]['.$index.']', $coordinate->getVariable(), false); + } + + $jsonBuilder->setValues($polyline->getOptions()); + + return $formatter->renderObjectAssignment($polyline, $formatter->renderObject('Polyline', [ + $jsonBuilder->build(), + ])); + } +} diff --git a/src/Helper/Renderer/Overlay/RectangleRenderer.php b/src/Helper/Renderer/Overlay/RectangleRenderer.php new file mode 100644 index 00000000..0eede808 --- /dev/null +++ b/src/Helper/Renderer/Overlay/RectangleRenderer.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Rectangle; + +/** + * @author GeLo + */ +class RectangleRenderer extends AbstractJsonRenderer +{ + /** + * @param Rectangle $rectangle + * @param Map $map + * + * @return string + */ + public function render(Rectangle $rectangle, Map $map) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder() + ->setValue('[map]', $map->getVariable(), false) + ->setValue('[bounds]', $rectangle->getBound()->getVariable(), false) + ->setValues($rectangle->getOptions()); + + return $formatter->renderObjectAssignment($rectangle, $formatter->renderObject('Rectangle', [ + $jsonBuilder->build(), + ])); + } +} diff --git a/src/Helper/Renderer/Place/AutocompleteContainerRenderer.php b/src/Helper/Renderer/Place/AutocompleteContainerRenderer.php new file mode 100644 index 00000000..34ebe4f6 --- /dev/null +++ b/src/Helper/Renderer/Place/AutocompleteContainerRenderer.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Place; + +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; + +/** + * @author GeLo + */ +class AutocompleteContainerRenderer extends AbstractJsonRenderer +{ + /** + * @return string + */ + public function render() + { + return $this->getJsonBuilder() + ->setValue('[base][coordinates]', []) + ->setValue('[base][bounds]', []) + ->setValue('[autocomplete]', null) + ->build(); + } +} diff --git a/src/Helper/Renderer/Place/AutocompleteHtmlRenderer.php b/src/Helper/Renderer/Place/AutocompleteHtmlRenderer.php new file mode 100644 index 00000000..5bbaa994 --- /dev/null +++ b/src/Helper/Renderer/Place/AutocompleteHtmlRenderer.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Place; + +use Ivory\GoogleMap\Helper\Renderer\Html\AbstractTagRenderer; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class AutocompleteHtmlRenderer extends AbstractTagRenderer +{ + /** + * @param Autocomplete $autocomplete + * + * @return string + */ + public function render(Autocomplete $autocomplete) + { + $attributes = [ + 'id' => $autocomplete->getHtmlId(), + 'type' => 'text', + 'autocomplete' => 'off', + ]; + + if ($autocomplete->hasValue()) { + $attributes['value'] = $autocomplete->getValue(); + } + + return $this->getTagRenderer()->render('input', null, array_merge( + $attributes, + $autocomplete->getInputAttributes() + )); + } +} diff --git a/src/Helper/Renderer/Place/AutocompleteRenderer.php b/src/Helper/Renderer/Place/AutocompleteRenderer.php new file mode 100644 index 00000000..1dc56cfc --- /dev/null +++ b/src/Helper/Renderer/Place/AutocompleteRenderer.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Place; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Place\Autocomplete; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class AutocompleteRenderer extends AbstractJsonRenderer +{ + /** + * @var RequirementRenderer + */ + private $requirementRenderer; + + /** + * @param Formatter $formatter + * @param JsonBuilder $jsonBuilder + * @param RequirementRenderer $requirementRenderer + */ + public function __construct( + Formatter $formatter, + JsonBuilder $jsonBuilder, + RequirementRenderer $requirementRenderer + ) { + parent::__construct($formatter, $jsonBuilder); + + $this->setRequirementRenderer($requirementRenderer); + } + + /** + * @return RequirementRenderer + */ + public function getRequirementRenderer() + { + return $this->requirementRenderer; + } + + /** + * @param RequirementRenderer $requirementRenderer + */ + public function setRequirementRenderer(RequirementRenderer $requirementRenderer) + { + $this->requirementRenderer = $requirementRenderer; + } + + /** + * @param Autocomplete $autocomplete + * + * @return string + */ + public function render(Autocomplete $autocomplete) + { + $formatter = $this->getFormatter(); + $jsonBuilder = $this->getJsonBuilder(); + + if ($autocomplete->hasTypes()) { + $jsonBuilder->setValue('[types]', $autocomplete->getTypes()); + } + + if ($autocomplete->hasBound()) { + $jsonBuilder->setValue('[bounds]', $autocomplete->getBound()->getVariable(), false); + } + + if ($autocomplete->hasComponentRestrictions()) { + $jsonBuilder->setValue('[componentRestrictions]', $autocomplete->getComponentRestrictions()); + } + + if (!$jsonBuilder->hasValues()) { + $jsonBuilder->setJsonEncodeOptions(JSON_FORCE_OBJECT); + } + + return $formatter->renderObjectAssignment($autocomplete, $formatter->renderObject('Autocomplete', [ + $formatter->renderCall($formatter->renderProperty('document', 'getElementById'), [ + $formatter->renderEscape($autocomplete->getHtmlId()), + ]), + $jsonBuilder->build(), + ], $formatter->renderClass('places'))); + } + + /** + * @return string + */ + public function renderRequirement() + { + return $this->requirementRenderer->render($this->getFormatter()->renderClass('places')); + } +} diff --git a/src/Helper/Renderer/Utility/CallbackRenderer.php b/src/Helper/Renderer/Utility/CallbackRenderer.php new file mode 100644 index 00000000..ce9075f2 --- /dev/null +++ b/src/Helper/Renderer/Utility/CallbackRenderer.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class CallbackRenderer extends AbstractRenderer +{ + /** + * @param string $name + * + * @return string + */ + public function render($name) + { + return 'ivory_google_map_'.$name; + } +} diff --git a/src/Helper/Renderer/Utility/ObjectToArrayRenderer.php b/src/Helper/Renderer/Utility/ObjectToArrayRenderer.php new file mode 100644 index 00000000..0d4f74d4 --- /dev/null +++ b/src/Helper/Renderer/Utility/ObjectToArrayRenderer.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class ObjectToArrayRenderer extends AbstractRenderer +{ + /** + * @param string|null $arrayVariable + * @param string|null $objectVariable + * @param string|null $keyVariable + * + * @return string + */ + public function render($arrayVariable = null, $objectVariable = null, $keyVariable = null) + { + $formatter = $this->getFormatter(); + + $arrayVariable = $arrayVariable ?: 'a'; + $objectVariable = $objectVariable ?: 'o'; + $keyVariable = $keyVariable ?: 'k'; + + return $formatter->renderClosure($formatter->renderLines([ + $formatter->renderAssignment('var '.$arrayVariable, '[]', true), + $formatter->renderStatement( + 'for', + $formatter->renderCall( + $formatter->renderProperty($arrayVariable, 'push'), + [$objectVariable.'['.$keyVariable.']'], + true + ), + 'var '.$keyVariable.' in '.$objectVariable, + null, + false + ), + $formatter->renderCode('return '.$arrayVariable, true, false), + ], true, false), [$objectVariable]); + } +} diff --git a/src/Helper/Renderer/Utility/RequirementLoaderRenderer.php b/src/Helper/Renderer/Utility/RequirementLoaderRenderer.php new file mode 100644 index 00000000..97c8418e --- /dev/null +++ b/src/Helper/Renderer/Utility/RequirementLoaderRenderer.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class RequirementLoaderRenderer extends AbstractRenderer +{ + /** + * @param string $name + * @param string|null $intervalVariable + * @param string|null $callbackVariable + * @param string|null $requirementVariable + * @param int $interval + * @param bool $newLine + * + * @return string + */ + public function render( + $name, + $intervalVariable = null, + $callbackVariable = null, + $requirementVariable = null, + $interval = 10, + $newLine = true + ) { + $formatter = $this->getFormatter(); + + $intervalVariable = $intervalVariable ?: 'i'; + $callbackVariable = $callbackVariable ?: 'c'; + $requirementVariable = $requirementVariable ?: 'r'; + + return $formatter->renderClosure($this->renderRequirement( + $intervalVariable, + $callbackVariable, + $requirementVariable, + $formatter->renderStatement('else', $formatter->renderAssignment( + 'var '.$intervalVariable, + $formatter->renderCall('setInterval', [ + $formatter->renderClosure($this->renderRequirement( + $intervalVariable, + $callbackVariable, + $requirementVariable + )), + $interval, + ], true) + ), null, null, false) + ), [$callbackVariable, $requirementVariable], $name, true, $newLine); + } + + /** + * @param string $intervalVariable + * @param string $callbackVariable + * @param string $requirementVariable + * @param string|null $nextStatement + * + * @return string + */ + private function renderRequirement( + $intervalVariable, + $callbackVariable, + $requirementVariable, + $nextStatement = null + ) { + $formatter = $this->getFormatter(); + $codes = [$formatter->renderCall($callbackVariable, [], true)]; + + if (empty($nextStatement)) { + array_unshift($codes, $formatter->renderCall('clearInterval', [$intervalVariable], true)); + } + + return $formatter->renderStatement( + 'if', + $formatter->renderLines($codes, true, false), + $formatter->renderCall($requirementVariable), + $nextStatement, + false + ); + } +} diff --git a/src/Helper/Renderer/Utility/RequirementRenderer.php b/src/Helper/Renderer/Utility/RequirementRenderer.php new file mode 100644 index 00000000..899eb20e --- /dev/null +++ b/src/Helper/Renderer/Utility/RequirementRenderer.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class RequirementRenderer extends AbstractRenderer +{ + /** + * @param string $class + * + * @return string + */ + public function render($class) + { + $separator = $this->getFormatter()->renderSeparator(); + + return 'typeof '.$class.$separator.'!=='.$separator.'typeof undefined'; + } +} diff --git a/src/Helper/Renderer/Utility/SourceRenderer.php b/src/Helper/Renderer/Utility/SourceRenderer.php new file mode 100644 index 00000000..70659724 --- /dev/null +++ b/src/Helper/Renderer/Utility/SourceRenderer.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class SourceRenderer extends AbstractRenderer +{ + /** + * @param string $name + * @param string $source + * @param string|null $variable + * @param bool $newLine + * + * @return string + */ + public function render($name, $source = null, $variable = null, $newLine = true) + { + $formatter = $this->getFormatter(); + $source = $source ?: 'src'; + $variable = $variable ?: 'script'; + + return $formatter->renderClosure($formatter->renderLines([ + $formatter->renderAssignment( + 'var '.$variable, + $formatter->renderCall( + $formatter->renderProperty('document', 'createElement'), + [$formatter->renderEscape('script')] + ), + true + ), + $formatter->renderAssignment( + $formatter->renderProperty($variable, 'type'), + $formatter->renderEscape('text/javascript'), + true + ), + $formatter->renderAssignment( + $formatter->renderProperty($variable, 'async'), + $formatter->renderEscape(true), + true + ), + $formatter->renderAssignment( + $formatter->renderProperty($variable, 'src'), + $source, + true + ), + $formatter->renderCall( + $formatter->renderProperty( + $formatter->renderCall( + $formatter->renderProperty('document', 'getElementsByTagName'), + [$formatter->renderEscape('head')] + ).'[0]', + 'appendChild' + ), + [$variable], + true + ), + ], true, false), [$source], $name, true, $newLine); + } +} diff --git a/src/Helper/Subscriber/AbstractDelegateSubscriber.php b/src/Helper/Subscriber/AbstractDelegateSubscriber.php new file mode 100644 index 00000000..6573ffce --- /dev/null +++ b/src/Helper/Subscriber/AbstractDelegateSubscriber.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; + +/** + * @author GeLo + */ +abstract class AbstractDelegateSubscriber extends AbstractSubscriber implements DelegateSubscriberInterface +{ + /** + * @param Event $event + * @param string $eventName + * @param EventDispatcherInterface $eventDispatcher + */ + public function handle(Event $event, $eventName, EventDispatcherInterface $eventDispatcher) + { + $delegates = static::getDelegatedSubscribedEvents(); + + if (isset($delegates[$eventName])) { + foreach ($delegates[$eventName] as $delegate) { + $eventDispatcher->dispatch($delegate, $event); + } + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + $events = []; + + foreach (array_keys(static::getDelegatedSubscribedEvents()) as $event) { + $events[$event] = 'handle'; + } + + return $events; + } +} diff --git a/src/Helper/Subscriber/AbstractSubscriber.php b/src/Helper/Subscriber/AbstractSubscriber.php new file mode 100644 index 00000000..3b737163 --- /dev/null +++ b/src/Helper/Subscriber/AbstractSubscriber.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * @author GeLo + */ +abstract class AbstractSubscriber implements EventSubscriberInterface +{ + /** + * @var Formatter + */ + private $formatter; + + /** + * @param Formatter $formatter + */ + public function __construct(Formatter $formatter) + { + $this->formatter = $formatter; + } + + /** + * @return Formatter + */ + public function getFormatter() + { + return $this->formatter; + } + + /** + * @param Formatter $formatter + */ + public function setFormatter(Formatter $formatter) + { + $this->formatter = $formatter; + } +} diff --git a/src/Helper/Subscriber/ApiJavascriptSubscriber.php b/src/Helper/Subscriber/ApiJavascriptSubscriber.php new file mode 100644 index 00000000..23f400be --- /dev/null +++ b/src/Helper/Subscriber/ApiJavascriptSubscriber.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\ApiEvent; +use Ivory\GoogleMap\Helper\Event\ApiEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\ApiRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\JavascriptTagRenderer; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; + +/** + * @author GeLo + */ +class ApiJavascriptSubscriber extends AbstractDelegateSubscriber +{ + /** + * @var ApiRenderer + */ + private $apiRenderer; + + /** + * @var JavascriptTagRenderer + */ + private $javascriptTagRenderer; + + /** + * @param Formatter $formatter + * @param ApiRenderer $apiRenderer + * @param JavascriptTagRenderer $javascriptTagRenderer + */ + public function __construct( + Formatter $formatter, + ApiRenderer $apiRenderer, + JavascriptTagRenderer $javascriptTagRenderer + ) { + parent::__construct($formatter); + + $this->setApiRenderer($apiRenderer); + $this->setJavascriptTagRenderer($javascriptTagRenderer); + } + + /** + * @return ApiRenderer + */ + public function getApiRenderer() + { + return $this->apiRenderer; + } + + /** + * @param ApiRenderer $apiRenderer + */ + public function setApiRenderer(ApiRenderer $apiRenderer) + { + $this->apiRenderer = $apiRenderer; + } + + /** + * @return JavascriptTagRenderer + */ + public function getJavascriptTagRenderer() + { + return $this->javascriptTagRenderer; + } + + /** + * @param JavascriptTagRenderer $javascriptTagRenderer + */ + public function setJavascriptTagRenderer(JavascriptTagRenderer $javascriptTagRenderer) + { + $this->javascriptTagRenderer = $javascriptTagRenderer; + } + + /** + * {@inheritdoc} + */ + public function handle(Event $event, $eventName, EventDispatcherInterface $eventDispatcher) + { + parent::handle($event, $eventName, $eventDispatcher); + + if ($event instanceof ApiEvent) { + $this->handleApi($event); + } + } + + /** + * @return string[][] + */ + public static function getDelegatedSubscribedEvents() + { + return [ + ApiEvents::JAVASCRIPT => [ + ApiEvents::JAVASCRIPT_MAP, + ApiEvents::JAVASCRIPT_AUTOCOMPLETE, + ], + ]; + } + + /** + * @param ApiEvent $event + */ + private function handleApi(ApiEvent $event) + { + $event->setCode($this->javascriptTagRenderer->render($this->apiRenderer->render( + $event->getLanguage(), + $event->getCallbacks(), + $event->getRequirements(), + $event->getSources(), + $event->getLibraries() + ))); + } +} diff --git a/src/Helper/Subscriber/Base/BaseSubscriber.php b/src/Helper/Subscriber/Base/BaseSubscriber.php new file mode 100644 index 00000000..76547d2b --- /dev/null +++ b/src/Helper/Subscriber/Base/BaseSubscriber.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Base; + +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Subscriber\AbstractDelegateSubscriber; + +/** + * @author GeLo + */ +class BaseSubscriber extends AbstractDelegateSubscriber +{ + /** + * {@inheritdoc} + */ + public static function getDelegatedSubscribedEvents() + { + return [ + MapEvents::JAVASCRIPT_BASE => [ + MapEvents::JAVASCRIPT_BASE_COORDINATE, + MapEvents::JAVASCRIPT_BASE_BOUND, + MapEvents::JAVASCRIPT_BASE_POINT, + MapEvents::JAVASCRIPT_BASE_SIZE, + ], + ]; + } +} diff --git a/src/Helper/Subscriber/Base/BoundSubscriber.php b/src/Helper/Subscriber/Base/BoundSubscriber.php new file mode 100644 index 00000000..5331812e --- /dev/null +++ b/src/Helper/Subscriber/Base/BoundSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Base; + +use Ivory\GoogleMap\Helper\Collector\Base\BoundCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Base\BoundRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class BoundSubscriber extends AbstractSubscriber +{ + /** + * @var BoundCollector + */ + private $boundCollector; + + /** + * @var BoundRenderer + */ + private $boundRenderer; + + /** + * @param Formatter $formatter + * @param BoundCollector $boundCollector + * @param BoundRenderer $boundRenderer + */ + public function __construct( + Formatter $formatter, + BoundCollector $boundCollector, + BoundRenderer $boundRenderer + ) { + parent::__construct($formatter); + + $this->setBoundCollector($boundCollector); + $this->setBoundRenderer($boundRenderer); + } + + /** + * @return BoundCollector + */ + public function getBoundCollector() + { + return $this->boundCollector; + } + + /** + * @param BoundCollector $boundCollector + */ + public function setBoundCollector(BoundCollector $boundCollector) + { + $this->boundCollector = $boundCollector; + } + + /** + * @return BoundRenderer + */ + public function getBoundRenderer() + { + return $this->boundRenderer; + } + + /** + * @param BoundRenderer $boundRenderer + */ + public function setBoundRenderer(BoundRenderer $boundRenderer) + { + $this->boundRenderer = $boundRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->boundCollector->collect($map) as $bound) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->boundRenderer->render($bound), + 'base.bounds', + $bound + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_BASE_BOUND => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Base/CoordinateSubscriber.php b/src/Helper/Subscriber/Base/CoordinateSubscriber.php new file mode 100644 index 00000000..67865fdb --- /dev/null +++ b/src/Helper/Subscriber/Base/CoordinateSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Base; + +use Ivory\GoogleMap\Helper\Collector\Base\CoordinateCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Base\CoordinateRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class CoordinateSubscriber extends AbstractSubscriber +{ + /** + * @var CoordinateCollector + */ + private $coordinateCollector; + + /** + * @var CoordinateRenderer + */ + private $coordinateRenderer; + + /** + * @param Formatter $formatter + * @param CoordinateCollector $coordinateCollector + * @param CoordinateRenderer $coordinateRenderer + */ + public function __construct( + Formatter $formatter, + CoordinateCollector $coordinateCollector, + CoordinateRenderer $coordinateRenderer + ) { + parent::__construct($formatter); + + $this->setCoordinateCollector($coordinateCollector); + $this->setCoordinateRenderer($coordinateRenderer); + } + + /** + * @return CoordinateCollector + */ + public function getCoordinateCollector() + { + return $this->coordinateCollector; + } + + /** + * @param CoordinateCollector $coordinateCollector + */ + public function setCoordinateCollector(CoordinateCollector $coordinateCollector) + { + $this->coordinateCollector = $coordinateCollector; + } + + /** + * @return CoordinateRenderer + */ + public function getCoordinateRenderer() + { + return $this->coordinateRenderer; + } + + /** + * @param CoordinateRenderer $coordinateRenderer + */ + public function setCoordinateRenderer(CoordinateRenderer $coordinateRenderer) + { + $this->coordinateRenderer = $coordinateRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->coordinateCollector->collect($map) as $coordinate) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->coordinateRenderer->render($coordinate), + 'base.coordinates', + $coordinate + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_BASE_COORDINATE => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Base/PointSubscriber.php b/src/Helper/Subscriber/Base/PointSubscriber.php new file mode 100644 index 00000000..2dfc889c --- /dev/null +++ b/src/Helper/Subscriber/Base/PointSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Base; + +use Ivory\GoogleMap\Helper\Collector\Base\PointCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Base\PointRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class PointSubscriber extends AbstractSubscriber +{ + /** + * @var PointCollector + */ + private $pointCollector; + + /** + * @var PointRenderer + */ + private $pointRenderer; + + /** + * @param Formatter $formatter + * @param PointCollector $pointCollector + * @param PointRenderer $pointRenderer + */ + public function __construct( + Formatter $formatter, + PointCollector $pointCollector, + PointRenderer $pointRenderer + ) { + parent::__construct($formatter); + + $this->setPointCollector($pointCollector); + $this->setPointRenderer($pointRenderer); + } + + /** + * @return PointCollector + */ + public function getPointCollector() + { + return $this->pointCollector; + } + + /** + * @param PointCollector $pointCollector + */ + public function setPointCollector(PointCollector $pointCollector) + { + $this->pointCollector = $pointCollector; + } + + /** + * @return PointRenderer + */ + public function getPointRenderer() + { + return $this->pointRenderer; + } + + /** + * @param PointRenderer $pointRenderer + */ + public function setPointRenderer(PointRenderer $pointRenderer) + { + $this->pointRenderer = $pointRenderer; + } + + /*** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->pointCollector->collect($map) as $point) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->pointRenderer->render($point), + 'base.points', + $point + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_BASE_POINT => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Base/SizeSubscriber.php b/src/Helper/Subscriber/Base/SizeSubscriber.php new file mode 100644 index 00000000..c24f37d6 --- /dev/null +++ b/src/Helper/Subscriber/Base/SizeSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Base; + +use Ivory\GoogleMap\Helper\Collector\Base\SizeCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Base\SizeRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class SizeSubscriber extends AbstractSubscriber +{ + /** + * @var SizeCollector + */ + private $sizeCollector; + + /** + * @var SizeRenderer + */ + private $sizeRenderer; + + /** + * @param Formatter $formatter + * @param SizeCollector $sizeCollector + * @param SizeRenderer $sizeRenderer + */ + public function __construct( + Formatter $formatter, + SizeCollector $sizeCollector, + SizeRenderer $sizeRenderer + ) { + parent::__construct($formatter); + + $this->setSizeCollector($sizeCollector); + $this->setSizeRenderer($sizeRenderer); + } + + /** + * @return SizeCollector + */ + public function getSizeCollector() + { + return $this->sizeCollector; + } + + /** + * @param SizeCollector $sizeCollector + */ + public function setSizeCollector(SizeCollector $sizeCollector) + { + $this->sizeCollector = $sizeCollector; + } + + /** + * @return SizeRenderer + */ + public function getSizeRenderer() + { + return $this->sizeRenderer; + } + + /** + * @param SizeRenderer $sizeRenderer + */ + public function setSizeRenderer(SizeRenderer $sizeRenderer) + { + $this->sizeRenderer = $sizeRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->sizeCollector->collect($map) as $size) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->sizeRenderer->render($size), + 'base.sizes', + $size + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_BASE_SIZE => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/DelegateSubscriberInterface.php b/src/Helper/Subscriber/DelegateSubscriberInterface.php new file mode 100644 index 00000000..50df98ee --- /dev/null +++ b/src/Helper/Subscriber/DelegateSubscriberInterface.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * @author GeLo + */ +interface DelegateSubscriberInterface extends EventSubscriberInterface +{ + /** + * @return string[][] + */ + public static function getDelegatedSubscribedEvents(); +} diff --git a/src/Helper/Subscriber/Event/DomEventOnceSubscriber.php b/src/Helper/Subscriber/Event/DomEventOnceSubscriber.php new file mode 100644 index 00000000..4fa2352b --- /dev/null +++ b/src/Helper/Subscriber/Event/DomEventOnceSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Event; + +use Ivory\GoogleMap\Helper\Collector\Event\DomEventOnceCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\DomEventOnceRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class DomEventOnceSubscriber extends AbstractSubscriber +{ + /** + * @var DomEventOnceCollector + */ + private $domEventOnceCollector; + + /** + * @var DomEventOnceRenderer + */ + private $domEventOnceRenderer; + + /** + * @param Formatter $formatter + * @param DomEventOnceCollector $domEventOnceCollector + * @param DomEventOnceRenderer $domEventOnceRenderer + */ + public function __construct( + Formatter $formatter, + DomEventOnceCollector $domEventOnceCollector, + DomEventOnceRenderer $domEventOnceRenderer + ) { + parent::__construct($formatter); + + $this->setDomEventOnceCollector($domEventOnceCollector); + $this->setDomEventOnceRenderer($domEventOnceRenderer); + } + + /** + * @return DomEventOnceCollector + */ + public function getDomEventOnceCollector() + { + return $this->domEventOnceCollector; + } + + /** + * @param DomEventOnceCollector $domEventOnceCollector + */ + public function setDomEventOnceCollector(DomEventOnceCollector $domEventOnceCollector) + { + $this->domEventOnceCollector = $domEventOnceCollector; + } + + /** + * @return DomEventOnceRenderer + */ + public function getDomEventOnceRenderer() + { + return $this->domEventOnceRenderer; + } + + /** + * @param DomEventOnceRenderer $domEventOnceRenderer + */ + public function setDomEventOnceRenderer(DomEventOnceRenderer $domEventOnceRenderer) + { + $this->domEventOnceRenderer = $domEventOnceRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->domEventOnceCollector->collect($map) as $domEventOnce) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->domEventOnceRenderer->render($domEventOnce), + 'events.dom_events_once', + $domEventOnce + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_EVENT_DOM_EVENT_ONCE => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Event/DomEventSubscriber.php b/src/Helper/Subscriber/Event/DomEventSubscriber.php new file mode 100644 index 00000000..dfe8a729 --- /dev/null +++ b/src/Helper/Subscriber/Event/DomEventSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Event; + +use Ivory\GoogleMap\Helper\Collector\Event\DomEventCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\DomEventRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class DomEventSubscriber extends AbstractSubscriber +{ + /** + * @var DomEventCollector + */ + private $domEventCollector; + + /** + * @var DomEventRenderer + */ + private $domEventRenderer; + + /** + * @param Formatter $formatter + * @param DomEventCollector $domEventCollector + * @param DomEventRenderer $domEventRenderer + */ + public function __construct( + Formatter $formatter, + DomEventCollector $domEventCollector, + DomEventRenderer $domEventRenderer + ) { + parent::__construct($formatter); + + $this->setDomEventCollector($domEventCollector); + $this->setDomEventRenderer($domEventRenderer); + } + + /** + * @return DomEventCollector + */ + public function getDomEventCollector() + { + return $this->domEventCollector; + } + + /** + * @param DomEventCollector $domEventCollector + */ + public function setDomEventCollector(DomEventCollector $domEventCollector) + { + $this->domEventCollector = $domEventCollector; + } + + /** + * @return DomEventRenderer + */ + public function getDomEventRenderer() + { + return $this->domEventRenderer; + } + + /** + * @param DomEventRenderer $domEventRenderer + */ + public function setDomEventRenderer(DomEventRenderer $domEventRenderer) + { + $this->domEventRenderer = $domEventRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->domEventCollector->collect($map) as $domEvent) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->domEventRenderer->render($domEvent), + 'events.dom_events', + $domEvent + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_EVENT_DOM_EVENT => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Event/EventOnceSubscriber.php b/src/Helper/Subscriber/Event/EventOnceSubscriber.php new file mode 100644 index 00000000..99305a02 --- /dev/null +++ b/src/Helper/Subscriber/Event/EventOnceSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Event; + +use Ivory\GoogleMap\Helper\Collector\Event\EventOnceCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\EventOnceRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class EventOnceSubscriber extends AbstractSubscriber +{ + /** + * @var EventOnceCollector + */ + private $eventOnceCollector; + + /** + * @var EventOnceRenderer + */ + private $eventOnceRenderer; + + /** + * @param Formatter $formatter + * @param EventOnceCollector $eventOnceCollector + * @param EventOnceRenderer $eventOnceRenderer + */ + public function __construct( + Formatter $formatter, + EventOnceCollector $eventOnceCollector, + EventOnceRenderer $eventOnceRenderer + ) { + parent::__construct($formatter); + + $this->setEventOnceCollector($eventOnceCollector); + $this->setEventOnceRenderer($eventOnceRenderer); + } + + /** + * @return EventOnceCollector + */ + public function getEventOnceCollector() + { + return $this->eventOnceCollector; + } + + /** + * @param EventOnceCollector $eventOnceCollector + */ + public function setEventOnceCollector(EventOnceCollector $eventOnceCollector) + { + $this->eventOnceCollector = $eventOnceCollector; + } + + /** + * @return EventOnceRenderer + */ + public function getEventOnceRenderer() + { + return $this->eventOnceRenderer; + } + + /** + * @param EventOnceRenderer $eventOnceRenderer + */ + public function setEventOnceRenderer(EventOnceRenderer $eventOnceRenderer) + { + $this->eventOnceRenderer = $eventOnceRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->eventOnceCollector->collect($map) as $eventOnce) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->eventOnceRenderer->render($eventOnce), + 'events.events_once', + $eventOnce + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_EVENT_EVENT_ONCE => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Event/EventSubscriber.php b/src/Helper/Subscriber/Event/EventSubscriber.php new file mode 100644 index 00000000..e31d2f68 --- /dev/null +++ b/src/Helper/Subscriber/Event/EventSubscriber.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Event; + +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Subscriber\AbstractDelegateSubscriber; + +/** + * @author GeLo + */ +class EventSubscriber extends AbstractDelegateSubscriber +{ + /** + * {@inheritdoc} + */ + public static function getDelegatedSubscribedEvents() + { + return [ + MapEvents::JAVASCRIPT_EVENT => [ + MapEvents::JAVASCRIPT_EVENT_DOM_EVENT, + MapEvents::JAVASCRIPT_EVENT_DOM_EVENT_ONCE, + MapEvents::JAVASCRIPT_EVENT_EVENT, + MapEvents::JAVASCRIPT_EVENT_EVENT_ONCE, + ], + ]; + } +} diff --git a/src/Helper/Subscriber/Event/SimpleEventSubscriber.php b/src/Helper/Subscriber/Event/SimpleEventSubscriber.php new file mode 100644 index 00000000..e427f59c --- /dev/null +++ b/src/Helper/Subscriber/Event/SimpleEventSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Event; + +use Ivory\GoogleMap\Helper\Collector\Event\EventCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\EventRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class SimpleEventSubscriber extends AbstractSubscriber +{ + /** + * @var EventCollector + */ + private $eventCollector; + + /** + * @var EventRenderer + */ + private $eventRenderer; + + /** + * @param Formatter $formatter + * @param EventCollector $eventCollector + * @param EventRenderer $eventRenderer + */ + public function __construct( + Formatter $formatter, + EventCollector $eventCollector, + EventRenderer $eventRenderer + ) { + parent::__construct($formatter); + + $this->setEventCollector($eventCollector); + $this->setEventRenderer($eventRenderer); + } + + /** + * @return EventCollector + */ + public function getEventCollector() + { + return $this->eventCollector; + } + + /** + * @param EventCollector $eventCollector + */ + public function setEventCollector(EventCollector $eventCollector) + { + $this->eventCollector = $eventCollector; + } + + /** + * @return EventRenderer + */ + public function getEventRenderer() + { + return $this->eventRenderer; + } + + /** + * @param EventRenderer $eventRenderer + */ + public function setEventRenderer(EventRenderer $eventRenderer) + { + $this->eventRenderer = $eventRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->eventCollector->collect($map) as $rawEvent) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->eventRenderer->render($rawEvent), + 'events.events', + $rawEvent + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_EVENT_EVENT => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Layer/KmlLayerSubscriber.php b/src/Helper/Subscriber/Layer/KmlLayerSubscriber.php new file mode 100644 index 00000000..bb42f83b --- /dev/null +++ b/src/Helper/Subscriber/Layer/KmlLayerSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Layer; + +use Ivory\GoogleMap\Helper\Collector\Layer\KmlLayerCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Layer\KmlLayerRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class KmlLayerSubscriber extends AbstractSubscriber +{ + /** + * @var KmlLayerCollector + */ + private $kmlLayerCollector; + + /** + * @var KmlLayerRenderer + */ + private $kmlLayerRenderer; + + /** + * @param Formatter $formatter + * @param KmlLayerCollector $kmlLayerCollector + * @param KmlLayerRenderer $kmlLayerRenderer + */ + public function __construct( + Formatter $formatter, + KmlLayerCollector $kmlLayerCollector, + KmlLayerRenderer $kmlLayerRenderer + ) { + parent::__construct($formatter); + + $this->setKmlLayerCollector($kmlLayerCollector); + $this->setKmlLayerRenderer($kmlLayerRenderer); + } + + /** + * @return KmlLayerCollector + */ + public function getKmlLayerCollector() + { + return $this->kmlLayerCollector; + } + + /** + * @param KmlLayerCollector $kmlLayerCollector + */ + public function setKmlLayerCollector(KmlLayerCollector $kmlLayerCollector) + { + $this->kmlLayerCollector = $kmlLayerCollector; + } + + /** + * @return KmlLayerRenderer + */ + public function getKmlLayerRenderer() + { + return $this->kmlLayerRenderer; + } + + /** + * @param KmlLayerRenderer $kmlLayerRenderer + */ + public function setKmlLayerRenderer(KmlLayerRenderer $kmlLayerRenderer) + { + $this->kmlLayerRenderer = $kmlLayerRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->kmlLayerCollector->collect($map) as $kmlLayer) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->kmlLayerRenderer->render($kmlLayer, $map), + 'layers.kml_layers', + $kmlLayer + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_LAYER_KML_LAYER => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Layer/LayerSubscriber.php b/src/Helper/Subscriber/Layer/LayerSubscriber.php new file mode 100644 index 00000000..4f6232ba --- /dev/null +++ b/src/Helper/Subscriber/Layer/LayerSubscriber.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Layer; + +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Subscriber\AbstractDelegateSubscriber; + +/** + * @author GeLo + */ +class LayerSubscriber extends AbstractDelegateSubscriber +{ + /** + * {@inheritdoc} + */ + public static function getDelegatedSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_LAYER => [MapEvents::JAVASCRIPT_LAYER_KML_LAYER]]; + } +} diff --git a/src/Helper/Subscriber/MapBoundSubscriber.php b/src/Helper/Subscriber/MapBoundSubscriber.php new file mode 100644 index 00000000..ae37372e --- /dev/null +++ b/src/Helper/Subscriber/MapBoundSubscriber.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\MapBoundRenderer; + +/** + * @author GeLo + */ +class MapBoundSubscriber extends AbstractSubscriber +{ + /** + * @var MapBoundRenderer + */ + private $mapBoundRenderer; + + /** + * @param Formatter $formatter + * @param MapBoundRenderer $mapBoundRenderer + */ + public function __construct(Formatter $formatter, MapBoundRenderer $mapBoundRenderer) + { + parent::__construct($formatter); + + $this->setMapBoundRenderer($mapBoundRenderer); + } + + /** + * @return MapBoundRenderer + */ + public function getMapBoundRenderer() + { + return $this->mapBoundRenderer; + } + + /** + * @param MapBoundRenderer $mapBoundRenderer + */ + public function setMapBoundRenderer(MapBoundRenderer $mapBoundRenderer) + { + $this->mapBoundRenderer = $mapBoundRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $map = $event->getMap(); + + if ($map->isAutoZoom()) { + $event->addCode($this->getFormatter()->renderCode($this->mapBoundRenderer->render($map))); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_FINISH => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/MapCenterSubscriber.php b/src/Helper/Subscriber/MapCenterSubscriber.php new file mode 100644 index 00000000..bc3b9f46 --- /dev/null +++ b/src/Helper/Subscriber/MapCenterSubscriber.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\MapCenterRenderer; + +/** + * @author GeLo + */ +class MapCenterSubscriber extends AbstractSubscriber +{ + /** + * @var MapCenterRenderer + */ + private $mapCenterRenderer; + + /** + * @param Formatter $formatter + * @param MapCenterRenderer $mapCenterRenderer + */ + public function __construct(Formatter $formatter, MapCenterRenderer $mapCenterRenderer) + { + parent::__construct($formatter); + + $this->setMapCenterRenderer($mapCenterRenderer); + } + + /** + * @return MapCenterRenderer + */ + public function getMapCenterRenderer() + { + return $this->mapCenterRenderer; + } + + /** + * @param MapCenterRenderer $mapCenterRenderer + */ + public function setMapCenterRenderer(MapCenterRenderer $mapCenterRenderer) + { + $this->mapCenterRenderer = $mapCenterRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $map = $event->getMap(); + + if (!$map->isAutoZoom()) { + $event->addCode($this->getFormatter()->renderCode($this->mapCenterRenderer->render($map))); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_FINISH => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/MapContainerSubscriber.php b/src/Helper/Subscriber/MapContainerSubscriber.php new file mode 100644 index 00000000..715d7229 --- /dev/null +++ b/src/Helper/Subscriber/MapContainerSubscriber.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\MapContainerRenderer; + +/** + * @author GeLo + */ +class MapContainerSubscriber extends AbstractSubscriber +{ + /** + * @var MapContainerRenderer + */ + private $containerRenderer; + + /** + * @param Formatter $formatter + * @param MapContainerRenderer $containerRenderer + */ + public function __construct(Formatter $formatter, MapContainerRenderer $containerRenderer) + { + parent::__construct($formatter); + + $this->setContainerRenderer($containerRenderer); + } + + /** + * @return MapContainerRenderer + */ + public function getContainerRenderer() + { + return $this->containerRenderer; + } + + /** + * @param MapContainerRenderer $containerRenderer + */ + public function setContainerRenderer(MapContainerRenderer $containerRenderer) + { + $this->containerRenderer = $containerRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->containerRenderer->render() + )); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_INIT_CONTAINER => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/MapHtmlSubscriber.php b/src/Helper/Subscriber/MapHtmlSubscriber.php new file mode 100644 index 00000000..c2b5227c --- /dev/null +++ b/src/Helper/Subscriber/MapHtmlSubscriber.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\MapHtmlRenderer; + +/** + * @author GeLo + */ +class MapHtmlSubscriber extends AbstractSubscriber +{ + /** + * @var MapHtmlRenderer + */ + private $mapHtmlRenderer; + + /** + * @param Formatter $formatter + * @param MapHtmlRenderer $mapHtmlRenderer + */ + public function __construct(Formatter $formatter, MapHtmlRenderer $mapHtmlRenderer) + { + parent::__construct($formatter); + + $this->setMapHtmlRenderer($mapHtmlRenderer); + } + + /** + * @return MapHtmlRenderer + */ + public function getMapHtmlRenderer() + { + return $this->mapHtmlRenderer; + } + + /** + * @param MapHtmlRenderer $mapHtmlRenderer + */ + public function setMapHtmlRenderer(MapHtmlRenderer $mapHtmlRenderer) + { + $this->mapHtmlRenderer = $mapHtmlRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $event->addCode($this->mapHtmlRenderer->render($event->getMap())); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::HTML => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/MapInitSubscriber.php b/src/Helper/Subscriber/MapInitSubscriber.php new file mode 100644 index 00000000..53e876dc --- /dev/null +++ b/src/Helper/Subscriber/MapInitSubscriber.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\MapEvents; + +/** + * @author GeLo + */ +class MapInitSubscriber extends AbstractDelegateSubscriber +{ + /** + * {@inheritdoc} + */ + public static function getDelegatedSubscribedEvents() + { + return [ + MapEvents::JAVASCRIPT_INIT => [ + MapEvents::JAVASCRIPT_INIT_CONTAINER, + MapEvents::JAVASCRIPT_INIT_FUNCTION, + ], + ]; + } +} diff --git a/src/Helper/Subscriber/MapJavascriptSubscriber.php b/src/Helper/Subscriber/MapJavascriptSubscriber.php new file mode 100644 index 00000000..37ea1f3d --- /dev/null +++ b/src/Helper/Subscriber/MapJavascriptSubscriber.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\ApiEvent; +use Ivory\GoogleMap\Helper\Event\ApiEvents; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Html\JavascriptTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\CallbackRenderer; +use Ivory\GoogleMap\Map; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; + +/** + * @author GeLo + */ +class MapJavascriptSubscriber extends AbstractDelegateSubscriber +{ + /** + * @var MapRenderer + */ + private $mapRenderer; + + /** + * @var CallbackRenderer + */ + private $callbackRenderer; + + /** + * @var JavascriptTagRenderer + */ + private $javascriptTagRenderer; + + /** + * @param Formatter $formatter + * @param MapRenderer $mapRenderer + * @param CallbackRenderer $callbackRenderer + * @param JavascriptTagRenderer $javascriptTagRenderer + */ + public function __construct( + Formatter $formatter, + MapRenderer $mapRenderer, + CallbackRenderer $callbackRenderer, + JavascriptTagRenderer $javascriptTagRenderer + ) { + parent::__construct($formatter); + + $this->setMapRenderer($mapRenderer); + $this->setCallbackRenderer($callbackRenderer); + $this->setJavascriptTagRenderer($javascriptTagRenderer); + } + + /** + * @return MapRenderer + */ + public function getMapRenderer() + { + return $this->mapRenderer; + } + + /** + * @param MapRenderer $mapRenderer + */ + public function setMapRenderer(MapRenderer $mapRenderer) + { + $this->mapRenderer = $mapRenderer; + } + + /** + * @return CallbackRenderer + */ + public function getCallbackRenderer() + { + return $this->callbackRenderer; + } + + /** + * @param CallbackRenderer $callbackRenderer + */ + public function setCallbackRenderer(CallbackRenderer $callbackRenderer) + { + $this->callbackRenderer = $callbackRenderer; + } + + /** + * @return JavascriptTagRenderer + */ + public function getJavascriptTagRenderer() + { + return $this->javascriptTagRenderer; + } + + /** + * @param JavascriptTagRenderer $javascriptTagRenderer + */ + public function setJavascriptTagRenderer(JavascriptTagRenderer $javascriptTagRenderer) + { + $this->javascriptTagRenderer = $javascriptTagRenderer; + } + + /** + * {@inheritdoc} + */ + public function handle(Event $event, $eventName, EventDispatcherInterface $eventDispatcher) + { + parent::handle($event, $eventName, $eventDispatcher); + + if ($event instanceof ApiEvent) { + $this->handleApi($event); + } elseif ($event instanceof MapEvent) { + $this->handleMap($event); + } + } + + /** + * @return string + */ + public static function getDelegatedSubscribedEvents() + { + return [ + ApiEvents::JAVASCRIPT_MAP => [], + MapEvents::JAVASCRIPT => [ + MapEvents::JAVASCRIPT_INIT, + MapEvents::JAVASCRIPT_BASE, + MapEvents::JAVASCRIPT_MAP, + MapEvents::JAVASCRIPT_OVERLAY, + MapEvents::JAVASCRIPT_LAYER, + MapEvents::JAVASCRIPT_EVENT, + MapEvents::JAVASCRIPT_FINISH, + ], + ]; + } + + /** + * @param ApiEvent $event + */ + private function handleApi(ApiEvent $event) + { + foreach ($event->getObjects(Map::class) as $map) { + $event->setLanguage($map->getLanguage()); + $event->addLibraries($map->getLibraries()); + $event->addCallback($map, $this->renderCallback($map)); + $event->addRequirement($map, $this->mapRenderer->renderRequirement()); + } + } + + /** + * @param MapEvent $event + */ + private function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + + $event->setCode($this->javascriptTagRenderer->render($formatter->renderClosure( + $event->getCode(), + [], + $this->renderCallback($event->getMap()) + ))); + } + + /** + * @param Map $map + * + * @return string + */ + private function renderCallback(Map $map) + { + return $this->callbackRenderer->render($map->getVariable()); + } +} diff --git a/src/Helper/Subscriber/MapStylesheetSubscriber.php b/src/Helper/Subscriber/MapStylesheetSubscriber.php new file mode 100644 index 00000000..c37b8fc7 --- /dev/null +++ b/src/Helper/Subscriber/MapStylesheetSubscriber.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Html\StylesheetTagRenderer; + +/** + * @author GeLo + */ +class MapStylesheetSubscriber extends AbstractSubscriber +{ + /** + * @var StylesheetTagRenderer + */ + private $stylesheetTagRenderer; + + /** + * @param Formatter $formatter + * @param StylesheetTagRenderer $stylesheetTagRenderer + */ + public function __construct(Formatter $formatter, StylesheetTagRenderer $stylesheetTagRenderer) + { + parent::__construct($formatter); + + $this->setStylesheetTagRenderer($stylesheetTagRenderer); + } + + /** + * @return StylesheetTagRenderer + */ + public function getStylesheetTagRenderer() + { + return $this->stylesheetTagRenderer; + } + + /** + * @param StylesheetTagRenderer $stylesheetTagRenderer + */ + public function setStylesheetTagRenderer(StylesheetTagRenderer $stylesheetTagRenderer) + { + $this->stylesheetTagRenderer = $stylesheetTagRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $map = $event->getMap(); + + if ($map->hasStylesheetOptions()) { + $event->addCode($this->stylesheetTagRenderer->render('#'.$map->getHtmlId(), $map->getStylesheetOptions())); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::STYLESHEET => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/MapSubscriber.php b/src/Helper/Subscriber/MapSubscriber.php new file mode 100644 index 00000000..286c9c09 --- /dev/null +++ b/src/Helper/Subscriber/MapSubscriber.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber; + +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\MapRenderer; + +/** + * @author GeLo + */ +class MapSubscriber extends AbstractSubscriber +{ + /** + * @var MapRenderer + */ + private $mapRenderer; + + /** + * @param Formatter $formatter + * @param MapRenderer $mapRenderer + */ + public function __construct(Formatter $formatter, MapRenderer $mapRenderer) + { + parent::__construct($formatter); + + $this->setMapRenderer($mapRenderer); + } + + /** + * @return MapRenderer + */ + public function getMapRenderer() + { + return $this->mapRenderer; + } + + /** + * @param MapRenderer $mapRenderer + */ + public function setMapRenderer(MapRenderer $mapRenderer) + { + $this->mapRenderer = $mapRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $map = $event->getMap(); + + $event->addCode($this->getFormatter()->renderContainerAssignment( + $map, + $this->mapRenderer->render($map), + 'map' + )); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_MAP => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/AbstractInfoWindowSubscriber.php b/src/Helper/Subscriber/Overlay/AbstractInfoWindowSubscriber.php new file mode 100644 index 00000000..0177948f --- /dev/null +++ b/src/Helper/Subscriber/Overlay/AbstractInfoWindowSubscriber.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +abstract class AbstractInfoWindowSubscriber extends AbstractSubscriber +{ + /** + * @var InfoWindowCollector + */ + private $infoWindowCollector; + + /** + * @param Formatter $formatter + * @param InfoWindowCollector $infoWindowCollector + */ + public function __construct(Formatter $formatter, InfoWindowCollector $infoWindowCollector) + { + parent::__construct($formatter); + + $this->setInfoWindowCollector($infoWindowCollector); + } + + /** + * @return InfoWindowCollector + */ + public function getInfoWindowCollector() + { + return $this->infoWindowCollector; + } + + /** + * @param InfoWindowCollector $infoWindowCollector + */ + public function setInfoWindowCollector(InfoWindowCollector $infoWindowCollector) + { + $this->infoWindowCollector = $infoWindowCollector; + } +} diff --git a/src/Helper/Subscriber/Overlay/AbstractMarkerSubscriber.php b/src/Helper/Subscriber/Overlay/AbstractMarkerSubscriber.php new file mode 100644 index 00000000..15c13551 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/AbstractMarkerSubscriber.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * Marker subscriber. + * + * @author GeLo + */ +abstract class AbstractMarkerSubscriber extends AbstractSubscriber +{ + /** + * @var MarkerCollector + */ + private $markerCollector; + + /** + * @param Formatter $formatter + * @param MarkerCollector $markerCollector + */ + public function __construct(Formatter $formatter, MarkerCollector $markerCollector) + { + parent::__construct($formatter); + + $this->setMarkerCollector($markerCollector); + } + + /** + * @return MarkerCollector + */ + public function getMarkerCollector() + { + return $this->markerCollector; + } + + /** + * @param MarkerCollector $markerCollector + */ + public function setMarkerCollector(MarkerCollector $markerCollector) + { + $this->markerCollector = $markerCollector; + } +} diff --git a/src/Helper/Subscriber/Overlay/CircleSubscriber.php b/src/Helper/Subscriber/Overlay/CircleSubscriber.php new file mode 100644 index 00000000..ba88e236 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/CircleSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\CircleCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\CircleRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class CircleSubscriber extends AbstractSubscriber +{ + /** + * @var CircleCollector + */ + private $circleCollector; + + /** + * @var CircleRenderer + */ + private $circleRenderer; + + /** + * @param Formatter $formatter + * @param CircleCollector $circleCollector + * @param CircleRenderer $circleRenderer + */ + public function __construct( + Formatter $formatter, + CircleCollector $circleCollector, + CircleRenderer $circleRenderer + ) { + parent::__construct($formatter); + + $this->setCircleCollector($circleCollector); + $this->setCircleRenderer($circleRenderer); + } + + /** + * @return CircleCollector + */ + public function getCircleCollector() + { + return $this->circleCollector; + } + + /** + * @param CircleCollector $circleCollector + */ + public function setCircleCollector(CircleCollector $circleCollector) + { + $this->circleCollector = $circleCollector; + } + + /** + * @return CircleRenderer + */ + public function getCircleRenderer() + { + return $this->circleRenderer; + } + + /** + * @param CircleRenderer $circleRenderer + */ + public function setCircleRenderer(CircleRenderer $circleRenderer) + { + $this->circleRenderer = $circleRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->circleCollector->collect($map) as $circle) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->circleRenderer->render($circle, $map), + 'overlays.circles', + $circle + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_OVERLAY_CIRCLE => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/DefaultInfoWindowSubscriber.php b/src/Helper/Subscriber/Overlay/DefaultInfoWindowSubscriber.php new file mode 100644 index 00000000..f6f2b5cc --- /dev/null +++ b/src/Helper/Subscriber/Overlay/DefaultInfoWindowSubscriber.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\DefaultInfoWindowCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\DefaultInfoWindowRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; + +/** + * @author GeLo + */ +class DefaultInfoWindowSubscriber extends AbstractInfoWindowSubscriber +{ + /** + * @var DefaultInfoWindowRenderer + */ + private $infoWindowRenderer; + + /** + * @param Formatter $formatter + * @param DefaultInfoWindowCollector $infoWindowCollector + * @param DefaultInfoWindowRenderer $infoWindowRenderer + */ + public function __construct( + Formatter $formatter, + DefaultInfoWindowCollector $infoWindowCollector, + DefaultInfoWindowRenderer $infoWindowRenderer + ) { + parent::__construct($formatter, $infoWindowCollector); + + $this->setInfoWindowRenderer($infoWindowRenderer); + } + + /** + * @return DefaultInfoWindowRenderer + */ + public function getInfoWindowRenderer() + { + return $this->infoWindowRenderer; + } + + /** + * @param DefaultInfoWindowRenderer $infoWindowRenderer + */ + public function setInfoWindowRenderer(DefaultInfoWindowRenderer $infoWindowRenderer) + { + $this->infoWindowRenderer = $infoWindowRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $map = $event->getMap(); + + foreach ($this->getInfoWindowCollector()->collect($map) as $infoWindow) { + $event->addCode($this->renderInfoWindow($map, $infoWindow)); + } + + foreach ($this->getInfoWindowCollector()->collect($map, [], false) as $infoWindow) { + $event->addCode($this->renderInfoWindow($map, $infoWindow, false)); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_OVERLAY_INFO_WINDOW => 'handleMap']; + } + + /** + * @param Map $map + * @param InfoWindow $infoWindow + * @param bool $position + * + * @return string + */ + private function renderInfoWindow(Map $map, InfoWindow $infoWindow, $position = true) + { + return $this->getFormatter()->renderContainerAssignment( + $map, + $this->infoWindowRenderer->render($infoWindow, $position), + 'overlays.info_windows', + $infoWindow + ); + } +} diff --git a/src/Helper/Subscriber/Overlay/EncodedPolylineSubscriber.php b/src/Helper/Subscriber/Overlay/EncodedPolylineSubscriber.php new file mode 100644 index 00000000..2ced3a28 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/EncodedPolylineSubscriber.php @@ -0,0 +1,131 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\EncodedPolylineCollector; +use Ivory\GoogleMap\Helper\Event\ApiEvent; +use Ivory\GoogleMap\Helper\Event\ApiEvents; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\EncodedPolylineRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class EncodedPolylineSubscriber extends AbstractSubscriber +{ + /** + * @var EncodedPolylineCollector + */ + private $encodedPolylineCollector; + + /** + * @var EncodedPolylineRenderer + */ + private $encodedPolylineRenderer; + + /** + * @param Formatter $formatter + * @param EncodedPolylineCollector $encodedPolylineCollector + * @param EncodedPolylineRenderer $encodedPolylineRenderer + */ + public function __construct( + Formatter $formatter, + EncodedPolylineCollector $encodedPolylineCollector, + EncodedPolylineRenderer $encodedPolylineRenderer + ) { + parent::__construct($formatter); + + $this->setEncodedPolylineCollector($encodedPolylineCollector); + $this->setEncodedPolylineRenderer($encodedPolylineRenderer); + } + + /** + * @return EncodedPolylineCollector + */ + public function getEncodedPolylineCollector() + { + return $this->encodedPolylineCollector; + } + + /** + * @param EncodedPolylineCollector $encodedPolylineCollector + */ + public function setEncodedPolylineCollector(EncodedPolylineCollector $encodedPolylineCollector) + { + $this->encodedPolylineCollector = $encodedPolylineCollector; + } + + /** + * @return EncodedPolylineRenderer + */ + public function getEncodedPolylineRenderer() + { + return $this->encodedPolylineRenderer; + } + + /** + * @param EncodedPolylineRenderer $encodedPolylineRenderer + */ + public function setEncodedPolylineRenderer(EncodedPolylineRenderer $encodedPolylineRenderer) + { + $this->encodedPolylineRenderer = $encodedPolylineRenderer; + } + + /** + * @param ApiEvent $event + */ + public function handleApi(ApiEvent $event) + { + foreach ($event->getObjects(Map::class) as $map) { + $encodedPolylines = $this->encodedPolylineCollector->collect($map); + + if (!empty($encodedPolylines)) { + $event->addLibrary('geometry'); + + break; + } + } + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->encodedPolylineCollector->collect($map) as $encodedPolyline) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->encodedPolylineRenderer->render($encodedPolyline, $map), + 'overlays.encoded_polylines', + $encodedPolyline + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [ + ApiEvents::JAVASCRIPT_MAP => 'handleApi', + MapEvents::JAVASCRIPT_OVERLAY_ENCODED_POLYLINE => 'handleMap', + ]; + } +} diff --git a/src/Helper/Subscriber/Overlay/ExtendableSubscriber.php b/src/Helper/Subscriber/Overlay/ExtendableSubscriber.php new file mode 100644 index 00000000..1970fb1d --- /dev/null +++ b/src/Helper/Subscriber/Overlay/ExtendableSubscriber.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\ExtendableCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\ExtendableRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class ExtendableSubscriber extends AbstractSubscriber +{ + /** + * @var ExtendableCollector + */ + private $extendableCollector; + + /** + * @var ExtendableRenderer + */ + private $extendableRenderer; + + /** + * @param Formatter $formatter + * @param ExtendableCollector $extendableCollector + * @param ExtendableRenderer $extendableRenderer + */ + public function __construct( + Formatter $formatter, + ExtendableCollector $extendableCollector, + ExtendableRenderer $extendableRenderer + ) { + parent::__construct($formatter); + + $this->setExtendableCollector($extendableCollector); + $this->setExtendableRenderer($extendableRenderer); + } + + /** + * @return ExtendableCollector + */ + public function getExtendableCollector() + { + return $this->extendableCollector; + } + + /** + * @param ExtendableCollector $extendableCollector + */ + public function setExtendableCollector(ExtendableCollector $extendableCollector) + { + $this->extendableCollector = $extendableCollector; + } + + /** + * @return ExtendableRenderer + */ + public function getExtendableRenderer() + { + return $this->extendableRenderer; + } + + /** + * @param ExtendableRenderer $extendableRenderer + */ + public function setExtendableRenderer(ExtendableRenderer $extendableRenderer) + { + $this->extendableRenderer = $extendableRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->extendableCollector->collect($map) as $extendable) { + $event->addCode($formatter->renderCode($this->extendableRenderer->render($extendable, $map->getBound()))); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_FINISH => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/GroundOverlaySubscriber.php b/src/Helper/Subscriber/Overlay/GroundOverlaySubscriber.php new file mode 100644 index 00000000..9031feed --- /dev/null +++ b/src/Helper/Subscriber/Overlay/GroundOverlaySubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\GroundOverlayCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\GroundOverlayRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class GroundOverlaySubscriber extends AbstractSubscriber +{ + /** + * @var GroundOverlayCollector + */ + private $groundOverlayCollector; + + /** + * @var GroundOverlayRenderer + */ + private $groundOverlayRenderer; + + /** + * @param Formatter $formatter + * @param GroundOverlayCollector $groundOverlayCollector + * @param GroundOverlayRenderer $groundOverlayRenderer + */ + public function __construct( + Formatter $formatter, + GroundOverlayCollector $groundOverlayCollector, + GroundOverlayRenderer $groundOverlayRenderer + ) { + parent::__construct($formatter); + + $this->setGroundOverlayCollector($groundOverlayCollector); + $this->setGroundOverlayRenderer($groundOverlayRenderer); + } + + /** + * @return GroundOverlayCollector + */ + public function getGroundOverlayCollector() + { + return $this->groundOverlayCollector; + } + + /** + * @param GroundOverlayCollector $groundOverlayCollector + */ + public function setGroundOverlayCollector(GroundOverlayCollector $groundOverlayCollector) + { + $this->groundOverlayCollector = $groundOverlayCollector; + } + + /** + * @return GroundOverlayRenderer + */ + public function getGroundOverlayRenderer() + { + return $this->groundOverlayRenderer; + } + + /** + * @param GroundOverlayRenderer $groundOverlayRenderer + */ + public function setGroundOverlayRenderer(GroundOverlayRenderer $groundOverlayRenderer) + { + $this->groundOverlayRenderer = $groundOverlayRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->groundOverlayCollector->collect($map) as $groundOverlay) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->groundOverlayRenderer->render($groundOverlay, $map), + 'overlays.ground_overlays', + $groundOverlay + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_OVERLAY_GROUND_OVERLAY => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/InfoBoxSubscriber.php b/src/Helper/Subscriber/Overlay/InfoBoxSubscriber.php new file mode 100644 index 00000000..64ac345f --- /dev/null +++ b/src/Helper/Subscriber/Overlay/InfoBoxSubscriber.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoBoxCollector; +use Ivory\GoogleMap\Helper\Event\ApiEvent; +use Ivory\GoogleMap\Helper\Event\ApiEvents; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoBoxRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; + +/** + * @author GeLo + */ +class InfoBoxSubscriber extends AbstractInfoWindowSubscriber +{ + /** + * @var InfoBoxRenderer + */ + private $infoBoxRenderer; + + /** + * @param Formatter $formatter + * @param InfoBoxCollector $infoBoxCollector + * @param InfoBoxRenderer $infoBoxRenderer + */ + public function __construct( + Formatter $formatter, + InfoBoxCollector $infoBoxCollector, + InfoBoxRenderer $infoBoxRenderer + ) { + parent::__construct($formatter, $infoBoxCollector); + + $this->setInfoBoxRenderer($infoBoxRenderer); + } + + /** + * @return InfoBoxRenderer + */ + public function getInfoBoxRenderer() + { + return $this->infoBoxRenderer; + } + + /** + * @param InfoBoxRenderer $infoBoxRenderer + */ + public function setInfoBoxRenderer(InfoBoxRenderer $infoBoxRenderer) + { + $this->infoBoxRenderer = $infoBoxRenderer; + } + + /** + * @param ApiEvent $event + */ + public function handleApi(ApiEvent $event) + { + foreach ($event->getObjects(Map::class) as $map) { + $infoBoxes = $this->getInfoWindowCollector()->collect($map); + + if (!empty($infoBoxes)) { + $event->addSource($this->infoBoxRenderer->renderSource()); + $event->addRequirement($map, $this->infoBoxRenderer->renderRequirement()); + + continue; + } + } + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $map = $event->getMap(); + + foreach ($this->getInfoWindowCollector()->collect($map) as $infoWindow) { + $event->addCode($this->renderInfoBox($map, $infoWindow)); + } + + foreach ($this->getInfoWindowCollector()->collect($map, [], false) as $infoWindow) { + $event->addCode($this->renderInfoBox($map, $infoWindow, false)); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [ + ApiEvents::JAVASCRIPT_MAP => 'handleApi', + MapEvents::JAVASCRIPT_OVERLAY_INFO_WINDOW => 'handleMap', + ]; + } + + /** + * @param Map $map + * @param InfoWindow $infoWindow + * @param bool $position + * + * @return string + */ + private function renderInfoBox(Map $map, InfoWindow $infoWindow, $position = true) + { + return $this->getFormatter()->renderContainerAssignment( + $map, + $this->infoBoxRenderer->render($infoWindow, $position), + 'overlays.info_boxes', + $infoWindow + ); + } +} diff --git a/src/Helper/Subscriber/Overlay/InfoWindowCloseSubscriber.php b/src/Helper/Subscriber/Overlay/InfoWindowCloseSubscriber.php new file mode 100644 index 00000000..926461a2 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/InfoWindowCloseSubscriber.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowCloseRenderer; + +/** + * @author GeLo + */ +class InfoWindowCloseSubscriber extends AbstractInfoWindowSubscriber +{ + /** + * @var InfoWindowCloseRenderer + */ + private $infoWindowCloseRenderer; + + /** + * @param Formatter $formatter + * @param InfoWindowCollector $infoWindowCollector + * @param InfoWindowCloseRenderer $infoWindowCloseRenderer + */ + public function __construct( + Formatter $formatter, + InfoWindowCollector $infoWindowCollector, + InfoWindowCloseRenderer $infoWindowCloseRenderer + ) { + parent::__construct($formatter, $infoWindowCollector); + + $this->setInfoWindowCloseRenderer($infoWindowCloseRenderer); + } + + /** + * @return InfoWindowCloseRenderer + */ + public function getInfoWindowCloseRenderer() + { + return $this->infoWindowCloseRenderer; + } + + /** + * @param InfoWindowCloseRenderer $infoWindowCloseRenderer + */ + public function setInfoWindowCloseRenderer(InfoWindowCloseRenderer $infoWindowCloseRenderer) + { + $this->infoWindowCloseRenderer = $infoWindowCloseRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + $codes = []; + + foreach ($this->getInfoWindowCollector()->collect($map) as $infoWindow) { + if ($infoWindow->isAutoClose()) { + $codes[] = $formatter->renderCode($this->infoWindowCloseRenderer->render($infoWindow), true, false); + } + } + + $event->addCode($formatter->renderContainerAssignment( + $map, + $formatter->renderClosure($formatter->renderLines($codes)), + 'functions.info_windows_close' + )); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_INIT_FUNCTION => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/InfoWindowOpenSubscriber.php b/src/Helper/Subscriber/Overlay/InfoWindowOpenSubscriber.php new file mode 100644 index 00000000..9d33a925 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/InfoWindowOpenSubscriber.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowOpenRenderer; + +/** + * @author GeLo + */ +class InfoWindowOpenSubscriber extends AbstractInfoWindowSubscriber +{ + /** + * @var InfoWindowOpenRenderer + */ + private $infoWindowOpenRenderer; + + /** + * @param Formatter $formatter + * @param InfoWindowCollector $infoWindowCollector + * @param InfoWindowOpenRenderer $infoWindowOpenRenderer + */ + public function __construct( + Formatter $formatter, + InfoWindowCollector $infoWindowCollector, + InfoWindowOpenRenderer $infoWindowOpenRenderer + ) { + parent::__construct($formatter, $infoWindowCollector); + + $this->setInfoWindowOpenRenderer($infoWindowOpenRenderer); + } + + /** + * @return InfoWindowOpenRenderer + */ + public function getInfoWindowOpenRenderer() + { + return $this->infoWindowOpenRenderer; + } + + /** + * @param InfoWindowOpenRenderer $infoWindowOpenRenderer + */ + public function setInfoWindowOpenRenderer(InfoWindowOpenRenderer $infoWindowOpenRenderer) + { + $this->infoWindowOpenRenderer = $infoWindowOpenRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->getInfoWindowCollector()->collect($map) as $infoWindow) { + if ($infoWindow->isOpen()) { + $event->addCode($formatter->renderCode($this->infoWindowOpenRenderer->render($infoWindow, $map))); + } + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_FINISH => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/MarkerClustererSubscriber.php b/src/Helper/Subscriber/Overlay/MarkerClustererSubscriber.php new file mode 100644 index 00000000..09304996 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/MarkerClustererSubscriber.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Event\ApiEvent; +use Ivory\GoogleMap\Helper\Event\ApiEvents; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerClustererRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\MarkerCluster; +use Ivory\GoogleMap\Overlay\MarkerClusterType; + +/** + * @author GeLo + */ +class MarkerClustererSubscriber extends AbstractSubscriber +{ + /** + * @var MarkerClustererRenderer + */ + private $markerClustererRenderer; + + /** + * @param Formatter $formatter + * @param MarkerClustererRenderer $markerClustererRenderer + */ + public function __construct(Formatter $formatter, MarkerClustererRenderer $markerClustererRenderer) + { + parent::__construct($formatter); + + $this->setMarkerClustererRenderer($markerClustererRenderer); + } + + /** + * @return MarkerClustererRenderer + */ + public function getMarkerClustererRenderer() + { + return $this->markerClustererRenderer; + } + + /** + * @param MarkerClustererRenderer $markerClustererRenderer + */ + public function setMarkerClustererRenderer(MarkerClustererRenderer $markerClustererRenderer) + { + $this->markerClustererRenderer = $markerClustererRenderer; + } + + /** + * @param ApiEvent $event + */ + public function handleApi(ApiEvent $event) + { + foreach ($event->getObjects(Map::class) as $map) { + if (($markerCluster = $this->getMarkerCluster($map)) !== null) { + $event->addSource($this->markerClustererRenderer->renderSource()); + $event->addRequirement($map, $this->markerClustererRenderer->renderRequirement()); + + break; + } + } + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + if (($markerCluster = $this->getMarkerCluster($map)) !== null) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->markerClustererRenderer->render($markerCluster, $map, $formatter->renderCall( + $formatter->renderProperty($formatter->renderContainerVariable($map, 'functions'), 'to_array'), + [$formatter->renderContainerVariable($map, 'overlays.markers')] + )), + 'overlays.marker_cluster' + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [ + ApiEvents::JAVASCRIPT_MAP => 'handleApi', + MapEvents::JAVASCRIPT_OVERLAY_MARKER_CLUSTER => 'handleMap', + ]; + } + + /** + * @param Map $map + * + * @return MarkerCluster|null + */ + private function getMarkerCluster(Map $map) + { + $markerCluster = $map->getOverlayManager()->getMarkerCluster(); + + if ($markerCluster->getType() === MarkerClusterType::MARKER_CLUSTERER) { + return $markerCluster; + } + } +} diff --git a/src/Helper/Subscriber/Overlay/MarkerInfoWindowOpenSubscriber.php b/src/Helper/Subscriber/Overlay/MarkerInfoWindowOpenSubscriber.php new file mode 100644 index 00000000..8d43265a --- /dev/null +++ b/src/Helper/Subscriber/Overlay/MarkerInfoWindowOpenSubscriber.php @@ -0,0 +1,151 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\EventRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowOpenRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class MarkerInfoWindowOpenSubscriber extends AbstractMarkerSubscriber +{ + /** + * @var InfoWindowOpenRenderer + */ + private $infoWindowOpenRenderer; + + /** + * @var EventRenderer + */ + private $eventRenderer; + + /** + * @param Formatter $formatter + * @param MarkerCollector $markerCollector + * @param InfoWindowOpenRenderer $infoWindowOpenRenderer + * @param EventRenderer $eventRenderer + */ + public function __construct( + Formatter $formatter, + MarkerCollector $markerCollector, + InfoWindowOpenRenderer $infoWindowOpenRenderer, + EventRenderer $eventRenderer + ) { + parent::__construct($formatter, $markerCollector); + + $this->setInfoWindowOpenRenderer($infoWindowOpenRenderer); + $this->setEventRenderer($eventRenderer); + } + + /** + * @return InfoWindowOpenRenderer + */ + public function getInfoWindowOpenRenderer() + { + return $this->infoWindowOpenRenderer; + } + + /** + * @param InfoWindowOpenRenderer $infoWindowOpenRenderer + */ + public function setInfoWindowOpenRenderer(InfoWindowOpenRenderer $infoWindowOpenRenderer) + { + $this->infoWindowOpenRenderer = $infoWindowOpenRenderer; + } + + /** + * @return EventRenderer + */ + public function getEventRenderer() + { + return $this->eventRenderer; + } + + /** + * @param EventRenderer $eventRenderer + */ + public function setEventRenderer(EventRenderer $eventRenderer) + { + $this->eventRenderer = $eventRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->getMarkerCollector()->collect($map) as $marker) { + if ($marker->hasInfoWindow() && $marker->getInfoWindow()->isAutoOpen()) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->eventRenderer->render($rawEvent = $this->createEvent($map, $marker)), + 'events.events', + $rawEvent + )); + } + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_EVENT => 'handleMap']; + } + + /** + * @param Map $map + * @param Marker $marker + * + * @return Event + */ + private function createEvent(Map $map, Marker $marker) + { + $formatter = $this->getFormatter(); + + $rawEvent = new Event( + $marker->getVariable(), + $marker->getInfoWindow()->getOpenEvent(), + $formatter->renderClosure($formatter->renderLines([ + $formatter->renderCall( + $formatter->renderProperty( + $formatter->renderContainerVariable($map, 'functions'), + 'info_windows_close' + ), + [], + true + ), + $formatter->renderCode( + $this->infoWindowOpenRenderer->render($marker->getInfoWindow(), $map, $marker), + true, + false + ), + ])) + ); + + $rawEvent->setVariable($marker->getVariable().'_info_window_open_event'); + + return $rawEvent; + } +} diff --git a/src/Helper/Subscriber/Overlay/MarkerSubscriber.php b/src/Helper/Subscriber/Overlay/MarkerSubscriber.php new file mode 100644 index 00000000..9b6991e7 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/MarkerSubscriber.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerRenderer; +use Ivory\GoogleMap\Overlay\MarkerClusterType; + +/** + * @author GeLo + */ +class MarkerSubscriber extends AbstractMarkerSubscriber +{ + /** + * @var MarkerRenderer + */ + private $markerRenderer; + + /** + * @param Formatter $formatter + * @param MarkerCollector $markerCollector + * @param MarkerRenderer $markerRenderer + */ + public function __construct( + Formatter $formatter, + MarkerCollector $markerCollector, + MarkerRenderer $markerRenderer + ) { + parent::__construct($formatter, $markerCollector); + + $this->setMarkerRenderer($markerRenderer); + } + + /** + * @return MarkerRenderer + */ + public function getMarkerRenderer() + { + return $this->markerRenderer; + } + + /** + * @param MarkerRenderer $markerRenderer + */ + public function setMarkerRenderer(MarkerRenderer $markerRenderer) + { + $this->markerRenderer = $markerRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + $markerMap = null; + + if ($map->getOverlayManager()->getMarkerCluster()->getType() === MarkerClusterType::DEFAULT_) { + $markerMap = $map; + } + + foreach ($this->getMarkerCollector()->collect($map) as $marker) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->markerRenderer->render($marker, $markerMap), + 'overlays.markers', + $marker + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_OVERLAY_MARKER => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/OverlaySubscriber.php b/src/Helper/Subscriber/Overlay/OverlaySubscriber.php new file mode 100644 index 00000000..6c2ae6a0 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/OverlaySubscriber.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Subscriber\AbstractDelegateSubscriber; + +/** + * @author GeLo + */ +class OverlaySubscriber extends AbstractDelegateSubscriber +{ + /** + * {@inheritdoc} + */ + public static function getDelegatedSubscribedEvents() + { + return [ + MapEvents::JAVASCRIPT_OVERLAY => [ + MapEvents::JAVASCRIPT_OVERLAY_CIRCLE, + MapEvents::JAVASCRIPT_OVERLAY_ENCODED_POLYLINE, + MapEvents::JAVASCRIPT_OVERLAY_GROUND_OVERLAY, + MapEvents::JAVASCRIPT_OVERLAY_POLYGON, + MapEvents::JAVASCRIPT_OVERLAY_POLYLINE, + MapEvents::JAVASCRIPT_OVERLAY_RECTANGLE, + MapEvents::JAVASCRIPT_OVERLAY_INFO_WINDOW, + MapEvents::JAVASCRIPT_OVERLAY_MARKER_IMAGE, + MapEvents::JAVASCRIPT_OVERLAY_MARKER_SHAPE, + MapEvents::JAVASCRIPT_OVERLAY_MARKER, + MapEvents::JAVASCRIPT_OVERLAY_MARKER_CLUSTER, + ], + ]; + } +} diff --git a/src/Helper/Subscriber/Overlay/PolygonSubscriber.php b/src/Helper/Subscriber/Overlay/PolygonSubscriber.php new file mode 100644 index 00000000..cfab3855 --- /dev/null +++ b/src/Helper/Subscriber/Overlay/PolygonSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\PolygonCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\PolygonRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class PolygonSubscriber extends AbstractSubscriber +{ + /** + * @var PolygonCollector + */ + private $polygonCollector; + + /** + * @var PolygonRenderer + */ + private $polygonRenderer; + + /** + * @param Formatter $formatter + * @param PolygonCollector $polygonCollector + * @param PolygonRenderer $polygonRenderer + */ + public function __construct( + Formatter $formatter, + PolygonCollector $polygonCollector, + PolygonRenderer $polygonRenderer + ) { + parent::__construct($formatter); + + $this->setPolygonCollector($polygonCollector); + $this->setPolygonRenderer($polygonRenderer); + } + + /** + * @return PolygonCollector + */ + public function getPolygonCollector() + { + return $this->polygonCollector; + } + + /** + * @param PolygonCollector $polygonCollector + */ + public function setPolygonCollector(PolygonCollector $polygonCollector) + { + $this->polygonCollector = $polygonCollector; + } + + /** + * @return PolygonRenderer + */ + public function getPolygonRenderer() + { + return $this->polygonRenderer; + } + + /** + * @param PolygonRenderer $polygonRenderer + */ + public function setPolygonRenderer(PolygonRenderer $polygonRenderer) + { + $this->polygonRenderer = $polygonRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->polygonCollector->collect($map) as $polygon) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->polygonRenderer->render($polygon, $map), + 'overlays.polygons', + $polygon + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_OVERLAY_POLYGON => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/PolylineSubscriber.php b/src/Helper/Subscriber/Overlay/PolylineSubscriber.php new file mode 100644 index 00000000..23b5c55b --- /dev/null +++ b/src/Helper/Subscriber/Overlay/PolylineSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\PolylineCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\PolylineRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class PolylineSubscriber extends AbstractSubscriber +{ + /** + * @var PolylineCollector + */ + private $polylineCollector; + + /** + * @var PolylineRenderer + */ + private $polylineRenderer; + + /** + * @param Formatter $formatter + * @param PolylineCollector $polylineCollector + * @param PolylineRenderer $polylineRenderer + */ + public function __construct( + Formatter $formatter, + PolylineCollector $polylineCollector, + PolylineRenderer $polylineRenderer + ) { + parent::__construct($formatter); + + $this->setPolylineCollector($polylineCollector); + $this->setPolylineRenderer($polylineRenderer); + } + + /** + * @return PolylineCollector + */ + public function getPolylineCollector() + { + return $this->polylineCollector; + } + + /** + * @param PolylineCollector $polylineCollector + */ + public function setPolylineCollector(PolylineCollector $polylineCollector) + { + $this->polylineCollector = $polylineCollector; + } + + /** + * @return PolylineRenderer + */ + public function getPolylineRenderer() + { + return $this->polylineRenderer; + } + + /** + * @param PolylineRenderer $polylineRenderer + */ + public function setPolylineRenderer(PolylineRenderer $polylineRenderer) + { + $this->polylineRenderer = $polylineRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->polylineCollector->collect($map) as $polyline) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->polylineRenderer->render($polyline, $map), + 'overlays.polylines', + $polyline + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_OVERLAY_POLYLINE => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Overlay/RectangleSubscriber.php b/src/Helper/Subscriber/Overlay/RectangleSubscriber.php new file mode 100644 index 00000000..b1f00b5a --- /dev/null +++ b/src/Helper/Subscriber/Overlay/RectangleSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\RectangleCollector; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\RectangleRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class RectangleSubscriber extends AbstractSubscriber +{ + /** + * @var RectangleCollector + */ + private $rectangleCollector; + + /** + * @var RectangleRenderer + */ + private $rectangleRenderer; + + /** + * @param Formatter $formatter + * @param RectangleCollector $rectangleCollector + * @param RectangleRenderer $rectangleRenderer + */ + public function __construct( + Formatter $formatter, + RectangleCollector $rectangleCollector, + RectangleRenderer $rectangleRenderer + ) { + parent::__construct($formatter); + + $this->setRectangleCollector($rectangleCollector); + $this->setRectangleRenderer($rectangleRenderer); + } + + /** + * @return RectangleCollector + */ + public function getRectangleCollector() + { + return $this->rectangleCollector; + } + + /** + * @param RectangleCollector $rectangleCollector + */ + public function setRectangleCollector(RectangleCollector $rectangleCollector) + { + $this->rectangleCollector = $rectangleCollector; + } + + /** + * @return RectangleRenderer + */ + public function getRectangleRenderer() + { + return $this->rectangleRenderer; + } + + /** + * @param RectangleRenderer $rectangleRenderer + */ + public function setRectangleRenderer(RectangleRenderer $rectangleRenderer) + { + $this->rectangleRenderer = $rectangleRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $formatter = $this->getFormatter(); + $map = $event->getMap(); + + foreach ($this->rectangleCollector->collect($map) as $rectangle) { + $event->addCode($formatter->renderContainerAssignment( + $map, + $this->rectangleRenderer->render($rectangle, $map), + 'overlays.rectangles', + $rectangle + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_OVERLAY_RECTANGLE => 'handleMap']; + } +} diff --git a/src/Helper/Subscriber/Place/AutocompleteContainerSubscriber.php b/src/Helper/Subscriber/Place/AutocompleteContainerSubscriber.php new file mode 100644 index 00000000..49ad8214 --- /dev/null +++ b/src/Helper/Subscriber/Place/AutocompleteContainerSubscriber.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Place; + +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteContainerRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class AutocompleteContainerSubscriber extends AbstractSubscriber +{ + /** + * @var AutocompleteContainerRenderer + */ + private $containerRenderer; + + /** + * @param Formatter $formatter + * @param AutocompleteContainerRenderer $containerRenderer + */ + public function __construct(Formatter $formatter, AutocompleteContainerRenderer $containerRenderer) + { + parent::__construct($formatter); + + $this->setContainerRenderer($containerRenderer); + } + + /** + * @return AutocompleteContainerRenderer + */ + public function getContainerRenderer() + { + return $this->containerRenderer; + } + + /** + * @param AutocompleteContainerRenderer $containerRenderer + */ + public function setContainerRenderer(AutocompleteContainerRenderer $containerRenderer) + { + $this->containerRenderer = $containerRenderer; + } + + /** + * @param PlaceAutocompleteEvent $event + */ + public function handleAutocomplete(PlaceAutocompleteEvent $event) + { + $autocomplete = $event->getAutocomplete(); + + $event->addCode($this->getFormatter()->renderContainerAssignment( + $autocomplete, + $this->containerRenderer->render() + )); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [PlaceAutocompleteEvents::JAVASCRIPT_INIT_CONTAINER => 'handleAutocomplete']; + } +} diff --git a/src/Helper/Subscriber/Place/AutocompleteHtmlSubscriber.php b/src/Helper/Subscriber/Place/AutocompleteHtmlSubscriber.php new file mode 100644 index 00000000..e4af4846 --- /dev/null +++ b/src/Helper/Subscriber/Place/AutocompleteHtmlSubscriber.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Place; + +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteHtmlRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class AutocompleteHtmlSubscriber extends AbstractSubscriber +{ + /** + * @var AutocompleteHtmlRenderer + */ + private $htmlRenderer; + + /** + * @param Formatter $formatter + * @param AutocompleteHtmlRenderer $htmlRenderer + */ + public function __construct(Formatter $formatter, AutocompleteHtmlRenderer $htmlRenderer) + { + parent::__construct($formatter); + + $this->setHtmlRenderer($htmlRenderer); + } + + /** + * @return AutocompleteHtmlRenderer + */ + public function getHtmlRenderer() + { + return $this->htmlRenderer; + } + + /** + * @param AutocompleteHtmlRenderer $htmlRenderer + */ + public function setHtmlRenderer(AutocompleteHtmlRenderer $htmlRenderer) + { + $this->htmlRenderer = $htmlRenderer; + } + + /** + * @param PlaceAutocompleteEvent $event + */ + public function handleAutocomplete(PlaceAutocompleteEvent $event) + { + $event->addCode($this->htmlRenderer->render($event->getAutocomplete())); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [PlaceAutocompleteEvents::HTML => 'handleAutocomplete']; + } +} diff --git a/src/Helper/Subscriber/Place/AutocompleteInitSubscriber.php b/src/Helper/Subscriber/Place/AutocompleteInitSubscriber.php new file mode 100644 index 00000000..f276cc52 --- /dev/null +++ b/src/Helper/Subscriber/Place/AutocompleteInitSubscriber.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Place; + +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Helper\Subscriber\AbstractDelegateSubscriber; + +/** + * @author GeLo + */ +class AutocompleteInitSubscriber extends AbstractDelegateSubscriber +{ + /** + * {@inheritdoc} + */ + public static function getDelegatedSubscribedEvents() + { + return [ + PlaceAutocompleteEvents::JAVASCRIPT_INIT => [ + PlaceAutocompleteEvents::JAVASCRIPT_INIT_CONTAINER, + ], + ]; + } +} diff --git a/src/Helper/Subscriber/Place/AutocompleteJavascriptSubscriber.php b/src/Helper/Subscriber/Place/AutocompleteJavascriptSubscriber.php new file mode 100644 index 00000000..63719a5f --- /dev/null +++ b/src/Helper/Subscriber/Place/AutocompleteJavascriptSubscriber.php @@ -0,0 +1,179 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Place; + +use Ivory\GoogleMap\Helper\Event\ApiEvent; +use Ivory\GoogleMap\Helper\Event\ApiEvents; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Html\JavascriptTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\CallbackRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractDelegateSubscriber; +use Ivory\GoogleMap\Place\Autocomplete; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; + +/** + * @author GeLo + */ +class AutocompleteJavascriptSubscriber extends AbstractDelegateSubscriber +{ + /** + * @var AutocompleteRenderer + */ + private $autocompleteRenderer; + + /** + * @var CallbackRenderer + */ + private $callbackRenderer; + + /** + * @var JavascriptTagRenderer + */ + private $javascriptTagRenderer; + + /** + * @param Formatter $formatter + * @param AutocompleteRenderer $autocompleteRenderer + * @param CallbackRenderer $callbackRenderer + * @param JavascriptTagRenderer $javascriptTagRenderer + */ + public function __construct( + Formatter $formatter, + AutocompleteRenderer $autocompleteRenderer, + CallbackRenderer $callbackRenderer, + JavascriptTagRenderer $javascriptTagRenderer + ) { + parent::__construct($formatter); + + $this->setAutocompleteRenderer($autocompleteRenderer); + $this->setCallbackRenderer($callbackRenderer); + $this->setJavascriptTagRenderer($javascriptTagRenderer); + } + + /** + * @return AutocompleteRenderer + */ + public function getAutocompleteRenderer() + { + return $this->autocompleteRenderer; + } + + /** + * @param AutocompleteRenderer $autocompleteRenderer + */ + public function setAutocompleteRenderer(AutocompleteRenderer $autocompleteRenderer) + { + $this->autocompleteRenderer = $autocompleteRenderer; + } + + /** + * @return CallbackRenderer + */ + public function getCallbackRenderer() + { + return $this->callbackRenderer; + } + + /** + * @param CallbackRenderer $callbackRenderer + */ + public function setCallbackRenderer(CallbackRenderer $callbackRenderer) + { + $this->callbackRenderer = $callbackRenderer; + } + + /** + * @return JavascriptTagRenderer + */ + public function getJavascriptTagRenderer() + { + return $this->javascriptTagRenderer; + } + + /** + * @param JavascriptTagRenderer $javascriptTagRenderer + */ + public function setJavascriptTagRenderer(JavascriptTagRenderer $javascriptTagRenderer) + { + $this->javascriptTagRenderer = $javascriptTagRenderer; + } + + /** + * {@inheritdoc} + */ + public function handle(Event $event, $eventName, EventDispatcherInterface $eventDispatcher) + { + parent::handle($event, $eventName, $eventDispatcher); + + if ($event instanceof ApiEvent) { + $this->handleApi($event); + } elseif ($event instanceof PlaceAutocompleteEvent) { + $this->handleAutocomplete($event); + } + } + + /** + * {@inheritdoc} + */ + public static function getDelegatedSubscribedEvents() + { + return [ + ApiEvents::JAVASCRIPT_AUTOCOMPLETE => [], + PlaceAutocompleteEvents::JAVASCRIPT => [ + PlaceAutocompleteEvents::JAVASCRIPT_INIT, + PlaceAutocompleteEvents::JAVASCRIPT_BASE, + PlaceAutocompleteEvents::JAVASCRIPT_AUTOCOMPLETE, + ], + ]; + } + + /** + * @param ApiEvent $event + */ + private function handleApi(ApiEvent $event) + { + foreach ($event->getObjects(Autocomplete::class) as $autocomplete) { + $event->setLanguage($autocomplete->getLanguage()); + $event->addLibraries(array_unique(array_merge($autocomplete->getLibraries(), ['places']))); + $event->addCallback($autocomplete, $this->renderCallback($autocomplete)); + $event->addRequirement($autocomplete, $this->autocompleteRenderer->renderRequirement()); + } + } + + /** + * @param PlaceAutocompleteEvent $event + */ + private function handleAutocomplete(PlaceAutocompleteEvent $event) + { + $formatter = $this->getFormatter(); + + $event->setCode($this->javascriptTagRenderer->render($formatter->renderClosure( + $event->getCode(), + [], + $this->renderCallback($event->getAutocomplete()) + ))); + } + + /** + * @param Autocomplete $autocomplete + * + * @return string + */ + private function renderCallback(Autocomplete $autocomplete) + { + return $this->callbackRenderer->render($autocomplete->getVariable()); + } +} diff --git a/src/Helper/Subscriber/Place/AutocompleteSubscriber.php b/src/Helper/Subscriber/Place/AutocompleteSubscriber.php new file mode 100644 index 00000000..faa3cc47 --- /dev/null +++ b/src/Helper/Subscriber/Place/AutocompleteSubscriber.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Place; + +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class AutocompleteSubscriber extends AbstractSubscriber +{ + /** + * @var AutocompleteRenderer + */ + private $autocompleteRenderer; + + /** + * @param Formatter $formatter + * @param AutocompleteRenderer $autocompleteRenderer + */ + public function __construct(Formatter $formatter, AutocompleteRenderer $autocompleteRenderer) + { + parent::__construct($formatter); + + $this->setAutocompleteRenderer($autocompleteRenderer); + } + + /** + * @return AutocompleteRenderer + */ + public function getAutocompleteRenderer() + { + return $this->autocompleteRenderer; + } + + /** + * @param AutocompleteRenderer $autocompleteRenderer + */ + public function setAutocompleteRenderer(AutocompleteRenderer $autocompleteRenderer) + { + $this->autocompleteRenderer = $autocompleteRenderer; + } + + /** + * @param PlaceAutocompleteEvent $event + */ + public function handleAutocomplete(PlaceAutocompleteEvent $event) + { + $autocomplete = $event->getAutocomplete(); + + $event->addCode($this->getFormatter()->renderContainerAssignment( + $autocomplete, + $this->autocompleteRenderer->render($autocomplete), + 'autocomplete' + )); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [PlaceAutocompleteEvents::JAVASCRIPT_AUTOCOMPLETE => 'handleAutocomplete']; + } +} diff --git a/src/Helper/Subscriber/Place/Base/AutocompleteBaseSubscriber.php b/src/Helper/Subscriber/Place/Base/AutocompleteBaseSubscriber.php new file mode 100644 index 00000000..e12e6c86 --- /dev/null +++ b/src/Helper/Subscriber/Place/Base/AutocompleteBaseSubscriber.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Place\Base; + +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Helper\Subscriber\AbstractDelegateSubscriber; + +/** + * @author GeLo + */ +class AutocompleteBaseSubscriber extends AbstractDelegateSubscriber +{ + /** + * {@inheritdoc} + */ + public static function getDelegatedSubscribedEvents() + { + return [ + PlaceAutocompleteEvents::JAVASCRIPT_BASE => [ + PlaceAutocompleteEvents::JAVASCRIPT_BASE_COORDINATE, + PlaceAutocompleteEvents::JAVASCRIPT_BASE_BOUND, + ], + ]; + } +} diff --git a/src/Helper/Subscriber/Place/Base/AutocompleteBoundSubscriber.php b/src/Helper/Subscriber/Place/Base/AutocompleteBoundSubscriber.php new file mode 100644 index 00000000..2af6c4ae --- /dev/null +++ b/src/Helper/Subscriber/Place/Base/AutocompleteBoundSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Place\Base; + +use Ivory\GoogleMap\Helper\Collector\Place\AutocompleteBoundCollector; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Base\BoundRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class AutocompleteBoundSubscriber extends AbstractSubscriber +{ + /** + * @var AutocompleteBoundCollector + */ + private $boundCollector; + + /** + * @var BoundRenderer + */ + private $boundRenderer; + + /** + * @param Formatter $formatter + * @param AutocompleteBoundCollector $boundCollector + * @param BoundRenderer $boundRenderer + */ + public function __construct( + Formatter $formatter, + AutocompleteBoundCollector $boundCollector, + BoundRenderer $boundRenderer + ) { + parent::__construct($formatter); + + $this->setBoundCollector($boundCollector); + $this->setBoundRenderer($boundRenderer); + } + + /** + * @return AutocompleteBoundCollector + */ + public function getBoundCollector() + { + return $this->boundCollector; + } + + /** + * @param AutocompleteBoundCollector $boundCollector + */ + public function setBoundCollector(AutocompleteBoundCollector $boundCollector) + { + $this->boundCollector = $boundCollector; + } + + /** + * @return BoundRenderer + */ + public function getBoundRenderer() + { + return $this->boundRenderer; + } + + /** + * @param BoundRenderer $boundRenderer + */ + public function setBoundRenderer(BoundRenderer $boundRenderer) + { + $this->boundRenderer = $boundRenderer; + } + + /** + * @param PlaceAutocompleteEvent $event + */ + public function handleAutocomplete(PlaceAutocompleteEvent $event) + { + $formatter = $this->getFormatter(); + $autocomplete = $event->getAutocomplete(); + + foreach ($this->boundCollector->collect($autocomplete) as $bound) { + $event->addCode($formatter->renderContainerAssignment( + $autocomplete, + $this->boundRenderer->render($bound), + 'base.bounds', + $bound + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [PlaceAutocompleteEvents::JAVASCRIPT_BASE_BOUND => 'handleAutocomplete']; + } +} diff --git a/src/Helper/Subscriber/Place/Base/AutocompleteCoordinateSubscriber.php b/src/Helper/Subscriber/Place/Base/AutocompleteCoordinateSubscriber.php new file mode 100644 index 00000000..bed6ac79 --- /dev/null +++ b/src/Helper/Subscriber/Place/Base/AutocompleteCoordinateSubscriber.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Place\Base; + +use Ivory\GoogleMap\Helper\Collector\Place\AutocompleteCoordinateCollector; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Base\CoordinateRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class AutocompleteCoordinateSubscriber extends AbstractSubscriber +{ + /** + * @var AutocompleteCoordinateCollector + */ + private $coordinateCollector; + + /** + * @var CoordinateRenderer + */ + private $coordinateRenderer; + + /** + * @param Formatter $formatter + * @param AutocompleteCoordinateCollector $coordinateCollector + * @param CoordinateRenderer $coordinateRenderer + */ + public function __construct( + Formatter $formatter, + AutocompleteCoordinateCollector $coordinateCollector, + CoordinateRenderer $coordinateRenderer + ) { + parent::__construct($formatter); + + $this->setCoordinateCollector($coordinateCollector); + $this->setCoordinateRenderer($coordinateRenderer); + } + + /** + * @return AutocompleteCoordinateCollector + */ + public function getCoordinateCollector() + { + return $this->coordinateCollector; + } + + /** + * @param AutocompleteCoordinateCollector $coordinateCollector + */ + public function setCoordinateCollector(AutocompleteCoordinateCollector $coordinateCollector) + { + $this->coordinateCollector = $coordinateCollector; + } + + /** + * @return CoordinateRenderer + */ + public function getCoordinateRenderer() + { + return $this->coordinateRenderer; + } + + /** + * @param CoordinateRenderer $coordinateRenderer + */ + public function setCoordinateRenderer(CoordinateRenderer $coordinateRenderer) + { + $this->coordinateRenderer = $coordinateRenderer; + } + + /** + * @param PlaceAutocompleteEvent $event + */ + public function handleAutocomplete(PlaceAutocompleteEvent $event) + { + $formatter = $this->getFormatter(); + $autocomplete = $event->getAutocomplete(); + + foreach ($this->coordinateCollector->collect($autocomplete) as $coordinate) { + $event->addCode($formatter->renderContainerAssignment( + $autocomplete, + $this->coordinateRenderer->render($coordinate), + 'base.coordinates', + $coordinate + )); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [PlaceAutocompleteEvents::JAVASCRIPT_BASE_COORDINATE => 'handleAutocomplete']; + } +} diff --git a/src/Helper/Subscriber/Utility/ObjectToArraySubscriber.php b/src/Helper/Subscriber/Utility/ObjectToArraySubscriber.php new file mode 100644 index 00000000..d736883c --- /dev/null +++ b/src/Helper/Subscriber/Utility/ObjectToArraySubscriber.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Helper\Subscriber\Utility; + +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Helper\Event\MapEvents; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Utility\ObjectToArrayRenderer; +use Ivory\GoogleMap\Helper\Subscriber\AbstractSubscriber; + +/** + * @author GeLo + */ +class ObjectToArraySubscriber extends AbstractSubscriber +{ + /** + * @var ObjectToArrayRenderer + */ + private $objectToArrayRenderer; + + /** + * @param Formatter $formatter + * @param ObjectToArrayRenderer $objectToArrayRenderer + */ + public function __construct(Formatter $formatter, ObjectToArrayRenderer $objectToArrayRenderer) + { + parent::__construct($formatter); + + $this->setObjectToArrayRenderer($objectToArrayRenderer); + } + + /** + * @return ObjectToArrayRenderer + */ + public function getObjectToArrayRenderer() + { + return $this->objectToArrayRenderer; + } + + /** + * @param ObjectToArrayRenderer $objectToArrayRenderer + */ + public function setObjectToArrayRenderer(ObjectToArrayRenderer $objectToArrayRenderer) + { + $this->objectToArrayRenderer = $objectToArrayRenderer; + } + + /** + * @param MapEvent $event + */ + public function handleMap(MapEvent $event) + { + $event->addCode($this->getFormatter()->renderContainerAssignment( + $event->getMap(), + $this->objectToArrayRenderer->render(), + 'functions.to_array' + )); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [MapEvents::JAVASCRIPT_INIT_FUNCTION => 'handleMap']; + } +} diff --git a/src/Layer/KmlLayer.php b/src/Layer/KmlLayer.php new file mode 100644 index 00000000..5fbbcdd2 --- /dev/null +++ b/src/Layer/KmlLayer.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Layer; + +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @author GeLo + */ +class KmlLayer implements OptionsAwareInterface, VariableAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var string + */ + private $url; + + /** + * @param string $url + * @param mixed[] $options + */ + public function __construct($url, array $options = []) + { + $this->setVariablePrefix('kml_layer'); + $this->setUrl($url); + $this->addOptions($options); + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + */ + public function setUrl($url) + { + $this->url = $url; + } +} diff --git a/src/Layer/LayerManager.php b/src/Layer/LayerManager.php new file mode 100644 index 00000000..da4bf277 --- /dev/null +++ b/src/Layer/LayerManager.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Layer; + +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class LayerManager +{ + /** + * @var Map|null + */ + private $map; + + /** + * @var KmlLayer[] + */ + private $kmlLayers = []; + + /** + * @return bool + */ + public function hasMap() + { + return $this->map !== null; + } + + /** + * @return Map|null + */ + public function getMap() + { + return $this->map; + } + + /** + * @param Map $map + */ + public function setMap(Map $map) + { + $this->map = $map; + + if ($map->getLayerManager() !== $this) { + $map->setLayerManager($this); + } + } + + /** + * @return bool + */ + public function hasKmlLayers() + { + return !empty($this->kmlLayers); + } + + /** + * @return KmlLayer[] + */ + public function getKmlLayers() + { + return $this->kmlLayers; + } + + /** + * @param KmlLayer[] $kmlLayers + */ + public function setKmlLayers(array $kmlLayers) + { + $this->kmlLayers = []; + $this->addKmlLayers($kmlLayers); + } + + /** + * @param KmlLayer[] $kmlLayers + */ + public function addKmlLayers(array $kmlLayers) + { + foreach ($kmlLayers as $kmlLayer) { + $this->addKmlLayer($kmlLayer); + } + } + + /** + * @param KmlLayer $kmlLayer + * + * @return bool + */ + public function hasKmlLayer(KmlLayer $kmlLayer) + { + return in_array($kmlLayer, $this->kmlLayers, true); + } + + /** + * @param KmlLayer $kmlLayer + */ + public function addKmlLayer(KmlLayer $kmlLayer) + { + if (!$this->hasKmlLayer($kmlLayer)) { + $this->kmlLayers[] = $kmlLayer; + } + } + + /** + * @param KmlLayer $kmlLayer + */ + public function removeKmlLayer(KmlLayer $kmlLayer) + { + unset($this->kmlLayers[array_search($kmlLayer, $this->kmlLayers, true)]); + } +} diff --git a/src/Layers/KMLLayer.php b/src/Layers/KMLLayer.php deleted file mode 100644 index 90742134..00000000 --- a/src/Layers/KMLLayer.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Layers; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Exception\LayerException; - -/** - * KML Layer which describes a google map KML layer. - * - * @author GeLo - */ -class KMLLayer extends AbstractOptionsAsset -{ - /** @var string */ - protected $url; - - /** - * Creates a KML Layer. - * - * @param string $url The KML layer url. - */ - public function __construct($url = null) - { - parent::__construct(); - - $this->setPrefixJavascriptVariable('kml_layer_'); - - if ($url !== null) { - $this->setUrl($url); - } - } - - /** - * Gets the KML Layer URL. - * - * @return string The KML Layer URL. - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the KML Layer URL. - * - * @param string $url The KML layer URL. - * - * @throws \Ivory\GoogleMap\Exception\LayerException If the URL is not valid. - */ - public function setUrl($url) - { - if (!is_string($url)) { - throw LayerException::invalidKmlLayerUrl(); - } - - $this->url = $url; - } -} diff --git a/src/Map.php b/src/Map.php index f93f29ef..e16fdd98 100644 --- a/src/Map.php +++ b/src/Map.php @@ -11,1200 +11,459 @@ namespace Ivory\GoogleMap; -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Base\Coordinate; use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Controls\MapTypeControl; -use Ivory\GoogleMap\Controls\OverviewMapControl; -use Ivory\GoogleMap\Controls\PanControl; -use Ivory\GoogleMap\Controls\RotateControl; -use Ivory\GoogleMap\Controls\ScaleControl; -use Ivory\GoogleMap\Controls\StreetViewControl; -use Ivory\GoogleMap\Controls\ZoomControl; -use Ivory\GoogleMap\Events\EventManager; -use Ivory\GoogleMap\Exception\MapException; -use Ivory\GoogleMap\Layers\KMLLayer; -use Ivory\GoogleMap\Overlays\Circle; -use Ivory\GoogleMap\Overlays\EncodedPolyline; -use Ivory\GoogleMap\Overlays\GroundOverlay; -use Ivory\GoogleMap\Overlays\InfoWindow; -use Ivory\GoogleMap\Overlays\Marker; -use Ivory\GoogleMap\Overlays\MarkerCluster; -use Ivory\GoogleMap\Overlays\Polygon; -use Ivory\GoogleMap\Overlays\Polyline; -use Ivory\GoogleMap\Overlays\Rectangle; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Control\ControlManager; +use Ivory\GoogleMap\Event\EventManager; +use Ivory\GoogleMap\Layer\LayerManager; +use Ivory\GoogleMap\Overlay\OverlayManager; +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; /** - * Map wich describes a google map. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Map + * * @author GeLo */ -class Map extends AbstractJavascriptVariableAsset +class Map implements VariableAwareInterface { - /** @var string */ - protected $htmlContainerId; - - /** @var boolean */ - protected $async; - - /** @var boolean */ - protected $autoZoom; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $center; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** @var array */ - protected $mapOptions; - - /** @var array */ - protected $stylesheetOptions; - - /** @var \Ivory\GoogleMap\Controls\MapTypeControl */ - protected $mapTypeControl; - - /** @var \Ivory\GoogleMap\Controls\OverviewMapControl */ - protected $overviewMapControl; - - /** @var \Ivory\GoogleMap\Controls\PanControl */ - protected $panControl; - - /** @var \Ivory\GoogleMap\Controls\RotateControl */ - protected $rotateControl; - - /** @var \Ivory\GoogleMap\Controls\ScaleControl */ - protected $scaleControl; - - /** @var \Ivory\GoogleMap\Controls\StreetViewControl */ - protected $streetViewControl; - - /** @var \Ivory\GoogleMap\Controls\ZoomControl */ - protected $zoomControl; - - /** @var \Ivory\GoogleMap\Events\EventManager */ - protected $eventManager; - - /** @var \Ivory\GoogleMap\Overlays\MarkerCluster */ - protected $markerCluster; - - /** @var array */ - protected $infoWindows; - - /** @var array */ - protected $polylines; - - /** @var array */ - protected $encodedPolylines; - - /** @var array */ - protected $polygons; - - /** @var array */ - protected $rectangles; - - /** @var array */ - protected $circles; - - /** @var array */ - protected $groundOverlays; - - /** @var array */ - protected $kmlLayers; - - /** @var array */ - protected $libraries; - - /** @var string */ - protected $language; + use VariableAwareTrait; /** - * Creates a map. + * @var string */ - public function __construct() - { - $this->setPrefixJavascriptVariable('map_'); - - $this->htmlContainerId = 'map_canvas'; - $this->async = false; - $this->autoZoom = false; - - $this->center = new Coordinate(); - $this->bound = new Bound(); - $this->eventManager = new EventManager(); - - $this->mapOptions = array( - 'mapTypeId' => MapTypeId::ROADMAP, - 'zoom' => 3, - ); - - $this->stylesheetOptions = array( - 'width' => '300px', - 'height' => '300px', - ); - - $this->markerCluster = new MarkerCluster(); - - $this->infoWindows = array(); - $this->polylines = array(); - $this->encodedPolylines = array(); - $this->polygons = array(); - $this->rectangles = array(); - $this->circles = array(); - $this->groundOverlays = array(); - $this->kmlLayers = array(); - - $this->libraries = array(); - $this->language = 'en'; - } + private $htmlId = 'map_canvas'; /** - * Gets the map HTML container ID. - * - * @return string The map HTML constainer ID. + * @var bool */ - public function getHtmlContainerId() - { - return $this->htmlContainerId; - } + private $autoZoom = false; /** - * Sets the map HTML container ID. - * - * @param string $htmlContainerId The map HTML container ID. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the HTML container ID is not a string. + * @var Coordinate */ - public function setHtmlContainerId($htmlContainerId) - { - if (!is_string($htmlContainerId)) { - throw MapException::invalidHtmlContainerId(); - } - - $this->htmlContainerId = $htmlContainerId; - } + private $center; /** - * Check if the map loading is asynchronous. - * - * @return boolean TRUE if the map loading is asynchronous else FALSE. + * @var Bound */ - public function isAsync() - { - return $this->async; - } + private $bound; /** - * Sets if the map loading is asynchronous. - * - * @param boolean $async TRUE if the map loading is asynchronous else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the async flag is not a boolean. + * @var ControlManager */ - public function setAsync($async) - { - if (!is_bool($async)) { - throw MapException::invalidAsync(); - } - - $this->async = $async; - } + private $controlManager; /** - * Check if the map autozooms. - * - * @return boolean TRUE if the map autozooms else FALSE. + * @var EventManager */ - public function isAutoZoom() - { - return $this->autoZoom; - } + private $eventManager; /** - * Sets if the map autozooms. - * - * @param boolean $autoZoom TRUE if the map autozooms else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the auto zoom flag is not a boolean. + * @var LayerManager */ - public function setAutoZoom($autoZoom) - { - if (!is_bool($autoZoom)) { - throw MapException::invalidAutoZoom(); - } - - $this->autoZoom = $autoZoom; - } + private $layerManager; /** - * Gets the map center. - * - * @return \Ivory\GoogleMap\Base\Coordinate The map center. + * @var OverlayManager */ - public function getCenter() - { - return $this->center; - } + private $overlayManager; /** - * Sets the map center. - * - * Available prototypes: - * - function setCenter(Ivory\GoogleMap\Base\Coordinate $center) - * - function setCenter(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the center is not valid (prototypes). + * @var string[] */ - public function setCenter() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->center = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - $this->center->setLatitude($args[0]); - $this->center->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->center->setNoWrap($args[2]); - } - } else { - throw MapException::invalidCenter(); - } - } + private $libraries = []; /** - * Gets the map bound. - * - * @return \Ivory\GoogleMap\Base\Bound The map bound. + * @var string */ - public function getBound() - { - return $this->bound; - } + private $language = 'en'; /** - * Sets the map bound. - * - * Available prototypes: - * - function setBound(Ivory\GoogleMap\Base\Bound $bound = null) - * - function setBount(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the bound is not valid (prototypes). + * @var mixed[] */ - public function setBound() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Bound)) { - $this->bound = $args[0]; - } elseif ((isset($args[0]) && ($args[0] instanceof Coordinate)) - && (isset($args[1]) && ($args[1] instanceof Coordinate)) - ) { - $this->bound->setSouthWest($args[0]); - $this->bound->setNorthEast($args[1]); - } elseif ((isset($args[0]) && is_numeric($args[0])) - && (isset($args[1]) && is_numeric($args[1])) - && (isset($args[2]) && is_numeric($args[2])) - && (isset($args[3]) && is_numeric($args[3])) - ) { - $this->bound->setSouthWest(new Coordinate($args[0], $args[1])); - $this->bound->setNorthEast(new Coordinate($args[2], $args[3])); - - if (isset($args[4]) && is_bool($args[4])) { - $this->bound->getSouthWest()->setNoWrap($args[4]); - } - - if (isset($args[5]) && is_bool($args[5])) { - $this->bound->getNorthEast()->setNoWrap($args[5]); - } - } elseif (!isset($args[0])) { - $this->bound->setSouthWest(null); - $this->bound->setNorthEast(null); - } else { - throw MapException::invalidBound(); - } - } + private $mapOptions = []; /** - * Checks if the map option exists. - * - * @param string $mapOption The map option. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the map option is not valid. - * - * @return boolean TRUE if the map option exists else FALSE. + * @var string[] */ - public function hasMapOption($mapOption) - { - if (!is_string($mapOption)) { - throw MapException::invalidMapOption(); - } - - return isset($this->mapOptions[$mapOption]); - } - - /** - * Gets the map options - * - * @return array The map options. - */ - public function getMapOptions() - { - return $this->mapOptions; - } + private $stylesheetOptions = []; - /** - * Sets the map options. - * - * @param array $mapOptions The map options. - */ - public function setMapOptions(array $mapOptions) - { - foreach ($mapOptions as $mapOption => $value) { - $this->setMapOption($mapOption, $value); - } - } - - /** - * Gets a specific map option. - * - * @param string $mapOption The map option. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the map option does not exist. - * - * @return mixed The map option value. - */ - public function getMapOption($mapOption) - { - if (!$this->hasMapOption($mapOption)) { - throw MapException::mapOptionDoesNotExist($mapOption); - } - - return $this->mapOptions[$mapOption]; - } - - /** - * Sets a specific map option - * - * @param string $mapOption The map option. - * @param mixed $value The map option value. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the map option is not valid. - */ - public function setMapOption($mapOption, $value) + public function __construct() { - if (!is_string($mapOption)) { - throw MapException::invalidMapOption(); - } - - $this->mapOptions[$mapOption] = $value; + $this->setVariablePrefix('map'); + $this->setCenter(new Coordinate()); + $this->setBound(new Bound()); + $this->setControlManager(new ControlManager()); + $this->setEventManager(new EventManager()); + $this->setOverlayManager(new OverlayManager()); + $this->setLayerManager(new LayerManager()); } /** - * Removes a map option. - * - * @param string $mapOption The map option. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the map option does not exist. + * @return string */ - public function removeMapOption($mapOption) + public function getHtmlId() { - if (!$this->hasMapOption($mapOption)) { - throw MapException::mapOptionDoesNotExist($mapOption); - } - - unset($this->mapOptions[$mapOption]); + return $this->htmlId; } /** - * Checks if the stylesheet option exists. - * - * @param string $stylesheetOption The stylesheet option. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the stylesheet option is not valid. - * - * @return boolean TRUE if the stylesheet option exists else FALSE. + * @param string $htmlId */ - public function hasStylesheetOption($stylesheetOption) + public function setHtmlId($htmlId) { - if (!is_string($stylesheetOption)) { - throw MapException::invalidStylesheetOption(); - } - - return isset($this->stylesheetOptions[$stylesheetOption]); + $this->htmlId = $htmlId; } /** - * Gets the stylesheet options. - * - * @return array The stylesheet options. + * @return bool */ - public function getStylesheetOptions() + public function isAutoZoom() { - return $this->stylesheetOptions; + return $this->autoZoom; } /** - * Sets the stylesheet options. - * - * @param array $stylesheetOptions The stylesheet options. + * @param bool $autoZoom */ - public function setStylesheetOptions(array $stylesheetOptions) + public function setAutoZoom($autoZoom) { - foreach ($stylesheetOptions as $stylesheetOption => $value) { - $this->setStylesheetOption($stylesheetOption, $value); - } + $this->autoZoom = $autoZoom; } /** - * Gets a specific stylesheet option. - * - * @param string $stylesheetOption The stylesheet option. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the stylesheet option does not exist. - * - * @return mixed The stylesheet option value. + * @return Coordinate */ - public function getStylesheetOption($stylesheetOption) + public function getCenter() { - if (!$this->hasStylesheetOption($stylesheetOption)) { - throw MapException::stylesheetOptionDoesNotExist($stylesheetOption); - } - - return $this->stylesheetOptions[$stylesheetOption]; + return $this->center; } /** - * Sets a specific stylesheet option. - * - * @param string $stylesheetOption The stylesheet option. - * @param mixed $value The stylesheet option value. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the stylesheet option is not valid. + * @param Coordinate $center */ - public function setStylesheetOption($stylesheetOption, $value) + public function setCenter(Coordinate $center) { - if (!is_string($stylesheetOption)) { - throw MapException::invalidStylesheetOption(); - } - - $this->stylesheetOptions[$stylesheetOption] = $value; + $this->center = $center; } /** - * Removes a stylesheet option. - * - * @param string $stylesheetOption The stylesheet option. - * - * @throws \Ivory\GoogleMap\Exception\MapException If the stylesheet option does not exist. + * @return Bound */ - public function removeStylesheetOption($stylesheetOption) + public function getBound() { - if (!$this->hasStylesheetOption($stylesheetOption)) { - throw MapException::stylesheetOptionDoesNotExist($stylesheetOption); - } - - unset($this->stylesheetOptions[$stylesheetOption]); + return $this->bound; } /** - * Checks if the map has a map type control. - * - * @return boolean TRUE if the map has a map type control else FALSE. + * @param Bound $bound */ - public function hasMapTypeControl() + public function setBound(Bound $bound) { - return $this->mapTypeControl !== null; + $this->bound = $bound; } /** - * Gets the map type control. - * - * @return \Ivory\GoogleMap\Controls\MapTypeControl The map type control. + * @return ControlManager */ - public function getMapTypeControl() + public function getControlManager() { - return $this->mapTypeControl; + return $this->controlManager; } /** - * Sets the map type control. - * - * Available prototypes: - * - function setMapTypeControl(Ivory\GoogleMap\Controls\MapTypeControl $mapTypeControl = null) - * - function setMaptypeControl(array $mapTypeIds, string $controlPosition, string $mapTypeControlStyle) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the map type control is not valid (prototypes). + * @param ControlManager $controlManager */ - public function setMapTypeControl() + public function setControlManager(ControlManager $controlManager) { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof MapTypeControl)) { - $this->mapTypeControl = $args[0]; - $this->mapOptions['mapTypeControl'] = true; - } elseif ((isset($args[0]) && is_array($args[0])) - && (isset($args[1]) && is_string($args[1])) - && (isset($args[2]) && is_string($args[2])) - ) { - if ($this->mapTypeControl === null) { - $this->mapTypeControl = new MapTypeControl(); - } + $this->controlManager = $controlManager; - $this->mapTypeControl->setMapTypeIds($args[0]); - $this->mapTypeControl->setControlPosition($args[1]); - $this->mapTypeControl->setMapTypeControlStyle($args[2]); - - $this->mapOptions['mapTypeControl'] = true; - } elseif (!isset($args[0])) { - $this->mapTypeControl = null; - - if (isset($this->mapOptions['mapTypeControl'])) { - unset($this->mapOptions['mapTypeControl']); - } - } else { - throw MapException::invalidMapTypeControl(); + if ($controlManager->getMap() !== $this) { + $controlManager->setMap($this); } } /** - * Checks if the map has an overview map control. - * - * @return boolean TRUE if the map has an overview map control else FALSE. - */ - public function hasOverviewMapControl() - { - return $this->overviewMapControl !== null; - } - - /** - * Gets the overview map control. - * - * @return \Ivory\GoogleMap\Controls\OverviewMapControl The overview map control. + * @return EventManager */ - public function getOverviewMapControl() + public function getEventManager() { - return $this->overviewMapControl; + return $this->eventManager; } /** - * Sets the overview map control. - * - * Available prototypes: - * - function setOverviewMapControl(Ivory\GoogleMap\Controls\OverviewMapControl $overviewMapControl = null) - * - function setOverviewMapControl(boolean $opened) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the overview map control is not valid (prototypes). + * @param EventManager $eventManager */ - public function setOverviewMapControl() + public function setEventManager(EventManager $eventManager) { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0]) instanceof OverviewMapControl) { - $this->overviewMapControl = $args[0]; - $this->mapOptions['overviewMapControl'] = true; - } elseif (isset($args[0]) && is_bool($args[0])) { - if ($this->overviewMapControl === null) { - $this->overviewMapControl = new OverviewMapControl(); - } - - $this->overviewMapControl->setOpened($args[0]); - $this->mapOptions['overviewMapControl'] = true; - } elseif (!isset($args[0])) { - $this->overviewMapControl = null; + $this->eventManager = $eventManager; - if (isset($this->mapOptions['overviewMapControl'])) { - unset($this->mapOptions['overviewMapControl']); - } - } else { - throw MapException::invalidOverviewMapControl(); + if ($eventManager->getMap() !== $this) { + $eventManager->setMap($this); } } /** - * Checks if the map has a pan control. - * - * @return boolean TRUE if the map has a pan control else FALSE. - */ - public function hasPanControl() - { - return $this->panControl !== null; - } - - /** - * Gets the map pan control. - * - * @return \Ivory\GoogleMap\Controls\PanControl The map pan control. + * @return LayerManager */ - public function getPanControl() + public function getLayerManager() { - return $this->panControl; + return $this->layerManager; } /** - * Sets the map pan control. - * - * Available prototypes: - * - function setPanControl(Ivory\GoogleMap\Controls\PanControl $panControl = null) - * - function setPanControl(string $controlPosition) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the pan control is not valid (prototypes). + * @param LayerManager $layerManager */ - public function setPanControl() + public function setLayerManager(LayerManager $layerManager) { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof PanControl)) { - $this->panControl = $args[0]; - $this->mapOptions['panControl'] = true; - } elseif (isset($args[0]) && is_string($args[0])) { - if ($this->panControl === null) { - $this->panControl = new PanControl(); - } - - $this->panControl->setControlPosition($args[0]); - $this->mapOptions['panControl'] = true; - } elseif (!isset($args[0])) { - $this->panControl = null; + $this->layerManager = $layerManager; - if (isset($this->mapOptions['panControl'])) { - unset($this->mapOptions['panControl']); - } - } else { - throw MapException::invalidPanControl(); + if ($layerManager->getMap() !== $this) { + $layerManager->setMap($this); } } /** - * Checks if the map has a rotate control. - * - * @return boolean TRUE if the map has a rotate control else FALSE. + * @return OverlayManager */ - public function hasRotateControl() + public function getOverlayManager() { - return $this->rotateControl !== null; + return $this->overlayManager; } /** - * Gets the map rotate control. - * - * @return \Ivory\GoogleMap\Controls\RotateControl The map rotate control. + * @param OverlayManager $overlayManager */ - public function getRotateControl() + public function setOverlayManager(OverlayManager $overlayManager) { - return $this->rotateControl; - } + $this->overlayManager = $overlayManager; - /** - * Sets the map rotate control. - * - * Available prototypes: - * - function setRotateControl(Ivory\GoogleMap\Controls\RotateControl $rotateControl = null) - * - function setRotateControl(string $controlPosition) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the rotate control is not valid (prototypes). - */ - public function setRotateControl() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof RotateControl)) { - $this->rotateControl = $args[0]; - $this->mapOptions['rotateControl'] = true; - } elseif (isset($args[0]) && is_string($args[0])) { - if ($this->rotateControl === null) { - $this->rotateControl = new RotateControl(); - } - - $this->rotateControl->setControlPosition($args[0]); - $this->mapOptions['rotateControl'] = true; - } elseif (!isset($args[0])) { - $this->rotateControl = null; - - if (isset($this->mapOptions['rotateControl'])) { - unset($this->mapOptions['rotateControl']); - } - } else { - throw MapException::invalidRotateControl(); + if ($overlayManager->getMap() !== $this) { + $overlayManager->setMap($this); } } /** - * Checks if the map has a scale control else FALSE. - * - * @return boolean TRUE if the map has a scale control else FALSE. - */ - public function hasScaleControl() - { - return $this->scaleControl !== null; - } - - /** - * Gets the map scale control. - * - * @return \Ivory\GoogleMap\Controls\ScaleControl The map scale control. - */ - public function getScaleControl() - { - return $this->scaleControl; - } - - /** - * Sets the map scale control. - * - * Available prototypes: - * - function setScaleControl(Ivory\GoogleMap\Controls\ScaleControl $scaleControl = null) - * - function setScaleControl(string $controlPosition, string $scaleControlStyle) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the scale control is not valid (prototypes). + * @return bool */ - public function setScaleControl() + public function hasLibraries() { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof ScaleControl)) { - $this->scaleControl = $args[0]; - $this->mapOptions['scaleControl'] = true; - } elseif ((isset($args[0]) && is_string($args[0])) && (isset($args[1]) && is_string($args[1]))) { - if ($this->scaleControl === null) { - $this->scaleControl = new ScaleControl(); - } - - $this->scaleControl->setControlPosition($args[0]); - $this->scaleControl->setScaleControlStyle($args[1]); - - $this->mapOptions['scaleControl'] = true; - } elseif (!isset($args[0])) { - $this->scaleControl = null; - - if (isset($this->mapOptions['scaleControl'])) { - unset($this->mapOptions['scaleControl']); - } - } else { - throw MapException::invalidScaleControl(); - } + return !empty($this->libraries); } /** - * Checks if the map has a street view control. - * - * @return boolean TRUE if the map has a street view control else FALSE. + * @return string[] */ - public function hasStreetViewControl() + public function getLibraries() { - return $this->streetViewControl !== null; + return $this->libraries; } /** - * Gets the map street view control. - * - * @return \Ivory\GoogleMap\Controls\StreetViewControl The map street view control. + * @param string[] $libraries */ - public function getStreetViewControl() + public function setLibraries(array $libraries) { - return $this->streetViewControl; + $this->libraries = []; + $this->addLibraries($libraries); } /** - * Sets the map street view control. - * - * Available prototypes: - * - function setStreetViewControl(Ivory\GoogleMap\Controls\StreetViewControl $streetViewControl = null) - * - function setStreetViewControl(string $controlPosition) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the street view control is not valid (prototypes). + * @param string[] $libraries */ - public function setStreetViewControl() + public function addLibraries(array $libraries) { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof StreetViewControl)) { - $this->streetViewControl = $args[0]; - $this->mapOptions['streetViewControl'] = true; - } elseif (isset($args[0]) && is_string($args[0])) { - if ($this->streetViewControl === null) { - $this->streetViewControl = new StreetViewControl(); - } - - $this->streetViewControl->setControlPosition($args[0]); - $this->mapOptions['streetViewControl'] = true; - } elseif (!isset($args[0])) { - $this->streetViewControl = null; - - if (isset($this->mapOptions['streetViewControl'])) { - unset($this->mapOptions['streetViewControl']); - } - } else { - throw MapException::invalidStreetViewControl(); + foreach ($libraries as $library) { + $this->addLibrary($library); } } /** - * Checks if the map has a zoom control. - * - * @return boolean TRUE if the map has a zoom control else FALSE. - */ - public function hasZoomControl() - { - return $this->zoomControl !== null; - } - - /** - * Gets the map zoom control. + * @param string $library * - * @return \Ivory\GoogleMap\Controls\ZoomControl The map zoom control. + * @return bool */ - public function getZoomControl() + public function hasLibrary($library) { - return $this->zoomControl; + return in_array($library, $this->libraries, true); } /** - * Sets the map zoom control. - * - * Available prototypes: - * - function setZoomControl(Ivory\GoogleMap\Controls\ZoomControl $zoomControl = null) - * - function setZoomControl(string $controlPosition, string $zoomControlStyle) - * - * @throws \Ivory\GoogleMap\Exception\MapException If the zoom control is not valid (prototypes). + * @param string $library */ - public function setZoomControl() + public function addLibrary($library) { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof ZoomControl)) { - $this->zoomControl = $args[0]; - $this->mapOptions['zoomControl'] = true; - } elseif ((isset($args[0]) && is_string($args[0])) && (isset($args[1]) && is_string($args[1]))) { - if ($this->zoomControl === null) { - $this->zoomControl = new ZoomControl(); - } - - $this->zoomControl->setControlPosition($args[0]); - $this->zoomControl->setZoomControlStyle($args[1]); - - $this->mapOptions['zoomControl'] = true; - } elseif (!isset($args[0])) { - $this->zoomControl = null; - - if (isset($this->mapOptions['zoomControl'])) { - unset($this->mapOptions['zoomControl']); - } - } else { - throw MapException::invalidZoomControl(); + if (!$this->hasLibrary($library)) { + $this->libraries[] = $library; } } /** - * Gets the map event manager. - * - * @return \Ivory\GoogleMap\Events\EventManager The map event manager. - */ - public function getEventManager() - { - return $this->eventManager; - } - - /** - * Sets the map event manager. - * - * @param \Ivory\GoogleMap\Events\EventManager $eventManager The map event manager. - */ - public function setEventManager(EventManager $eventManager) - { - $this->eventManager = $eventManager; - } - - /** - * Gets the marker cluster. - * - * @return \Ivory\GoogleMap\Overlays\MarkerCluster The marker cluster. + * @param string $library */ - public function getMarkerCluster() + public function removeLibrary($library) { - return $this->markerCluster; + unset($this->libraries[array_search($library, $this->libraries, true)]); } /** - * Sets the marker cluster. - * - * @param \Ivory\GoogleMap\Overlays\MarkerCluster $markerCluster The marker cluster. + * @return string */ - public function setMarkerCluster(MarkerCluster $markerCluster) - { - $this->markerCluster = $markerCluster; - } - - /** - * Gets the map markers. - * - * @return array The map markers. - */ - public function getMarkers() - { - return $this->markerCluster->getMarkers(); - } - - /** - * Add a map marker. - * - * @param \Ivory\GoogleMap\Overlays\Marker $marker The marker to add. - */ - public function addMarker(Marker $marker) + public function getLanguage() { - $this->markerCluster->addMarker($marker); - - if ($this->autoZoom) { - $this->bound->extend($marker); - } + return $this->language; } /** - * Gets the map info windows. - * - * @return array The map info windows. + * @param string $language */ - public function getInfoWindows() + public function setLanguage($language) { - return $this->infoWindows; + $this->language = $language; } /** - * Add a map info window. - * - * @param \Ivory\GoogleMap\Overlays\InfoWindow $infoWindow The info window to add. + * @return bool */ - public function addInfoWindow(InfoWindow $infoWindow) + public function hasMapOptions() { - $this->infoWindows[] = $infoWindow; - - if ($this->autoZoom) { - $this->bound->extend($infoWindow); - } + return !empty($this->mapOptions); } /** - * Gets the map polylines. - * - * @return array The map polylines. + * @return mixed[] */ - public function getPolylines() - { - return $this->polylines; - } - - /** - * Add a map polyline. - * - * @param \Ivory\GoogleMap\Overlays\Polyline The polyline to add. - */ - public function addPolyline(Polyline $polyline) + public function getMapOptions() { - $this->polylines[] = $polyline; - - if ($this->autoZoom) { - $this->bound->extend($polyline); - } + return $this->mapOptions; } /** - * Gets the map encoded polylines. - * - * @return array The map encoded polylines. + * @param mixed[] $mapOptions */ - public function getEncodedPolylines() + public function setMapOptions(array $mapOptions) { - return $this->encodedPolylines; + $this->mapOptions = []; + $this->addMapOptions($mapOptions); } /** - * Adds an encoded polyline to the map. - * - * @param \Ivory\GoogleMap\Overlays\EncodedPolyline $encodedPolyline The encoded polyline to add. + * @param mixed[] $mapOptions */ - public function addEncodedPolyline(EncodedPolyline $encodedPolyline) + public function addMapOptions(array $mapOptions) { - $this->encodedPolylines[] = $encodedPolyline; - - if ($this->autoZoom) { - $this->bound->extend($encodedPolyline); + foreach ($mapOptions as $mapOption => $value) { + $this->setMapOption($mapOption, $value); } } /** - * Gets the map polygons. + * @param string $mapOption * - * @return array The map polygons. + * @return bool */ - public function getPolygons() + public function hasMapOption($mapOption) { - return $this->polygons; + return isset($this->mapOptions[$mapOption]); } /** - * Add a map polygon. + * @param string $mapOption * - * @param \Ivory\GoogleMap\Overlays\Polygon $polygon The polygon to add. + * @return mixed */ - public function addPolygon(Polygon $polygon) + public function getMapOption($mapOption) { - $this->polygons[] = $polygon; - - if ($this->autoZoom) { - $this->bound->extend($polygon); - } + return $this->hasMapOption($mapOption) ? $this->mapOptions[$mapOption] : null; } /** - * Gets the map rectangles. - * - * @return array The map rectangles. + * @param string $mapOption + * @param mixed $value */ - public function getRectangles() + public function setMapOption($mapOption, $value) { - return $this->rectangles; + $this->mapOptions[$mapOption] = $value; } /** - * Add a map rectangle to the map. - * - * @param \Ivory\GoogleMap\Overlays\Rectangle $rectangle The rectangle to add. + * @param string $mapOption */ - public function addRectangle(Rectangle $rectangle) + public function removeMapOption($mapOption) { - $this->rectangles[] = $rectangle; - - if ($this->autoZoom) { - $this->bound->extend($rectangle); - } + unset($this->mapOptions[$mapOption]); } /** - * Gets the map circles - * - * @return array The map circles. + * @return bool */ - public function getCircles() + public function hasStylesheetOptions() { - return $this->circles; + return !empty($this->stylesheetOptions); } /** - * Add a circle to the map. - * - * @param \Ivory\GoogleMap\Overlays\Circle $circle The circle to add. + * @return string[] */ - public function addCircle(Circle $circle) + public function getStylesheetOptions() { - $this->circles[] = $circle; - - if ($this->autoZoom) { - $this->bound->extend($circle); - } + return $this->stylesheetOptions; } /** - * Gets the map ground overlays. - * - * @return array The map ground overlays. + * @param string[] $stylesheetOptions */ - public function getGroundOverlays() + public function setStylesheetOptions(array $stylesheetOptions) { - return $this->groundOverlays; + $this->stylesheetOptions = []; + $this->addStylesheetOptions($stylesheetOptions); } /** - * Add a ground overlay to the map. - * - * @param \Ivory\GoogleMapBundle\Model\Overlays\GroupOverlay $groundOverlay The ground overlay to add. + * @param string[] $stylesheetOptions */ - public function addGroundOverlay(GroundOverlay $groundOverlay) + public function addStylesheetOptions(array $stylesheetOptions) { - $this->groundOverlays[] = $groundOverlay; - - if ($this->autoZoom) { - $this->bound->extend($groundOverlay); + foreach ($stylesheetOptions as $stylesheetOption => $value) { + $this->setStylesheetOption($stylesheetOption, $value); } } /** - * Gets the KML layers. - * - * @return array The KML layers. - */ - public function getKMLLayers() - { - return $this->kmlLayers; - } - - /** - * Adds a KML Layer to the map. - * - * @param \Ivory\GoogleMap\Layers\KMLLayer $kmlLayer The KML Layer to add. - */ - public function addKMLLayer(KMLLayer $kmlLayer) - { - $this->kmlLayers[] = $kmlLayer; - } - - /** - * Checks if the map has libraries. + * @param string $stylesheetOption * - * @return boolean TRUE if the map has libraries else FALSE. + * @return bool */ - public function hasLibraries() - { - return !empty($this->libraries); - } - - /** - * Gets the map libraries. - * - * @return array The map libraries. - */ - public function getLibraries() + public function hasStylesheetOption($stylesheetOption) { - return $this->libraries; + return isset($this->stylesheetOptions[$stylesheetOption]); } /** - * Sets the map libraries. + * @param string $stylesheetOption * - * @param array $libraries The map libraries. + * @return string|null */ - public function setLibraries(array $libraries) + public function getStylesheetOption($stylesheetOption) { - $this->libraries = $libraries; + return $this->hasStylesheetOption($stylesheetOption) ? $this->stylesheetOptions[$stylesheetOption] : null; } /** - * Gets the map language. - * - * @return string The map language. + * @param string $stylesheetOption + * @param string $value */ - public function getLanguage() + public function setStylesheetOption($stylesheetOption, $value) { - return $this->language; + $this->stylesheetOptions[$stylesheetOption] = $value; } /** - * Sets the map langauge. - * - * @param string $language The map langauge. + * @param string $stylesheetOption */ - public function setLanguage($language) + public function removeStylesheetOption($stylesheetOption) { - $this->language = $language; + unset($this->stylesheetOptions[$stylesheetOption]); } } diff --git a/src/MapTypeId.php b/src/MapTypeId.php index b02ae434..4e4836ea 100644 --- a/src/MapTypeId.php +++ b/src/MapTypeId.php @@ -12,12 +12,11 @@ namespace Ivory\GoogleMap; /** - * Map type ID which describes a google map type ID. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeId + * * @author GeLo */ -class MapTypeId +final class MapTypeId { const HYBRID = 'hybrid'; const ROADMAP = 'roadmap'; @@ -25,27 +24,9 @@ class MapTypeId const TERRAIN = 'terrain'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available map type IDs. - * - * @return array The map type IDs. - */ - public static function getMapTypeIds() + private function __construct() { - return array( - self::HYBRID, - self::ROADMAP, - self::SATELLITE, - self::TERRAIN, - ); } } diff --git a/src/Overlays/Animation.php b/src/Overlay/Animation.php similarity index 54% rename from src/Overlays/Animation.php rename to src/Overlay/Animation.php index bcdfc508..b1076461 100644 --- a/src/Overlays/Animation.php +++ b/src/Overlay/Animation.php @@ -9,39 +9,22 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Overlays; +namespace Ivory\GoogleMap\Overlay; /** - * Animation which describes a google map animation. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Animation + * * @author GeLo */ -class Animation +final class Animation { const BOUNCE = 'bounce'; const DROP = 'drop'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available animations. - * - * @return array The animations. - */ - public static function getAnimations() + private function __construct() { - return array( - self::BOUNCE, - self::DROP, - ); } } diff --git a/src/Overlay/Circle.php b/src/Overlay/Circle.php new file mode 100644 index 00000000..593a4daa --- /dev/null +++ b/src/Overlay/Circle.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Circle + * + * @author GeLo + */ +class Circle implements ExtendableInterface, OptionsAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var Coordinate + */ + private $center; + + /** + * @var float + */ + private $radius; + + /** + * @param Coordinate $center + * @param float $radius + * @param mixed[] $options + */ + public function __construct(Coordinate $center, $radius = 1.0, array $options = []) + { + $this->setVariablePrefix('circle'); + $this->setCenter($center); + $this->setRadius($radius); + $this->addOptions($options); + } + + /** + * @return Coordinate + */ + public function getCenter() + { + return $this->center; + } + + /** + * @param Coordinate $center + */ + public function setCenter(Coordinate $center) + { + $this->center = $center; + } + + /** + * @return float + */ + public function getRadius() + { + return $this->radius; + } + + /** + * @param float $radius + */ + public function setRadius($radius) + { + $this->radius = $radius; + } +} diff --git a/src/Overlay/EncodedPolyline.php b/src/Overlay/EncodedPolyline.php new file mode 100644 index 00000000..a336814a --- /dev/null +++ b/src/Overlay/EncodedPolyline.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @see http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html + * + * @author GeLo + */ +class EncodedPolyline implements ExtendableInterface, OptionsAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var string + */ + private $value; + + /** + * @param string $value + * @param mixed[] $options + */ + public function __construct($value, array $options = []) + { + $this->setVariablePrefix('encoded_polyline'); + $this->setValue($value); + $this->addOptions($options); + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * @param string $value + */ + public function setValue($value) + { + $this->value = $value; + } +} diff --git a/src/Exception/Exception.php b/src/Overlay/ExtendableInterface.php similarity index 66% rename from src/Exception/Exception.php rename to src/Overlay/ExtendableInterface.php index 35c6c35b..9f35347b 100644 --- a/src/Exception/Exception.php +++ b/src/Overlay/ExtendableInterface.php @@ -9,15 +9,13 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Exception; +namespace Ivory\GoogleMap\Overlay; -use Exception as BaseException; +use Ivory\GoogleMap\Utility\VariableAwareInterface; /** - * Ivory google map exception. - * * @author GeLo */ -class Exception extends BaseException +interface ExtendableInterface extends VariableAwareInterface { } diff --git a/src/Overlay/GroundOverlay.php b/src/Overlay/GroundOverlay.php new file mode 100644 index 00000000..58f8f1a1 --- /dev/null +++ b/src/Overlay/GroundOverlay.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GroundOverlay + * + * @author GeLo + */ +class GroundOverlay implements ExtendableInterface, OptionsAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var string + */ + private $url; + + /** + * @var Bound + */ + private $bound; + + /** + * @param string $url + * @param Bound $bound + * @param mixed[] $options + */ + public function __construct($url, Bound $bound, array $options = []) + { + $this->setVariablePrefix('ground_overlay'); + $this->setUrl($url); + $this->setBound($bound); + $this->addOptions($options); + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * @return Bound + */ + public function getBound() + { + return $this->bound; + } + + /** + * @param Bound $bound + */ + public function setBound(Bound $bound) + { + $this->bound = $bound; + } +} diff --git a/src/Overlay/Icon.php b/src/Overlay/Icon.php new file mode 100644 index 00000000..972c8aff --- /dev/null +++ b/src/Overlay/Icon.php @@ -0,0 +1,181 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Base\Size; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Icon + * + * @author GeLo + */ +class Icon +{ + /** + * @var string + */ + private $url; + + /** + * @var Point|null + */ + private $anchor; + + /** + * @var Point|null + */ + private $origin; + + /** + * @var Size|null + */ + private $scaledSize; + + /** + * @var Size|null + */ + private $size; + + /** + * @param string $url + * @param Point|null $anchor + * @param Point|null $origin + * @param Size|null $scaledSize + * @param Size|null $size + */ + public function __construct( + $url = 'https://maps.gstatic.com/mapfiles/markers/marker.png', + Point $anchor = null, + Point $origin = null, + Size $scaledSize = null, + Size $size = null + ) { + $this->setUrl($url); + $this->setAnchor($anchor); + $this->setOrigin($origin); + $this->setScaledSize($scaledSize); + $this->setSize($size); + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * @return bool + */ + public function hasAnchor() + { + return $this->anchor !== null; + } + + /** + * @return Point|null + */ + public function getAnchor() + { + return $this->anchor; + } + + /** + * @param Point|null $anchor + */ + public function setAnchor(Point $anchor = null) + { + $this->anchor = $anchor; + } + + /** + * @return bool + */ + public function hasOrigin() + { + return $this->origin !== null; + } + + /** + * @return Point|null + */ + public function getOrigin() + { + return $this->origin; + } + + /** + * @param Point|null $origin + */ + public function setOrigin(Point $origin = null) + { + $this->origin = $origin; + } + + /** + * @return bool + */ + public function hasScaledSize() + { + return $this->scaledSize !== null; + } + + /** + * @return Size|null + */ + public function getScaledSize() + { + return $this->scaledSize; + } + + /** + * @param Size|null $scaledSize + */ + public function setScaledSize(Size $scaledSize = null) + { + $this->scaledSize = $scaledSize; + } + + /** + * @return bool + */ + public function hasSize() + { + return $this->size !== null; + } + + /** + * @return Size|null + */ + public function getSize() + { + return $this->size; + } + + /** + * @param Size|null $size + */ + public function setSize(Size $size = null) + { + $this->size = $size; + } +} diff --git a/src/Overlay/InfoWindow.php b/src/Overlay/InfoWindow.php new file mode 100644 index 00000000..15e8e443 --- /dev/null +++ b/src/Overlay/InfoWindow.php @@ -0,0 +1,227 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Event\MouseEvent; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#InfoWindow + * + * @author GeLo + */ +class InfoWindow implements ExtendableInterface, OptionsAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var string + */ + private $content; + + /** + * @var string + */ + private $type = InfoWindowType::DEFAULT_; + + /** + * @var Coordinate|null + */ + private $position; + + /** + * @var Size|null + */ + private $pixedOffset; + + /** + * @var bool + */ + private $open = false; + + /** + * @var string + */ + private $openEvent = MouseEvent::CLICK; + + /** + * @var bool + */ + private $autoOpen = true; + + /** + * @var bool + */ + private $autoClose = true; + + /** + * @param string $content + * @param string $type + * @param Coordinate|null $position + */ + public function __construct($content, $type = InfoWindowType::DEFAULT_, Coordinate $position = null) + { + $this->setVariablePrefix('info_window'); + $this->setContent($content); + $this->setType($type); + $this->setPosition($position); + } + + /** + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * @param string $content + */ + public function setContent($content) + { + $this->content = $content; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return bool + */ + public function hasPosition() + { + return $this->position !== null; + } + + /** + * @return Coordinate|null + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param Coordinate|null $position + */ + public function setPosition(Coordinate $position = null) + { + $this->position = $position; + } + + /** + * @return bool + */ + public function hasPixelOffset() + { + return $this->pixedOffset !== null; + } + + /** + * @return Size|null + */ + public function getPixelOffset() + { + return $this->pixedOffset; + } + + /** + * @param Size|null $pixelOffset + */ + public function setPixelOffset(Size $pixelOffset = null) + { + $this->pixedOffset = $pixelOffset; + } + + /** + * @return bool + */ + public function isOpen() + { + return $this->open; + } + + /** + * @param bool $open + */ + public function setOpen($open) + { + $this->open = $open; + } + + /** + * @return bool + */ + public function isAutoOpen() + { + return $this->autoOpen; + } + + /** + * @param bool $autoOpen + */ + public function setAutoOpen($autoOpen) + { + $this->autoOpen = $autoOpen; + } + + /** + * @return string + */ + public function getOpenEvent() + { + return $this->openEvent; + } + + /** + * @param string $openEvent + */ + public function setOpenEvent($openEvent) + { + $this->openEvent = $openEvent; + } + + /** + * @return bool + */ + public function isAutoClose() + { + return $this->autoClose; + } + + /** + * @param bool $autoClose + */ + public function setAutoClose($autoClose) + { + $this->autoClose = $autoClose; + } +} diff --git a/src/Overlay/InfoWindowType.php b/src/Overlay/InfoWindowType.php new file mode 100644 index 00000000..061c4656 --- /dev/null +++ b/src/Overlay/InfoWindowType.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +/** + * @author GeLo + */ +final class InfoWindowType +{ + const DEFAULT_ = 'default'; + const INFO_BOX = 'info_box'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Overlay/Marker.php b/src/Overlay/Marker.php new file mode 100644 index 00000000..d212ecb7 --- /dev/null +++ b/src/Overlay/Marker.php @@ -0,0 +1,187 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Marker + * + * @author GeLo + */ +class Marker implements ExtendableInterface, OptionsAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var Coordinate + */ + private $position; + + /** + * @var string|null + */ + private $animation; + + /** + * @var Icon|null + */ + private $icon; + + /** + * @var MarkerShape|null + */ + private $shape; + + /** + * @var InfoWindow|null + */ + private $infoWindow; + + /** + * @param Coordinate $position + * @param string|null $animation + * @param Icon|null $icon + * @param MarkerShape|null $shape + * @param mixed[] $options + */ + public function __construct( + Coordinate $position, + $animation = null, + Icon $icon = null, + MarkerShape $shape = null, + array $options = [] + ) { + $this->setVariablePrefix('marker'); + $this->setPosition($position); + $this->setAnimation($animation); + $this->setIcon($icon); + $this->setShape($shape); + $this->addOptions($options); + } + + /** + * @return Coordinate + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param Coordinate $position + */ + public function setPosition(Coordinate $position) + { + $this->position = $position; + } + + /** + * @return bool + */ + public function hasAnimation() + { + return $this->animation !== null; + } + + /** + * @return string|null + */ + public function getAnimation() + { + return $this->animation; + } + + /** + * @param string|null $animation + */ + public function setAnimation($animation = null) + { + $this->animation = $animation; + } + + /** + * @return bool + */ + public function hasIcon() + { + return $this->icon !== null; + } + + /** + * @return Icon|null + */ + public function getIcon() + { + return $this->icon; + } + + /** + * @param Icon|null $icon + */ + public function setIcon(Icon $icon = null) + { + $this->icon = $icon; + } + + /** + * @return bool + */ + public function hasShape() + { + return $this->shape !== null; + } + + /** + * @return MarkerShape|null + */ + public function getShape() + { + return $this->shape; + } + + /** + * @param MarkerShape|null $shape + */ + public function setShape(MarkerShape $shape = null) + { + $this->shape = $shape; + } + + /** + * @return bool + */ + public function hasInfoWindow() + { + return $this->infoWindow !== null; + } + + /** + * @return InfoWindow|null + */ + public function getInfoWindow() + { + return $this->infoWindow; + } + + /** + * @param InfoWindow|null $infoWindow + */ + public function setInfoWindow(InfoWindow $infoWindow = null) + { + $this->infoWindow = $infoWindow; + } +} diff --git a/src/Overlay/MarkerCluster.php b/src/Overlay/MarkerCluster.php new file mode 100644 index 00000000..ae3b059c --- /dev/null +++ b/src/Overlay/MarkerCluster.php @@ -0,0 +1,190 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @author GeLo + */ +class MarkerCluster implements OptionsAwareInterface, VariableAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var OverlayManager|null + */ + private $overlayManager; + + /** + * @var string + */ + private $type = MarkerClusterType::DEFAULT_; + + /** + * @var Marker[] + */ + private $markers = []; + + public function __construct() + { + $this->setVariablePrefix('marker_cluster'); + } + + /** + * @return bool + */ + public function hasOverlayManager() + { + return $this->overlayManager !== null; + } + + /** + * @return OverlayManager|null + */ + public function getOverlayManager() + { + return $this->overlayManager; + } + + /** + * @param OverlayManager $overlayManager + */ + public function setOverlayManager(OverlayManager $overlayManager) + { + $this->overlayManager = $overlayManager; + + if ($overlayManager->getMarkerCluster() !== $this) { + $overlayManager->setMarkerCluster($this); + } + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return bool + */ + public function hasMarkers() + { + return !empty($this->markers); + } + + /** + * @return Marker[] + */ + public function getMarkers() + { + return $this->markers; + } + + /** + * @param Marker[] $markers + */ + public function setMarkers(array $markers) + { + foreach ($this->markers as $marker) { + $this->removeMarker($marker); + } + + $this->addMarkers($markers); + } + + /** + * @param Marker[] $markers + */ + public function addMarkers(array $markers) + { + foreach ($markers as $marker) { + $this->addMarker($marker); + } + } + + /** + * @param Marker $marker + * + * @return bool + */ + public function hasMarker(Marker $marker) + { + return in_array($marker, $this->markers, true); + } + + /** + * @param Marker $marker + */ + public function addMarker(Marker $marker) + { + if (!$this->hasMarker($marker)) { + $this->markers[] = $marker; + } + + $this->addExtendable($marker); + } + + /** + * @param Marker $marker + */ + public function removeMarker(Marker $marker) + { + unset($this->markers[array_search($marker, $this->markers, true)]); + $this->markers = array_values($this->markers); + $this->removeExtendable($marker); + } + + /** + * @param ExtendableInterface $extendable + */ + private function addExtendable(ExtendableInterface $extendable) + { + if ($this->isAutoZoom()) { + $this->getOverlayManager()->getMap()->getBound()->addExtendable($extendable); + } + } + + /** + * @param ExtendableInterface $extendable + */ + private function removeExtendable(ExtendableInterface $extendable) + { + if ($this->isAutoZoom()) { + $this->getOverlayManager()->getMap()->getBound()->removeExtendable($extendable); + } + } + + /** + * @return bool + */ + private function isAutoZoom() + { + return $this->hasOverlayManager() + && $this->getOverlayManager()->hasMap() + && $this->getOverlayManager()->getMap()->isAutoZoom(); + } +} diff --git a/src/Overlay/MarkerClusterType.php b/src/Overlay/MarkerClusterType.php new file mode 100644 index 00000000..69593a62 --- /dev/null +++ b/src/Overlay/MarkerClusterType.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +/** + * @author GeLo + */ +final class MarkerClusterType +{ + const DEFAULT_ = 'default'; + const MARKER_CLUSTERER = 'marker_clusterer'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Overlay/MarkerShape.php b/src/Overlay/MarkerShape.php new file mode 100644 index 00000000..22c66929 --- /dev/null +++ b/src/Overlay/MarkerShape.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MarkerShape + * + * @author GeLo + */ +class MarkerShape +{ + /** + * @var string + */ + private $type; + + /** + * @var float[] + */ + private $coordinates = []; + + /** + * @param string $type + * @param float[] $coordinates + */ + public function __construct($type, array $coordinates) + { + $this->setType($type); + $this->addCoordinates($coordinates); + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return bool + */ + public function hasCoordinates() + { + return !empty($this->coordinates); + } + + /** + * @return float[] + */ + public function getCoordinates() + { + return $this->coordinates; + } + + /** + * @param float[] $coordinates + */ + public function setCoordinates(array $coordinates) + { + $this->coordinates = []; + $this->addCoordinates($coordinates); + } + + /** + * @param float[] $coordinates + */ + public function addCoordinates(array $coordinates) + { + foreach ($coordinates as $coordinate) { + $this->addCoordinate($coordinate); + } + } + + /** + * @param float $coordinate + * + * @return bool + */ + public function hasCoordinate($coordinate) + { + return in_array($coordinate, $this->coordinates, true); + } + + /** + * @param float $coordinate + */ + public function addCoordinate($coordinate) + { + $this->coordinates[] = $coordinate; + } +} diff --git a/src/Overlay/MarkerShapeType.php b/src/Overlay/MarkerShapeType.php new file mode 100644 index 00000000..864e40af --- /dev/null +++ b/src/Overlay/MarkerShapeType.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +/** + * @author GeLo + */ +final class MarkerShapeType +{ + const POLY = 'poly'; + const CIRCLE = 'circle'; + const RECTANGLE = 'rect'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Overlay/OverlayManager.php b/src/Overlay/OverlayManager.php new file mode 100644 index 00000000..85f413ec --- /dev/null +++ b/src/Overlay/OverlayManager.php @@ -0,0 +1,694 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class OverlayManager +{ + /** + * @var Map|null + */ + private $map; + + /** + * @var MarkerCluster + */ + private $markerCluster; + + /** + * @var InfoWindow[] + */ + private $infoWindows = []; + + /** + * @var Polyline[] + */ + private $polylines = []; + + /** + * @var EncodedPolyline[] + */ + private $encodedPolylines = []; + + /** + * @var Polygon[] + */ + private $polygons = []; + + /** + * @var Rectangle[] + */ + private $rectangles = []; + + /** + * @var Circle[] + */ + private $circles = []; + + /** + * @var GroundOverlay[] + */ + private $groundOverlays = []; + + public function __construct() + { + $this->setMarkerCluster(new MarkerCluster()); + } + + /** + * @return bool + */ + public function hasMap() + { + return $this->map !== null; + } + + /** + * @return Map|null + */ + public function getMap() + { + return $this->map; + } + + /** + * @param Map $map + */ + public function setMap(Map $map) + { + $this->map = $map; + + if ($map->getOverlayManager() !== $this) { + $map->setOverlayManager($this); + } + } + + /** + * @return MarkerCluster + */ + public function getMarkerCluster() + { + return $this->markerCluster; + } + + /** + * @param MarkerCluster $markerCluster + */ + public function setMarkerCluster(MarkerCluster $markerCluster) + { + $this->markerCluster = $markerCluster; + + if ($markerCluster->getOverlayManager() !== $this) { + $markerCluster->setOverlayManager($this); + } + } + + /** + * @return bool + */ + public function hasMarkers() + { + return $this->markerCluster->hasMarkers(); + } + + /** + * @return Marker[] + */ + public function getMarkers() + { + return $this->markerCluster->getMarkers(); + } + + /** + * @param Marker[] $markers + */ + public function setMarkers(array $markers) + { + $this->markerCluster->setMarkers($markers); + } + + /** + * @param Marker[] $markers + */ + public function addMarkers(array $markers) + { + $this->markerCluster->addMarkers($markers); + } + + /** + * @param Marker $marker + * + * @return bool + */ + public function hasMarker(Marker $marker) + { + return $this->markerCluster->hasMarker($marker); + } + + /** + * @param Marker $marker + */ + public function addMarker(Marker $marker) + { + $this->markerCluster->addMarker($marker); + } + + /** + * @param Marker $marker + */ + public function removeMarker(Marker $marker) + { + $this->markerCluster->removeMarker($marker); + } + + /** + * @return bool + */ + public function hasInfoWindows() + { + return !empty($this->infoWindows); + } + + /** + * @return InfoWindow[] + */ + public function getInfoWindows() + { + return $this->infoWindows; + } + + /** + * @param InfoWindow[] $infoWindows + */ + public function setInfoWindows(array $infoWindows) + { + foreach ($this->infoWindows as $infoWindow) { + $this->removeInfoWindow($infoWindow); + } + + $this->addInfoWindows($infoWindows); + } + + /** + * @param InfoWindow[] $infoWindows + */ + public function addInfoWindows(array $infoWindows) + { + foreach ($infoWindows as $infoWindow) { + $this->addInfoWindow($infoWindow); + } + } + + /** + * @param InfoWindow $infoWindow + * + * @return bool + */ + public function hasInfoWindow(InfoWindow $infoWindow) + { + return in_array($infoWindow, $this->infoWindows, true); + } + + /** + * @param InfoWindow $infoWindow + */ + public function addInfoWindow(InfoWindow $infoWindow) + { + if (!$this->hasInfoWindow($infoWindow)) { + $this->infoWindows[] = $infoWindow; + } + + $this->addExtendable($infoWindow); + } + + /** + * @param InfoWindow $infoWindow + */ + public function removeInfoWindow(InfoWindow $infoWindow) + { + unset($this->infoWindows[array_search($infoWindow, $this->infoWindows, true)]); + $this->infoWindows = array_values($this->infoWindows); + $this->removeExtendable($infoWindow); + } + + /** + * @return bool + */ + public function hasPolylines() + { + return !empty($this->polylines); + } + + /** + * @return Polyline[] + */ + public function getPolylines() + { + return $this->polylines; + } + + /** + * @param Polyline[] $polylines + */ + public function setPolylines(array $polylines) + { + foreach ($this->polylines as $polyline) { + $this->removePolyline($polyline); + } + + $this->addPolylines($polylines); + } + + /** + * @param Polyline[] $polylines + */ + public function addPolylines(array $polylines) + { + foreach ($polylines as $polyline) { + $this->addPolyline($polyline); + } + } + + /** + * @param Polyline $polyline + * + * @return bool + */ + public function hasPolyline(Polyline $polyline) + { + return in_array($polyline, $this->polylines, true); + } + + /** + * @param Polyline $polyline + */ + public function addPolyline(Polyline $polyline) + { + if (!$this->hasPolyline($polyline)) { + $this->polylines[] = $polyline; + } + + $this->addExtendable($polyline); + } + + /** + * @param Polyline $polyline + */ + public function removePolyline(Polyline $polyline) + { + unset($this->polylines[array_search($polyline, $this->polylines, true)]); + $this->polylines = array_values($this->polylines); + $this->removeExtendable($polyline); + } + + /** + * @return bool + */ + public function hasEncodedPolylines() + { + return !empty($this->encodedPolylines); + } + + /** + * @return EncodedPolyline[] + */ + public function getEncodedPolylines() + { + return $this->encodedPolylines; + } + + /** + * @param EncodedPolyline[] $encodedPolylines + */ + public function setEncodedPolylines(array $encodedPolylines) + { + foreach ($this->encodedPolylines as $encodedPolyline) { + $this->removeEncodedPolyline($encodedPolyline); + } + + $this->addEncodedPolylines($encodedPolylines); + } + + /** + * @param EncodedPolyline[] $encodedPolylines + */ + public function addEncodedPolylines(array $encodedPolylines) + { + foreach ($encodedPolylines as $encodedPolyline) { + $this->addEncodedPolyline($encodedPolyline); + } + } + + /** + * @param EncodedPolyline $encodedPolyline + * + * @return bool + */ + public function hasEncodedPolyline(EncodedPolyline $encodedPolyline) + { + return in_array($encodedPolyline, $this->encodedPolylines, true); + } + + /** + * @param EncodedPolyline $encodedPolyline + */ + public function addEncodedPolyline(EncodedPolyline $encodedPolyline) + { + if (!$this->hasEncodedPolyline($encodedPolyline)) { + $this->encodedPolylines[] = $encodedPolyline; + } + + $this->addExtendable($encodedPolyline); + } + + /** + * @param EncodedPolyline $encodedPolyline + */ + public function removeEncodedPolyline(EncodedPolyline $encodedPolyline) + { + unset($this->encodedPolylines[array_search($encodedPolyline, $this->encodedPolylines, true)]); + $this->encodedPolylines = array_values($this->encodedPolylines); + $this->removeExtendable($encodedPolyline); + } + + /** + * @return bool + */ + public function hasPolygons() + { + return !empty($this->polygons); + } + + /** + * @return Polygon[] + */ + public function getPolygons() + { + return $this->polygons; + } + + /** + * @param Polygon[] $polygons + */ + public function setPolygons(array $polygons) + { + foreach ($this->polygons as $polygon) { + $this->removePolygon($polygon); + } + + $this->addPolygons($polygons); + } + + /** + * @param Polygon[] $polygons + */ + public function addPolygons(array $polygons) + { + foreach ($polygons as $polygon) { + $this->addPolygon($polygon); + } + } + + /** + * @param Polygon $polygon + * + * @return bool + */ + public function hasPolygon(Polygon $polygon) + { + return in_array($polygon, $this->polygons, true); + } + + /** + * @param Polygon $polygon + */ + public function addPolygon(Polygon $polygon) + { + if (!$this->hasPolygon($polygon)) { + $this->polygons[] = $polygon; + } + + $this->addExtendable($polygon); + } + + /** + * @param Polygon $polygon + */ + public function removePolygon(Polygon $polygon) + { + unset($this->polygons[array_search($polygon, $this->polygons, true)]); + $this->polygons = array_values($this->polygons); + $this->removeExtendable($polygon); + } + + /** + * @return bool + */ + public function hasRectangles() + { + return !empty($this->rectangles); + } + + /** + * @return Rectangle[] + */ + public function getRectangles() + { + return $this->rectangles; + } + + /** + * @param Rectangle[] $rectangles + */ + public function setRectangles(array $rectangles) + { + foreach ($this->rectangles as $rectangle) { + $this->removeRectangle($rectangle); + } + + $this->addRectangles($rectangles); + } + + /** + * @param Rectangle[] $rectangles + */ + public function addRectangles(array $rectangles) + { + foreach ($rectangles as $rectangle) { + $this->addRectangle($rectangle); + } + } + + /** + * @param Rectangle $rectangle + * + * @return bool + */ + public function hasRectangle(Rectangle $rectangle) + { + return in_array($rectangle, $this->rectangles, true); + } + + /** + * @param Rectangle $rectangle + */ + public function addRectangle(Rectangle $rectangle) + { + if (!$this->hasRectangle($rectangle)) { + $this->rectangles[] = $rectangle; + } + + $this->addExtendable($rectangle); + } + + /** + * @param Rectangle $rectangle + */ + public function removeRectangle(Rectangle $rectangle) + { + unset($this->rectangles[array_search($rectangle, $this->rectangles, true)]); + $this->rectangles = array_values($this->rectangles); + $this->removeExtendable($rectangle); + } + + /** + * @return bool + */ + public function hasCircles() + { + return !empty($this->circles); + } + + /** + * @return Circle[] + */ + public function getCircles() + { + return $this->circles; + } + + /** + * @param Circle[] $circles + */ + public function setCircles(array $circles) + { + foreach ($this->circles as $circle) { + $this->removeCircle($circle); + } + + $this->addCircles($circles); + } + + /** + * @param Circle[] $circles + */ + public function addCircles(array $circles) + { + foreach ($circles as $circle) { + $this->addCircle($circle); + } + } + + /** + * @param Circle $circle + * + * @return bool + */ + public function hasCircle(Circle $circle) + { + return in_array($circle, $this->circles, true); + } + + /** + * @param Circle $circle + */ + public function addCircle(Circle $circle) + { + if (!$this->hasCircle($circle)) { + $this->circles[] = $circle; + } + + $this->addExtendable($circle); + } + + /** + * @param Circle $circle + */ + public function removeCircle(Circle $circle) + { + unset($this->circles[array_search($circle, $this->circles, true)]); + $this->circles = array_values($this->circles); + $this->removeExtendable($circle); + } + + /** + * @return bool + */ + public function hasGroundOverlays() + { + return !empty($this->groundOverlays); + } + + /** + * @return GroundOverlay[] + */ + public function getGroundOverlays() + { + return $this->groundOverlays; + } + + /** + * @param GroundOverlay[] $groundOverlays + */ + public function setGroundOverlays(array $groundOverlays) + { + foreach ($this->groundOverlays as $groundOverlay) { + $this->removeGroundOverlay($groundOverlay); + } + + $this->addGroundOverlays($groundOverlays); + } + + /** + * @param GroundOverlay[] $groundOverlays + */ + public function addGroundOverlays(array $groundOverlays) + { + foreach ($groundOverlays as $groundOverlay) { + $this->addGroundOverlay($groundOverlay); + } + } + + /** + * @param GroundOverlay $groundOverlay + * + * @return bool + */ + public function hasGroundOverlay(GroundOverlay $groundOverlay) + { + return in_array($groundOverlay, $this->groundOverlays, true); + } + + /** + * @param GroundOverlay $groundOverlay + */ + public function addGroundOverlay(GroundOverlay $groundOverlay) + { + if (!$this->hasGroundOverlay($groundOverlay)) { + $this->groundOverlays[] = $groundOverlay; + } + + $this->addExtendable($groundOverlay); + } + + /** + * @param GroundOverlay $groundOverlay + */ + public function removeGroundOverlay(GroundOverlay $groundOverlay) + { + unset($this->groundOverlays[array_search($groundOverlay, $this->groundOverlays, true)]); + $this->groundOverlays = array_values($this->groundOverlays); + $this->removeExtendable($groundOverlay); + } + + /** + * @param ExtendableInterface $extendable + */ + private function addExtendable(ExtendableInterface $extendable) + { + if ($this->isAutoZoom()) { + $this->getMap()->getBound()->addExtendable($extendable); + } + } + + /** + * @param ExtendableInterface $extendable + */ + private function removeExtendable(ExtendableInterface $extendable) + { + if ($this->isAutoZoom()) { + $this->getMap()->getBound()->removeExtendable($extendable); + } + } + + /** + * @return bool + */ + private function isAutoZoom() + { + return $this->hasMap() && $this->getMap()->isAutoZoom(); + } +} diff --git a/src/Overlay/Polygon.php b/src/Overlay/Polygon.php new file mode 100644 index 00000000..dd618c82 --- /dev/null +++ b/src/Overlay/Polygon.php @@ -0,0 +1,105 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Polygon + * + * @author GeLo + */ +class Polygon implements ExtendableInterface, OptionsAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var Coordinate[] + */ + private $coordinates = []; + + /** + * @param Coordinate[] $coordinates + * @param mixed[] $options + */ + public function __construct(array $coordinates = [], array $options = []) + { + $this->setVariablePrefix('polygon'); + $this->addCoordinates($coordinates); + $this->addOptions($options); + } + + /** + * @return bool + */ + public function hasCoordinates() + { + return !empty($this->coordinates); + } + + /** + * @return Coordinate[] + */ + public function getCoordinates() + { + return $this->coordinates; + } + + /** + * @param Coordinate[] $coordinates + */ + public function setCoordinates(array $coordinates) + { + $this->coordinates = []; + $this->addCoordinates($coordinates); + } + + /** + * @param Coordinate[] $coordinates + */ + public function addCoordinates(array $coordinates) + { + foreach ($coordinates as $coordinate) { + $this->addCoordinate($coordinate); + } + } + + /** + * @param Coordinate $coordinate + * + * @return bool + */ + public function hasCoordinate(Coordinate $coordinate) + { + return in_array($coordinate, $this->coordinates, true); + } + + /** + * @param Coordinate $coordinate + */ + public function addCoordinate(Coordinate $coordinate) + { + $this->coordinates[] = $coordinate; + } + + /** + * @param Coordinate $coordinate + */ + public function removeCoordinate(Coordinate $coordinate) + { + unset($this->coordinates[array_search($coordinate, $this->coordinates, true)]); + } +} diff --git a/src/Overlay/Polyline.php b/src/Overlay/Polyline.php new file mode 100644 index 00000000..eb2e85a2 --- /dev/null +++ b/src/Overlay/Polyline.php @@ -0,0 +1,105 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Polyline + * + * @author GeLo + */ +class Polyline implements ExtendableInterface, OptionsAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var Coordinate[] + */ + private $coordinates = []; + + /** + * @param Coordinate[] $coordinates + * @param mixed[] $options + */ + public function __construct(array $coordinates = [], array $options = []) + { + $this->setVariablePrefix('polyline'); + $this->addCoordinates($coordinates); + $this->addOptions($options); + } + + /** + * @return bool + */ + public function hasCoordinates() + { + return !empty($this->coordinates); + } + + /** + * @return Coordinate[] + */ + public function getCoordinates() + { + return $this->coordinates; + } + + /** + * @param Coordinate[] $coordinates + */ + public function setCoordinates($coordinates) + { + $this->coordinates = []; + $this->addCoordinates($coordinates); + } + + /** + * @param Coordinate[] $coordinates + */ + public function addCoordinates($coordinates) + { + foreach ($coordinates as $coordinate) { + $this->addCoordinate($coordinate); + } + } + + /** + * @param Coordinate $coordinate + * + * @return bool + */ + public function hasCoordinate(Coordinate $coordinate) + { + return in_array($coordinate, $this->coordinates, true); + } + + /** + * @param Coordinate $coordinate + */ + public function addCoordinate(Coordinate $coordinate) + { + $this->coordinates[] = $coordinate; + } + + /** + * @param Coordinate $coordinate + */ + public function removeCoordinate(Coordinate $coordinate) + { + unset($this->coordinates[array_search($coordinate, $this->coordinates, true)]); + } +} diff --git a/src/Overlay/Rectangle.php b/src/Overlay/Rectangle.php new file mode 100644 index 00000000..681c72ec --- /dev/null +++ b/src/Overlay/Rectangle.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @author GeLo + */ +class Rectangle implements ExtendableInterface, OptionsAwareInterface +{ + use OptionsAwareTrait; + use VariableAwareTrait; + + /** + * @var Bound + */ + private $bound; + + /** + * @param Bound $bound + * @param mixed[] $options + */ + public function __construct(Bound $bound, array $options = []) + { + $this->setVariablePrefix('rectangle'); + $this->setBound($bound); + $this->addOptions($options); + } + + /** + * @return Bound + */ + public function getBound() + { + return $this->bound; + } + + /** + * @param Bound $bound + */ + public function setBound(Bound $bound) + { + $this->bound = $bound; + } +} diff --git a/src/Overlays/Circle.php b/src/Overlays/Circle.php deleted file mode 100644 index c4610253..00000000 --- a/src/Overlays/Circle.php +++ /dev/null @@ -1,114 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Circle which describes a google map circle. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Circle - * @author GeLo - */ -class Circle extends AbstractOptionsAsset implements ExtendableInterface -{ - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $center; - - /** @var double */ - protected $radius; - - /** - * Create a circle. - * - * @param \Ivory\GoogleMap\Base\Coordinate $center The circle center. - * @param double $radius The circle radius. - */ - public function __construct(Coordinate $center = null, $radius = 1) - { - parent::__construct(); - - $this->setPrefixJavascriptVariable('circle_'); - - if ($center === null) { - $center = new Coordinate(); - } - - $this->setCenter($center); - $this->setRadius($radius); - } - - /** - * Gets the circle center. - * - * @return \Ivory\GoogleMap\Base\Coordinate The circle center. - */ - public function getCenter() - { - return $this->center; - } - - /** - * Sets the circle center. - * - * Available prototypes: - * - function setCenter(Ivory\GoogleMap\Base\Coordinate $center) - * - function setCenter(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the center is not valid (prototypes). - */ - public function setCenter() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->center = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - $this->center->setLatitude($args[0]); - $this->center->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->center->setNoWrap($args[2]); - } - } else { - throw OverlayException::invalidCircleCenter(); - } - } - - /** - * Gets the circle radius. - * - * @return double The circle radius. - */ - public function getRadius() - { - return $this->radius; - } - - /** - * Sets the circle radius. - * - * @param double $radius The circle radius. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the radius is not valid. - */ - public function setRadius($radius) - { - if (!is_numeric($radius)) { - throw OverlayException::invalidCircleRadius(); - } - - $this->radius = $radius; - } -} diff --git a/src/Overlays/EncodedPolyline.php b/src/Overlays/EncodedPolyline.php deleted file mode 100644 index b74a4eea..00000000 --- a/src/Overlays/EncodedPolyline.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Encoded polyline. - * - * @see http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html - * @author GeLo - */ -class EncodedPolyline extends AbstractOptionsAsset implements ExtendableInterface -{ - /** @var string */ - protected $value; - - /** - * Creates an encoded polyline. - * - * @param string $value The encoded polyline value. - */ - public function __construct($value = null) - { - parent::__construct(); - - $this->setPrefixJavascriptVariable('encoded_polyline_'); - - if ($value !== null) { - $this->setValue($value); - } - } - - /** - * Gets the encoded polyline value. - * - * @return string The encoded polyline value. - */ - public function getValue() - { - return $this->value; - } - - /** - * Sets the encoded polyline value. - * - * @param string $value The encoded polyline value. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the encoded polyline value is not valid. - */ - public function setValue($value) - { - if (!is_string($value)) { - throw OverlayException::invalidEncodedPolylineValue(); - } - - $this->value = $value; - } -} diff --git a/src/Overlays/GroundOverlay.php b/src/Overlays/GroundOverlay.php deleted file mode 100644 index fdc8be97..00000000 --- a/src/Overlays/GroundOverlay.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Ground overlay which describes a google map ground overlay. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GroundOverlay - * @author GeLo - */ -class GroundOverlay extends AbstractOptionsAsset implements ExtendableInterface -{ - /** @var string */ - protected $url; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** - * Creates a ground overlay. - * - * @param string $url The ground overlay url. - * @param \Ivory\GoogleMap\Base\Bound $bound The ground overlay bound. - */ - public function __construct($url = null, Bound $bound = null) - { - parent::__construct(); - - $this->setPrefixJavascriptVariable('ground_overlay_'); - - if ($url !== null) { - $this->setUrl($url); - } - - if ($bound === null) { - $bound = new Bound(new Coordinate(-1, -1), new Coordinate(1, 1)); - } - - $this->setBound($bound); - } - - /** - * Gets the ground overlay image url. - * - * @return string The ground overlay image url. - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the ground overlay image url. - * - * @param string $url The ground overlay image url. - */ - public function setUrl($url) - { - if (!is_string($url)) { - throw OverlayException::invalidGroundOverlayUrl(); - } - - $this->url = $url; - } - - /** - * Gets the ground overlay bound. - * - * @return \Ivory\GoogleMap\Base\Bound The ground overlay bound. - */ - public function getBound() - { - return $this->bound; - } - - /** - * Sets the ground overlay bound. - * - * Available prototypes: - * - function setBound(Ivory\GoogleMap\Base\Bound $bound) - * - function setBount(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the ground overlay bound is not valid (prototypes). - */ - public function setBound() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Bound)) { - if ($args[0]->hasCoordinates()) { - $this->bound = $args[0]; - } else { - throw OverlayException::invalidGroundOverlayBoundCoordinates(); - } - } elseif ((isset($args[0]) && ($args[0] instanceof Coordinate)) - && (isset($args[1]) && ($args[1] instanceof Coordinate)) - ) { - $this->bound->setSouthWest($args[0]); - $this->bound->setNorthEast($args[1]); - } elseif ((isset($args[0]) && is_numeric($args[0])) - && (isset($args[1]) && is_numeric($args[1])) - && (isset($args[2]) && is_numeric($args[2])) - && (isset($args[3]) && is_numeric($args[3])) - ) { - $this->bound->setSouthWest(new Coordinate($args[0], $args[1])); - $this->bound->setNorthEast(new Coordinate($args[2], $args[3])); - - if (isset($args[4]) && is_bool($args[4])) { - $this->bound->getSouthWest()->setNoWrap($args[4]); - } - - if (isset($args[5]) && is_bool($args[5])) { - $this->bound->getNorthEast()->setNoWrap($args[5]); - } - } else { - throw OverlayException::invalidGroundOverlayBound(); - } - } -} diff --git a/src/Overlays/InfoWindow.php b/src/Overlays/InfoWindow.php deleted file mode 100644 index d0768b73..00000000 --- a/src/Overlays/InfoWindow.php +++ /dev/null @@ -1,319 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Base\Size; -use Ivory\GoogleMap\Events\MouseEvent; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Info window which describes a google map info window. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#InfoWindow - * @author GeLo - */ -class InfoWindow extends AbstractOptionsAsset implements ExtendableInterface -{ - /** @var string */ - protected $content; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $position; - - /** @var \Ivory\GoogleMap\Base\Size */ - protected $pixedOffset; - - /** @var boolean */ - protected $open; - - /** @var string */ - protected $openEvent; - - /** @var boolean */ - protected $autoOpen; - - /** @var boolean */ - protected $autoClose; - - /** - * Creates an info window. - * - * @param string $content The info window content. - * @param \Ivory\GoogleMap\Base\Coordinate $position The info window position. - * @param \Ivory\GoogleMap\Base\Size $pixelOffset The info window pixel offset. - * @param boolean $open The info window open flag. - * @param string $openEvent The info window open event. - * @param boolean $autoOpen The info window auto open flag. - * @param boolean $autoClose The info window auto close flag - */ - public function __construct( - $content = '

Default content

', - Coordinate $position = null, - Size $pixelOffset = null, - $open = false, - $openEvent = MouseEvent::CLICK, - $autoOpen = true, - $autoClose = false - ) { - parent::__construct(); - - $this->setPrefixJavascriptVariable('info_window_'); - - $this->setContent($content); - - if ($position !== null) { - $this->setPosition($position); - } - - if ($pixelOffset !== null) { - $this->setPixelOffset($pixelOffset); - } - - $this->setOpen($open); - $this->setOpenEvent($openEvent); - - $this->setAutoOpen($autoOpen); - $this->setAutoClose($autoClose); - } - - /** - * Gets the infow window position. - * - * @return \Ivory\GoogleMap\Base\Coordinate The info window position. - */ - public function getPosition() - { - return $this->position; - } - - /** - * Sets the info window position - * - * Available prototypes: - * - function setPosition(Ivory\GoogleMap\Base\Coordinate $position = null) - * - function setPosition(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the position is not valid. - */ - public function setPosition() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->position = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->position === null) { - $this->position = new Coordinate(); - } - - $this->position->setLatitude($args[0]); - $this->position->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->position->setNoWrap($args[2]); - } - } elseif (!isset($args[0])) { - $this->position = null; - } else { - throw OverlayException::invalidInfoWindowPosition(); - } - } - - /** - * Checks if the info window has a pixel offset. - * - * @return boolean TRUE if the info window has a pixel offset else FALSE. - */ - public function hasPixelOffset() - { - return $this->pixedOffset !== null; - } - - /** - * Gets the pixel offset. - * - * @return \Ivory\GoogleMap\Base\Size The pixel offset. - */ - public function getPixelOffset() - { - return $this->pixedOffset; - } - - /** - * Sets the pixel offset. - * - * Available prototypes: - * - function setPixelOffset(Ivory\GoogleMap\Base\Size $scaledSize) - * - function setPixelOffset(double $width, double $height, string $widthUnit = null, string $heightUnit = null) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the pixel offset is not valid (prototypes). - */ - public function setPixelOffset() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Size)) { - $this->pixedOffset = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->pixedOffset === null) { - $this->pixedOffset = new Size(); - } - - $this->pixedOffset->setWidth($args[0]); - $this->pixedOffset->setHeight($args[1]); - - if (isset($args[2]) && is_string($args[2])) { - $this->pixedOffset->setWidthUnit($args[2]); - } - - if (isset($args[3]) && is_string($args[3])) { - $this->pixedOffset->setHeightUnit($args[3]); - } - } elseif (!isset($args[0])) { - $this->pixedOffset = null; - } else { - throw OverlayException::invalidInfoWindowPixelOffset(); - } - } - - /** - * Gets the info window content. - * - * @return string The info window content. - */ - public function getContent() - { - return $this->content; - } - - /** - * Sets the info window content - * - * @param string $content The info window content. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the content is not valid. - */ - public function setContent($content) - { - if (!is_string($content)) { - throw OverlayException::invalidInfoWindowContent(); - } - - $this->content = $content; - } - - /** - * Checks if the info window is open. - * - * @return boolean TRUE if the info window is open else FALSE. - */ - public function isOpen() - { - return $this->open; - } - - /** - * Sets if the info window is open. - * - * @param boolean $open TRUE if the info window is open else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the info window open flag is not valid. - */ - public function setOpen($open) - { - if (!is_bool($open)) { - throw OverlayException::invalidInfoWindowOpen(); - } - - $this->open = $open; - } - - /** - * Checks if the info window auto open. - * - * @return boolean TRUE if the info window auto open on event else FALSE. - */ - public function isAutoOpen() - { - return $this->autoOpen; - } - - /** - * Sets if the info window auto open. - * - * @param boolean $autoOpen TRUE if the info window auto open on event else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the auto open flag is not valid. - */ - public function setAutoOpen($autoOpen) - { - if (!is_bool($autoOpen)) { - throw OverlayException::invalidInfoWindowAutoOpen(); - } - - $this->autoOpen = $autoOpen; - } - - /** - * Gets the info window open event. - * - * @return string The info window open event. - */ - public function getOpenEvent() - { - return $this->openEvent; - } - - /** - * Sets the info window open event. - * - * @param string $openEvent The info window open event. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the open event is not valid. - */ - public function setOpenEvent($openEvent) - { - if (!in_array($openEvent, MouseEvent::getMouseEvents())) { - throw OverlayException::invalidInfoWindowOpenEvent(); - } - - $this->openEvent = $openEvent; - } - - /** - * Gets the auto close flag. - * - * @return boolean TRUE if all opened info windows close when one is opened else FALSE. - */ - public function isAutoClose() - { - return $this->autoClose; - } - - /** - * Sets the auto close flag. - * - * @param boolean $autoClose TRUE if all opened info windows close when one is opened else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the auto close flag is not valid. - */ - public function setAutoClose($autoClose) - { - if (!is_bool($autoClose)) { - throw OverlayException::invalidInfoWindowAutoClose(); - } - - $this->autoClose = $autoClose; - } -} diff --git a/src/Overlays/Marker.php b/src/Overlays/Marker.php deleted file mode 100644 index 63cbb451..00000000 --- a/src/Overlays/Marker.php +++ /dev/null @@ -1,354 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Marker which describes a google map marker. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Marker - * @author GeLo - */ -class Marker extends AbstractOptionsAsset implements ExtendableInterface -{ - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $position; - - /** @var string */ - protected $animation; - - /** @var \Ivory\GoogleMap\Overlays\MarkerImage */ - protected $icon; - - /** @var \Ivory\GoogleMap\Overlays\MarkerImage */ - protected $shadow; - - /** @var \Ivory\GoogleMap\Overlays\MarkerShape */ - protected $shape; - - /** @var \Ivory\GoogleMap\Overlays\InfoWindow */ - protected $infoWindow; - - /** - * Creates a marker. - * - * @param \Ivory\GoogleMap\Base\Coordinate $position The marker position. - * @param string $animation The marker animation. - * @param \Ivory\GoogleMap\Overlays\MarkerImage $icon The marker icon. - * @param \Ivory\GoogleMap\Overlays\MarkerImage $shadow The marker shadow. - * @param \Ivory\GoogleMap\Overlays\MarkerShape $shape The marker shape. - * @param \Ivory\GoogleMap\Overlays\InfoWindow $infoWindow The marker info window. - */ - public function __construct( - Coordinate $position = null, - $animation = null, - MarkerImage $icon = null, - MarkerImage $shadow = null, - MarkerShape $shape = null, - InfoWindow $infoWindow = null - ) { - parent::__construct(); - - $this->setPrefixJavascriptVariable('marker_'); - - if ($position === null) { - $position = new Coordinate(); - } - - $this->setPosition($position); - - if ($animation !== null) { - $this->setAnimation($animation); - } - - if ($icon !== null) { - $this->setIcon($icon); - } - - if ($shadow !== null) { - $this->setShadow($shadow); - } - - if ($shape !== null) { - $this->setShape($shape); - } - - if ($infoWindow !== null) { - $this->setInfoWindow($infoWindow); - } - } - - /** - * Gets the marker position. - * - * @return \Ivory\GoogleMap\Base\Coordinate The marker position. - */ - public function getPosition() - { - return $this->position; - } - - /** - * Sets the marker position. - * - * Available prototypes: - * - function setPosition(Ivory\GoogleMap\Base\Coordinate $position = null) - * - function setPosition(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the position is not valid. - */ - public function setPosition() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->position = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - $this->position->setLatitude($args[0]); - $this->position->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->position->setNoWrap($args[2]); - } - } elseif (!isset($args[0])) { - $this->position = null; - } else { - throw OverlayException::invalidMarkerPosition(); - } - } - - /** - * Checks if the marker has an animation. - * - * @return boolean TRUE if the marker has an animation else FALSE. - */ - public function hasAnimation() - { - return $this->animation !== null; - } - - /** - * Gets the marker animation. - * - * @return string The marker animation. - */ - public function getAnimation() - { - return $this->animation; - } - - /** - * Sets the marker animation. - * - * @param string $animation The marker animation. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the animation is not valid. - */ - public function setAnimation($animation = null) - { - if (!in_array($animation, Animation::getAnimations()) && ($animation !== null)) { - throw OverlayException::invalidMarkerAnimation(); - } - - $this->animation = $animation; - } - - /** - * Checks if the marker has an icon. - * - * @return boolean TRUE if the marker has an icon else FALSE. - */ - public function hasIcon() - { - return $this->icon !== null; - } - - /** - * Gets the marker icon. - * - * @return \Ivory\GoogleMap\Overlays\MarkerImage The marker image. - */ - public function getIcon() - { - return $this->icon; - } - - /** - * Sets the marker icon. - * - * Available prototypes: - * - function setIcon(Ivory\GoogleMap\Overlays\MarkerImage $markerImage = null) - * - function setIcon(string $url = null) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the icon is not valid. - */ - public function setIcon() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof MarkerImage)) { - if ($args[0]->getUrl() === null) { - throw OverlayException::invalidMarkerIconUrl(); - } - - $this->icon = $args[0]; - } elseif (isset($args[0]) && is_string($args[0])) { - if ($this->icon === null) { - $this->icon = new MarkerImage(); - } - - $this->icon->setUrl($args[0]); - } elseif (!isset($args[0])) { - $this->icon = null; - } else { - throw OverlayException::invalidMarkerIcon(); - } - } - - /** - * Checks if the marker has a shadow. - * - * @return boolean TRUE if the marker has a shadow else FALSE. - */ - public function hasShadow() - { - return $this->shadow !== null; - } - - /** - * Gets the marker shadow. - * - * @return \Ivory\GoogleMap\Overlays\MarkerImage The marker shadow. - */ - public function getShadow() - { - return $this->shadow; - } - - /** - * Sets the marker shadow. - * - * Available prototypes: - * - function setShadow(Ivory\GoogleMap\Overlays\MarkerImage $markerImage = null) - * - function setShadow(string $url = null) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the marker shadow is not valid. - */ - public function setShadow() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof MarkerImage)) { - if ($args[0]->getUrl() === null) { - throw OverlayException::invalidMarkerShadowUrl(); - } - - $this->shadow = $args[0]; - } elseif (isset($args[0]) && is_string($args[0])) { - if ($this->shadow === null) { - $this->shadow = new MarkerImage(); - } - - $this->shadow->setUrl($args[0]); - } elseif (!isset($args[0])) { - $this->shadow = null; - } else { - throw OverlayException::invalidMarkerShadow(); - } - } - - /** - * Checks if the marker has a shape. - * - * @return boolean TRUE if the marker has a shape else FALSE. - */ - public function hasShape() - { - return $this->shape !== null; - } - - /** - * Gets the marker shape. - * - * @return \Ivory\GoogleMap\Overlays\MarkerShape The marker shape. - */ - public function getShape() - { - return $this->shape; - } - - /** - * Sets the marker shape. - * - * Available prototypes: - * - function setShape(Ivory\GoogleMap\Overlays\MarkerShape $shape = null) - * - function setShape(string $type, array $coordinates) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the shape is not valid. - */ - public function setShape() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof MarkerShape)) { - if (!$args[0]->hasCoordinates()) { - throw OverlayException::invalidMarkerShapeCoordinates(); - } - - $this->shape = $args[0]; - } elseif ((isset($args[0]) && is_string($args[0])) && (isset($args[1]) && is_array($args[1]))) { - if ($this->shape === null) { - $this->shape = new MarkerShape(); - } - - $this->shape->setType($args[0]); - $this->shape->setCoordinates($args[1]); - } elseif (!isset($args[0])) { - $this->shape = null; - } else { - throw OverlayException::invalidMarkerShape(); - } - } - - /** - * Check if the marker has an info window. - * - * @return boolean TRUE if the marker has an info window else FALSE. - */ - public function hasInfoWindow() - { - return $this->infoWindow !== null; - } - - /** - * Gets the info window. - * - * @return \Ivory\GoogleMap\Overlays\InfoWindow The info window. - */ - public function getInfoWindow() - { - return $this->infoWindow; - } - - /** - * Sets the info window. - * - * @param \Ivory\GoogleMap\Overlays\InfoWindow $infoWindow The info window. - */ - public function setInfoWindow(InfoWindow $infoWindow) - { - $this->infoWindow = $infoWindow; - } -} diff --git a/src/Overlays/MarkerCluster.php b/src/Overlays/MarkerCluster.php deleted file mode 100644 index eb3a01bc..00000000 --- a/src/Overlays/MarkerCluster.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; - -/** - * Marker Cluster. - * - * @author GeLo - */ -class MarkerCluster extends AbstractOptionsAsset -{ - /** @const string The default marker cluster type */ - const _DEFAULT = 'default'; - - /** @const string The javascript marker cluster type */ - const MARKER_CLUSTER = 'marker_cluster'; - - /** @var string */ - protected $type; - - /** @var array */ - protected $markers; - - /** - * Creates a marker cluster. - */ - public function __construct() - { - parent::__construct(); - - $this->setPrefixJavascriptVariable('marker_cluster_'); - $this->setType(self::_DEFAULT); - $this->markers = array(); - } - - /** - * Gets the marker cluster type. - * - * @return string The marker cluster type. - */ - public function getType() - { - return $this->type; - } - - /** - * Sets the marker cluster type. - * - * @param string $type The marker cluster type. - */ - public function setType($type) - { - $this->type = $type; - } - - /** - * Checks if the cluster has marker. - * - * @return boolean TRUE if the cluster has marker else FALSE. - */ - public function hasMarkers() - { - return !empty($this->markers); - } - - /** - * Gets the cluster markers. - * - * @return array The cluster markers. - */ - public function getMarkers() - { - return $this->markers; - } - - /** - * Sets the cluster markers. - * - * @param array $markers The cluster markers. - */ - public function setMarkers($markers) - { - $this->markers = array(); - - foreach ($markers as $marker) { - $this->addMarker($marker); - } - } - - /** - * Adds a marker to the cluster. - * - * @param \Ivory\GoogleMap\Overlays\Marker $marker The marker to add. - */ - public function addMarker(Marker $marker) - { - $this->markers[] = $marker; - } -} diff --git a/src/Overlays/MarkerImage.php b/src/Overlays/MarkerImage.php deleted file mode 100644 index dba210e4..00000000 --- a/src/Overlays/MarkerImage.php +++ /dev/null @@ -1,309 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Base\Point; -use Ivory\GoogleMap\Base\Size; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Marker image which describes a google map marker image. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MarkerImage - * @author GeLo - */ -class MarkerImage extends AbstractJavascriptVariableAsset -{ - /** @var string */ - protected $url; - - /** @var \Ivory\GoogleMap\Base\Point */ - protected $anchor; - - /** @var \Ivory\GoogleMap\Base\Point */ - protected $origin; - - /** @var \Ivory\GoogleMap\Base\Size */ - protected $scaledSize; - - /** @var Ivory\GoogleMap\Base\Size */ - protected $size; - - /** - * Create a marker image. - */ - public function __construct( - $url = '//maps.gstatic.com/mapfiles/markers/marker.png', - Point $anchor = null, - Point $origin = null, - Size $scaledSize = null, - Size $size = null - ) { - $this->setPrefixJavascriptVariable('marker_image_'); - $this->setUrl($url); - - if ($anchor !== null) { - $this->setAnchor($anchor); - } - - if ($origin !== null) { - $this->setOrigin($origin); - } - - if ($scaledSize !== null) { - $this->setScaledSize($scaledSize); - } - - if ($size !== null) { - $this->setSize($size); - } - } - - /** - * Gets the url of the marker image. - * - * @return string The url of the marker image. - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the url of the marker image. - * - * @param string $url The url of the marker image. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the url is not valid. - */ - public function setUrl($url) - { - if (!is_string($url)) { - throw OverlayException::invalidMarkeImageUrl(); - } - - $this->url = $url; - } - - /** - * Checks if the marker image has an anchor. - * - * @return boolean TRUE if the marker image has an anchor else FALSE. - */ - public function hasAnchor() - { - return $this->anchor !== null; - } - - /** - * Gets the anchor of the marker image. - * - * @return \Ivory\GoogleMap\Base\Point The marker image anchor. - */ - public function getAnchor() - { - return $this->anchor; - } - - /** - * Sets the anchor of the marker image - * - * Available prototypes: - * - function setAnchor(Ivory\GoogleMap\Base\Point $anchor = null) - * - function setAnchor(double x, double y) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the anchor is not valid (prototypes). - */ - public function setAnchor() - { - $args = func_get_args(); - - if ($args[0] instanceof Point) { - $this->anchor = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->anchor === null) { - $this->anchor = new Point(); - } - - $this->anchor->setX($args[0]); - $this->anchor->setY($args[1]); - } elseif (!isset($args[0])) { - $this->anchor = null; - } else { - throw OverlayException::invalidMarkerImageAnchor(); - } - } - - /** - * Checks if the marker image has an origin. - * - * @return boolean TRUE if the marker image has an origin else FALSE. - */ - public function hasOrigin() - { - return $this->origin !== null; - } - - /** - * Gets the origin of the marker image. - * - * @return \Ivory\GoogleMap\Base\Point The marker image origin. - */ - public function getOrigin() - { - return $this->origin; - } - - /** - * Sets the origin of the marker image - * - * Available prototypes: - * - function setOrigin(Ivory\GoogleMap\Base\Point $origin = null) - * - function setOrigin(double x, double y) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the origin is not valid. - */ - public function setOrigin() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Point)) { - $this->origin = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->origin === null) { - $this->origin = new Point(); - } - - $this->origin->setX($args[0]); - $this->origin->setY($args[1]); - } elseif (!isset($args[0])) { - $this->origin = null; - } else { - throw OverlayException::invalidMarkerImageOrigin(); - } - } - - /** - * Checks if the marker image has a scaled size else FALSE. - * - * @return boolean TRUE if the marker image has a scaled size else FALSE. - */ - public function hasScaledSize() - { - return $this->scaledSize !== null; - } - - /** - * Gets the scaled size of the marker image. - * - * @return \Ivory\GoogleMap\Base\Size The marker image scaled size. - */ - public function getScaledSize() - { - return $this->scaledSize; - } - - /** - * Sets the scaled size of the marker image - * - * Available prototypes: - * - function setScaledSize(Ivory\GoogleMap\Base\Size $scaledSize = null) - * - function setScaledSize(double $width, double $height, string $widthUnit = null, string $heightUnit = null) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the scaled size is not valid. - */ - public function setScaledSize() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Size)) { - $this->scaledSize = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->scaledSize === null) { - $this->scaledSize = new Size(); - } - - $this->scaledSize->setWidth($args[0]); - $this->scaledSize->setHeight($args[1]); - - if (isset($args[2]) && is_string($args[2])) { - $this->scaledSize->setWidthUnit($args[2]); - } - - if (isset($args[3]) && is_string($args[3])) { - $this->scaledSize->setHeightUnit($args[3]); - } - } elseif (!isset($args[0])) { - $this->scaledSize = null; - } else { - throw OverlayException::invalidMarkerImageScaledSize(); - } - } - - /** - * Checks if the marker image has a size. - * - * @return boolean TRUE if the marker image has a size else FALSE. - */ - public function hasSize() - { - return $this->size !== null; - } - - /** - * Gets the size of the marker image. - * - * @return \Ivory\GoogleMap\Base\Size The marker image size. - */ - public function getSize() - { - return $this->size; - } - - /** - * Sets the size of the marker image. - * - * Available prototypes: - * - function setSize(Ivory\GoogleMap\Base\Size $size = null) - * - function setSize(double $width, double $height, string $widthUnit = null, string $heightUnit = null) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the size is not valid. - */ - public function setSize() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Size)) { - $this->size = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->size === null) { - $this->size = new Size($args[0], $args[1]); - } - - $this->size->setWidth($args[0]); - $this->size->setHeight($args[1]); - - if (isset($args[2]) && is_string($args[2])) { - $this->size->setWidthUnit($args[2]); - } - - if (isset($args[3]) && is_string($args[3])) { - $this->size->setHeightUnit($args[3]); - } - } elseif (!isset($args[0])) { - $this->size = null; - } else { - throw OverlayException::invalidMarkerImageSize(); - } - } -} diff --git a/src/Overlays/MarkerShape.php b/src/Overlays/MarkerShape.php deleted file mode 100644 index 1efbfbaa..00000000 --- a/src/Overlays/MarkerShape.php +++ /dev/null @@ -1,175 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Marker shape which describes a google map marker shape. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#MarkerShape - * @author GeLo - */ -class MarkerShape extends AbstractJavascriptVariableAsset -{ - /** @var string */ - protected $type; - - /** @var array */ - protected $coordinates; - - /** - * Creates a marker shape. - * - * @param string $type The marker shape type. - * @param array $coordinates The marker shape coordinates. - */ - public function __construct($type = 'poly', array $coordinates = array(1, 1, 1, -1, -1, -1, -1, 1)) - { - $this->setPrefixJavascriptVariable('marker_shape_'); - $this->setType($type); - $this->setCoordinates($coordinates); - } - - /** - * Gets the marker shape type. - * - * @return string The marker sape type. - */ - public function getType() - { - return $this->type; - } - - /** - * Sets the marker shape type. - * - * The allowing marker shape type are : circle, poly & rect. - * - * @param string $type The marker schape type. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the type is not valid. - */ - public function setType($type) - { - switch (strtolower($type)) { - case 'circle': - case 'poly': - case 'rect': - $this->type = $type; - break; - default: - throw OverlayException::invalidMarkerShapeType(); - } - } - - /** - * Resets the marker shape coordinates. - */ - public function resetCoordinates() - { - $this->coordinates = array(); - } - - /** - * Cheks if the marker shape has coordinates - * - * @return boolean TRUE if the marker shape has coordinates else FALSE. - */ - public function hasCoordinates() - { - return !empty($this->coordinates); - } - - /** - * Gets the marker shape coordinates. - * - * @return array The marker shape coordinates. - */ - public function getCoordinates() - { - return $this->coordinates; - } - - /** - * Sets the marker shape coordinates. - * - * @param array $coordinates The marker shape coordinates. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the coordinates are not valid according to the type. - */ - public function setCoordinates(array $coordinates) - { - switch (strtolower($this->type)) { - case 'circle': - if ((count($coordinates) === 3) - && is_numeric($coordinates[0]) - && is_numeric($coordinates[1]) - && is_numeric($coordinates[2]) - ) { - $this->coordinates = $coordinates; - } else { - throw OverlayException::invalidMarkerShapeCircleCoordinates(); - } - break; - case 'poly': - if ((count($coordinates) <= 0) || ((count($coordinates) % 2) !== 0)) { - throw OverlayException::invalidMarkerShapePolyCoordinates(); - } - - foreach ($coordinates as $coordinate) { - if (!is_numeric($coordinate)) { - throw OverlayException::invalidMarkerShapePolyCoordinates(); - } - } - - $this->coordinates = $coordinates; - break; - case 'rect': - if ((count($coordinates) === 4) - && is_numeric($coordinates[0]) - && is_numeric($coordinates[1]) - && is_numeric($coordinates[2]) - && is_numeric($coordinates[3]) - ) { - $this->coordinates = $coordinates; - } else { - throw OverlayException::invalidMarkerShapeRectCoordinates(); - } - break; - } - } - - /** - * Adds a coordinate to the marker shape if the type is poly. - * - * @param integer $x The X coordinate. - * @param integer $y The Y coordinate. - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the type is not poly or if the poly coordinate is not - * valid. - */ - public function addPolyCoordinate($x, $y) - { - if ($this->type !== 'poly') { - throw OverlayException::invalidMarkerShapeAddPolyCoordinateCall(); - } - - if (!is_numeric($x) || !is_numeric($y)) { - throw OverlayException::invalidMarkerShapePolyCoordinate(); - } - - $this->coordinates[] = $x; - $this->coordinates[] = $y; - } -} diff --git a/src/Overlays/Polygon.php b/src/Overlays/Polygon.php deleted file mode 100644 index da67fed6..00000000 --- a/src/Overlays/Polygon.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Polygon which describes a google map polygon. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Polygon - * @author GeLo - */ -class Polygon extends AbstractOptionsAsset implements ExtendableInterface -{ - /** @var array */ - protected $coordinates; - - /** - * Creates a polygon. - * - * @param array $coordinates The polygon coordinates. - */ - public function __construct(array $coordinates = array()) - { - parent::__construct(); - - $this->setPrefixJavascriptVariable('polygon_'); - $this->setCoordinates($coordinates); - } - - /** - * Checks if polygon has coordinates. - * - * @return boolean TRUE if the polygon has coordinates else FALSE. - */ - public function hasCoordinates() - { - return !empty($this->coordinates); - } - - /** - * Gets the polygon coordinates. - * - * @return array The polygon coordinates. - */ - public function getCoordinates() - { - return $this->coordinates; - } - - /** - * Sets the polygon coordinates. - * - * @param array $coordinates The polygon coordinates. - */ - public function setCoordinates($coordinates) - { - $this->coordinates = array(); - - foreach ($coordinates as $coordinate) { - $this->addCoordinate($coordinate); - } - } - - /** - * Adds a coordinate to the polygon. - * - * Available prototypes: - * - function addCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate) - * - function addCoordinate(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the coordinate is not valid. - */ - public function addCoordinate() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->coordinates[] = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - $coordinate = new Coordinate($args[0], $args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $coordinate->setNoWrap($args[2]); - } - - $this->coordinates[] = $coordinate; - } else { - throw OverlayException::invalidPolygonCoordinate(); - } - } -} diff --git a/src/Overlays/Polyline.php b/src/Overlays/Polyline.php deleted file mode 100644 index 265771fe..00000000 --- a/src/Overlays/Polyline.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Polyline which describes a google map polyline. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Polyline - * @author GeLo - */ -class Polyline extends AbstractOptionsAsset implements ExtendableInterface -{ - /** @var array */ - protected $coordinates; - - /** - * Creates a polyline. - * - * @param array $coordinates The polyline coordinates. - */ - public function __construct(array $coordinates = array()) - { - parent::__construct(); - - $this->setPrefixJavascriptVariable('polyline_'); - $this->setCoordinates($coordinates); - } - - /** - * Checks if the polyline has coordinates. - * - * @return boolean TRUE if the polyline has coordinates else FALSE. - */ - public function hasCoordinates() - { - return !empty($this->coordinates); - } - - /** - * Gets the polyline coordinates. - * - * @return array The polyline coordinates. - */ - public function getCoordinates() - { - return $this->coordinates; - } - - /** - * Sets the polyline coordinates. - * - * @param array $coordinates The polyline coordinates. - */ - public function setCoordinates($coordinates) - { - $this->coordinates = array(); - - foreach ($coordinates as $coordinate) { - $this->addCoordinate($coordinate); - } - } - - /** - * Add a coordinate to the polyline. - * - * Available prototypes: - * - function addCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate) - * - function addCoordinate(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the coordinate is not valid. - */ - public function addCoordinate() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->coordinates[] = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - $coordinate = new Coordinate($args[0], $args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $coordinate->setNoWrap($args[2]); - } - - $this->coordinates[] = $coordinate; - } else { - throw OverlayException::invalidPolylineCoordinate(); - } - } -} diff --git a/src/Overlays/Rectangle.php b/src/Overlays/Rectangle.php deleted file mode 100644 index 478f83ef..00000000 --- a/src/Overlays/Rectangle.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Overlays; - -use Ivory\GoogleMap\Assets\AbstractOptionsAsset; -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\OverlayException; - -/** - * Rectangle which describes a google map rectangle. - * - * @author GeLo - */ -class Rectangle extends AbstractOptionsAsset implements ExtendableInterface -{ - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** - * Creates a rectangle. - */ - public function __construct(Bound $bound = null) - { - parent::__construct(); - - $this->setPrefixJavascriptVariable('rectangle_'); - - if ($bound === null) { - $bound = new Bound(new Coordinate(-1, -1), new Coordinate(1, 1)); - } - - $this->setBound($bound); - } - - /** - * Gets the rectangle bound. - * - * @return \Ivory\GoogleMap\Base\Bound The rectangle bound. - */ - public function getBound() - { - return $this->bound; - } - - /** - * Sets the rectangle bound. - * - * Available prototypes: - * - function setBound(Ivory\GoogleMap\Base\Bound $bound) - * - function setBount(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - * - * @throws \Ivory\GoogleMap\Exception\OverlayException If the bound is not valid. - */ - public function setBound() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Bound)) { - if (!$args[0]->hasCoordinates()) { - throw OverlayException::invalidRectangleBoundCoordinates(); - } - - $this->bound = $args[0]; - } elseif ((isset($args[0]) && ($args[0] instanceof Coordinate)) - && (isset($args[1]) && ($args[1] instanceof Coordinate)) - ) { - $this->bound->setSouthWest($args[0]); - $this->bound->setNorthEast($args[1]); - } elseif ((isset($args[0]) && is_numeric($args[0])) - && (isset($args[1]) && is_numeric($args[1])) - && (isset($args[2]) && is_numeric($args[2])) - && (isset($args[3]) && is_numeric($args[3])) - ) { - $this->bound->setSouthWest(new Coordinate($args[0], $args[1])); - $this->bound->setNorthEast(new Coordinate($args[2], $args[3])); - - if (isset($args[4]) && is_bool($args[4])) { - $this->bound->getSouthWest()->setNoWrap($args[4]); - } - - if (isset($args[5]) && is_bool($args[5])) { - $this->bound->getNorthEast()->setNoWrap($args[5]); - } - } else { - throw OverlayException::invalidRectangleBound(); - } - } -} diff --git a/src/Place/Autocomplete.php b/src/Place/Autocomplete.php new file mode 100644 index 00000000..60b16226 --- /dev/null +++ b/src/Place/Autocomplete.php @@ -0,0 +1,419 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Place; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @author GeLo + */ +class Autocomplete implements VariableAwareInterface +{ + use VariableAwareTrait; + + /** + * @var string + */ + private $inputId = 'place_input'; + + /** + * @var Bound|null + */ + private $bound; + + /** + * @var string[] + */ + private $types = []; + + /** + * @var array + */ + private $componentRestrictions = []; + + /** + * @var string + */ + private $value; + + /** + * @var string[] + */ + private $inputAttributes = []; + + /** + * @var string[] + */ + private $libraries = []; + + /** + * @var string + */ + private $language = 'en'; + + public function __construct() + { + $this->setVariablePrefix('place_autocomplete'); + } + + /** + * @return string + */ + public function getHtmlId() + { + return $this->inputId; + } + + /** + * @param string $inputId + */ + public function setInputId($inputId) + { + $this->inputId = $inputId; + } + + /** + * @return bool + */ + public function hasBound() + { + return $this->bound !== null; + } + + /** + * @return Bound|null + */ + public function getBound() + { + return $this->bound; + } + + /** + * @param Bound|null $bound + */ + public function setBound(Bound $bound = null) + { + $this->bound = $bound; + } + + /** + * @return bool + */ + public function hasTypes() + { + return !empty($this->types); + } + + /** + * @return string[] + */ + public function getTypes() + { + return $this->types; + } + + /** + * @param string[] $types + */ + public function setTypes(array $types) + { + $this->types = []; + $this->addTypes($types); + } + + /** + * @param string[] $types + */ + public function addTypes(array $types) + { + foreach ($types as $type) { + $this->addType($type); + } + } + + /** + * @param string $type + * + * @return bool + */ + public function hasType($type) + { + return in_array($type, $this->types, true); + } + + /** + * @param string $type + */ + public function addType($type) + { + if (!$this->hasType($type)) { + $this->types[] = $type; + } + } + + /** + * @param string $type + */ + public function removeType($type) + { + unset($this->types[array_search($type, $this->types, true)]); + } + + /** + * @return bool + */ + public function hasComponentRestrictions() + { + return !empty($this->componentRestrictions); + } + + /** + * @return string[] + */ + public function getComponentRestrictions() + { + return $this->componentRestrictions; + } + + /** + * @param string[] $componentRestrictions + */ + public function setComponentRestrictions(array $componentRestrictions) + { + $this->componentRestrictions = []; + $this->addComponentRestrictions($componentRestrictions); + } + + /** + * @param string[] $componentRestrictions + */ + public function addComponentRestrictions(array $componentRestrictions) + { + foreach ($componentRestrictions as $type => $value) { + $this->setComponentRestriction($type, $value); + } + } + + /** + * @param string $type + * + * @return bool + */ + public function hasComponentRestriction($type) + { + return isset($this->componentRestrictions[$type]); + } + + /** + * @param string $type + * + * @return string + */ + public function getComponentRestriction($type) + { + return $this->hasComponentRestriction($type) ? $this->componentRestrictions[$type] : null; + } + + /** + * @param string $type + * @param string $value + */ + public function setComponentRestriction($type, $value) + { + $this->componentRestrictions[$type] = $value; + } + + /** + * @param string $type + */ + public function removeComponentRestriction($type) + { + unset($this->componentRestrictions[$type]); + } + + /** + * @return bool + */ + public function hasValue() + { + return $this->value !== null; + } + + /** + * @return string|null + */ + public function getValue() + { + return $this->value; + } + + /** + * @param string|null $value + */ + public function setValue($value = null) + { + $this->value = $value; + } + + /** + * @return bool + */ + public function hasInputAttributes() + { + return !empty($this->inputAttributes); + } + + /** + * @return string[] + */ + public function getInputAttributes() + { + return $this->inputAttributes; + } + + /** + * @param string[] $inputAttributes + */ + public function setInputAttributes(array $inputAttributes) + { + $this->inputAttributes = []; + $this->addInputAttributes($inputAttributes); + } + + /** + * @param string[] $inputAttributes + */ + public function addInputAttributes(array $inputAttributes) + { + foreach ($inputAttributes as $name => $value) { + $this->setInputAttribute($name, $value); + } + } + + /** + * @param string $name + * + * @return bool + */ + public function hasInputAttribute($name) + { + return isset($this->inputAttributes[$name]); + } + + /** + * @param string $name + * + * @return string|null + */ + public function getInputAttribute($name) + { + return $this->hasInputAttribute($name) ? $this->inputAttributes[$name] : null; + } + + /** + * @param string $name + * @param string $value + */ + public function setInputAttribute($name, $value) + { + $this->inputAttributes[$name] = $value; + } + + /** + * @param string $name + */ + public function removeInputAttribute($name) + { + unset($this->inputAttributes[$name]); + } + + /** + * @return bool + */ + public function hasLibraries() + { + return !empty($this->libraries); + } + + /** + * @return string[] + */ + public function getLibraries() + { + return $this->libraries; + } + + /** + * @param string[] $libraries + */ + public function setLibraries(array $libraries) + { + $this->libraries = []; + $this->addLibraries($libraries); + } + + /** + * @param string[] $libraries + */ + public function addLibraries(array $libraries) + { + foreach ($libraries as $library) { + $this->addLibrary($library); + } + } + + /** + * @param string $library + * + * @return bool + */ + public function hasLibrary($library) + { + return in_array($library, $this->libraries, true); + } + + /** + * @param string $library + */ + public function addLibrary($library) + { + if (!$this->hasLibrary($library)) { + $this->libraries[] = $library; + } + } + + /** + * @param string $library + */ + public function removeLibrary($library) + { + unset($this->libraries[array_search($library, $this->libraries, true)]); + } + + /** + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * @param string $language + */ + public function setLanguage($language) + { + $this->language = $language; + } +} diff --git a/src/Place/AutocompleteComponentRestriction.php b/src/Place/AutocompleteComponentRestriction.php new file mode 100644 index 00000000..abab51a8 --- /dev/null +++ b/src/Place/AutocompleteComponentRestriction.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Place; + +/** + * @author GeLo + */ +final class AutocompleteComponentRestriction +{ + const COUNTRY = 'country'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Place/AutocompleteType.php b/src/Place/AutocompleteType.php new file mode 100644 index 00000000..552bb91a --- /dev/null +++ b/src/Place/AutocompleteType.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Place; + +/** + * @author GeLo + */ +final class AutocompleteType +{ + const ESTABLISHMENT = 'establishment'; + const GEOCODE = 'geocode'; + const REGIONS = '(regions)'; + const CITIES = '(cities)'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Places/Autocomplete.php b/src/Places/Autocomplete.php deleted file mode 100644 index bb56613d..00000000 --- a/src/Places/Autocomplete.php +++ /dev/null @@ -1,476 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Places; - -use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset; -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\PlaceException; - -/** - * Places autocomplete. - * - * @author GeLo - */ -class Autocomplete extends AbstractJavascriptVariableAsset -{ - /** @var string */ - protected $inputId; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** @var array */ - protected $types; - - /** @var array */ - protected $componentRestrictions; - - /** @var string */ - protected $value; - - /** @var array */ - protected $inputAttributes; - - /** @var boolean */ - protected $async; - - /** @var string */ - protected $language; - - /** - * Creates a place autocomplete. - */ - public function __construct() - { - $this->setPrefixJavascriptVariable('place_autocomplete_'); - - $this->inputId = 'place_input'; - $this->inputAttributes = array( - 'type' => 'text', - 'placeholder' => 'off', - ); - - $this->types = array(); - $this->componentRestrictions = array(); - - $this->async = false; - $this->language = 'en'; - } - - /** - * Gets the autocomplete input ID. - * - * @return string The autocomplete input ID. - */ - public function getInputId() - { - return $this->inputId; - } - - /** - * Sets the autocomplete input ID. - * - * @param string $inputId The autocomplete input ID. - * - * @throws \Ivory\GoogleMap\Exception\PlaceException If the input ID is not a valid string. - */ - public function setInputId($inputId) - { - if (!is_string($inputId) || (strlen($inputId) === 0)) { - throw PlaceException::invalidAutocompleteInputId(); - } - - $this->inputId = $inputId; - } - - /** - * Checks if the autocomplete has a bound. - * - * @return boolean TRUE if the autocomplete has a bound else FALSE. - */ - public function hasBound() - { - return $this->bound !== null; - } - - /** - * Gets the autocomplete bound. - * - * @return \Ivory\GoogleMap\Base\Bound The autocomplete bound. - */ - public function getBound() - { - return $this->bound; - } - - /** - * Sets the autocomplete bound. - * - * Available prototypes: - * - function setBound(Ivory\GoogleMap\Base\Bound $bound = null) - * - function setBount(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - * - * @throws \Ivory\GoogleMap\Exception\PlaceException If the bound is not valid (prototypes). - */ - public function setBound() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Bound)) { - $this->bound = $args[0]; - } elseif ((isset($args[0]) && ($args[0] instanceof Coordinate)) - && (isset($args[1]) && ($args[1] instanceof Coordinate)) - ) { - if ($this->bound === null) { - $this->bound = new Bound(); - } - - $this->bound->setSouthWest($args[0]); - $this->bound->setNorthEast($args[1]); - } elseif ((isset($args[0]) && is_numeric($args[0])) - && (isset($args[1]) && is_numeric($args[1])) - && (isset($args[2]) && is_numeric($args[2])) - && (isset($args[3]) && is_numeric($args[3])) - ) { - if ($this->bound === null) { - $this->bound = new Bound(); - } - - $this->bound->setSouthWest(new Coordinate($args[0], $args[1])); - $this->bound->setNorthEast(new Coordinate($args[2], $args[3])); - - if (isset($args[4]) && is_bool($args[4])) { - $this->bound->getSouthWest()->setNoWrap($args[4]); - } - - if (isset($args[5]) && is_bool($args[5])) { - $this->bound->getNorthEast()->setNoWrap($args[5]); - } - } elseif (!isset($args[0])) { - $this->bound = null; - } else { - throw PlaceException::invalidAutocompleteBound(); - } - } - - /** - * Checks if the autocomplete has types. - * - * @return boolean TRUE if the autocomplete has types else FALSE. - */ - public function hasTypes() - { - return !empty($this->types); - } - - /** - * Checks if the autocomplete has a specific type. - * - * @param string $type The type. - * - * @return boolean TRUE if the autocomplete has te specific type else FALSE. - */ - public function hasType($type) - { - return array_search($type, $this->types) !== false; - } - - /** - * Gets the autocomplete types. - * - * @return array The autocomplete types. - */ - public function getTypes() - { - return $this->types; - } - - /** - * Sets the autocomplete types. - * - * @param array $types The autocomplete types. - */ - public function setTypes(array $types) - { - $this->types = array(); - - foreach ($types as $type) { - $this->addType($type); - } - } - - /** - * Adds a type to the autocomplete. - * - * @param string $type The type to add. - * - * @throws \Ivory\GoogleMap\Exception\PlaceException If the type is not valid. - * @throws \Ivory\GoogleMap\Exception\PlaceException If the type already exists. - */ - public function addType($type) - { - if (!in_array($type, AutocompleteType::getAvailableAutocompleteTypes())) { - throw PlaceException::invalidAutocompleteType(); - } - - if ($this->hasType($type)) { - throw PlaceException::autocompleteTypeAlreadyExists($type); - } - - $this->types[] = $type; - } - - /** - * Removes a type from the autocomplete. - * - * @param string $type The type to remove. - * - * @throws \Ivory\GoogleMap\Exception\PlaceException If the type does not exist. - */ - public function removeType($type) - { - if (!$this->hasType($type)) { - throw PlaceException::autocompleteTypeDoesNotExist($type); - } - - $index = array_search($type, $this->types); - unset($this->types[$index]); - } - - /** - * Checks if the autocomplete has component restrictions. - * - * @return boolean TRUE if the autocomplete has component restrictions else FALSE. - */ - public function hasComponentRestrictions() - { - return !empty($this->componentRestrictions); - } - - /** - * Checks if the autocomplete has a specific component restriction type. - * - * @param string $type The component restriction type. - * - * @return boolean TRUE if the autocomplete has the specific component restriction type else FALSE. - */ - public function hasComponentRestriction($type) - { - return isset($this->componentRestrictions[$type]); - } - - /** - * Gets the component restrictions. - * - * @return array The component restrictions. - */ - public function getComponentRestrictions() - { - return $this->componentRestrictions; - } - - /** - * Gets a specific component restriction. - * - * @param string $type The component restriction type. - * - * @throws \Ivory\GoogleMap\Exception\PlaceException If the component restriction type does not exist. - * - * @return mixed The component restriction. - */ - public function getComponentRestriction($type) - { - if (!$this->hasComponentRestriction($type)) { - throw PlaceException::autocompleteComponentRestrictionDoesNotExist($type); - } - - return $this->componentRestrictions[$type]; - } - - /** - * Sets the component restrictions. - * - * @param array $componentRestrictions The component restrictions. - */ - public function setComponentRestrictions(array $componentRestrictions) - { - $this->componentRestrictions = array(); - - foreach ($componentRestrictions as $type => $value) { - $this->addComponentRestriction($type, $value); - } - } - - /** - * Adds a component restriction. - * - * @param string $type The component restriction type. - * @param mixed $value The component restriction value. - * - * @throws \Ivory\GoogleMap\Exception\PlaceException If the component restriction type is not supported. - * @throws \Ivory\GoogleMap\Exception\PlaceException If the component restriction type already exists. - */ - public function addComponentRestriction($type, $value) - { - if (!in_array($type, AutocompleteComponentRestriction::getAvailableAutocompleteComponentRestrictions())) { - throw PlaceException::invalidAutocompleteComponentRestriction(); - } - - if ($this->hasComponentRestriction($type)) { - throw PlaceException::autocompleteComponentRestrictionAlreadyExists($type); - } - - $this->componentRestrictions[$type] = $value; - } - - /** - * Removes a component restriction. - * - * @param string $type The component restriction. - * - * @throws \Ivory\GoogleMap\Exception\PlaceException If the component restriction type does not exists. - */ - public function removeComponentRestriction($type) - { - if (!$this->hasComponentRestriction($type)) { - throw PlaceException::autocompleteComponentRestrictionDoesNotExist($type); - } - - unset($this->componentRestrictions[$type]); - } - - /** - * Checks if the autocomplete has a value. - * - * @return boolean TRUE if the autocomplete has a value else FALSE. - */ - public function hasValue() - { - return $this->value !== null; - } - - /** - * Gets the autocomplete value. - * - * @return string The autocomplete value. - */ - public function getValue() - { - return $this->value; - } - - /** - * Sets the autocomplete value. - * - * @param string $value The autocomplete value. - */ - public function setValue($value) - { - $this->value = $value; - } - - /** - * Gets the autocomplete input attributes. - * - * @return array The autocomplete input attributes. - */ - public function getInputAttributes() - { - return $this->inputAttributes; - } - - /** - * Sets the autocomplete input attributes. - * - * @param array $inputAttributes The autocomplete input attributes. - */ - public function setInputAttributes(array $inputAttributes) - { - $this->inputAttributes = array(); - - foreach ($inputAttributes as $name => $value) { - $this->setInputAttribute($name, $value); - } - } - - /** - * Sets an autocomplete attribute. - * - * You can remove an attribute by setting it to `null`. - * - * @param string $name The attribute name. - * @param mixed $value The attribute value. - */ - public function setInputAttribute($name, $value) - { - if ($value === null) { - if (isset($this->inputAttributes[$name])) { - unset($this->inputAttributes[$name]); - } - } else { - $this->inputAttributes[$name] = $value; - } - } - - /** - * Checks if the autocomplete is loaded asynchronously. - * - * @return boolean TRUE if the autocomplete is loaded asynchronounsly else FALSE. - */ - public function isAsync() - { - return $this->async; - } - - /** - * Sets if the autocomplete is loaded asynchronously. - * - * @param boolean $async TRUE if the autocomplete is loaded asynchronously else FALSE. - */ - public function setAsync($async) - { - if (!is_bool($async)) { - throw PlaceException::invalidAutocompleteAsync(); - } - - $this->async = $async; - } - - /** - * Gets the autocomplete language - * - * @return string The autocomplete language - */ - public function getLanguage() - { - return $this->language; - } - - /** - * Sets the autocomplete language. - * - * @param string $language The autocomplete language - */ - public function setLanguage($language) - { - $this->language = $language; - } -} diff --git a/src/Places/AutocompleteComponentRestriction.php b/src/Places/AutocompleteComponentRestriction.php deleted file mode 100644 index 47e3b23d..00000000 --- a/src/Places/AutocompleteComponentRestriction.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Places; - -/** - * Places autocomplete component restriction. - * - * @author GeLo - * @author Semyon Velichko - */ -class AutocompleteComponentRestriction -{ - const COUNTRY = 'country'; - - /** - * Disabled constructor. - * - * @codeCoverageIgnore - */ - final private function __construct() - { - } - - /** - * Gets the available component restrictions. - * - * @return array The available component restrictions. - */ - public static function getAvailableAutocompleteComponentRestrictions() - { - return array( - self::COUNTRY, - ); - } -} \ No newline at end of file diff --git a/src/Places/AutocompleteType.php b/src/Places/AutocompleteType.php deleted file mode 100644 index b2ce866f..00000000 --- a/src/Places/AutocompleteType.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Places; - -/** - * Place autocomplete type. - * - * @author GeLo - */ -class AutocompleteType -{ - const ESTABLISHMENT = 'establishment'; - const GEOCODE = 'geocode'; - const REGIONS = '(regions)'; - const CITIES = '(cities)'; - - /** - * Disabled constructor. - * - * @codeCoverageIgnore - */ - final private function __construct() - { - - } - - /** - * Gets the available autocomplete types. - * - * @return array The available autocomplete types. - */ - public static function getAvailableAutocompleteTypes() - { - return array( - self::ESTABLISHMENT, - self::GEOCODE, - self::REGIONS, - self::CITIES, - ); - } -} diff --git a/src/Service/AbstractService.php b/src/Service/AbstractService.php new file mode 100644 index 00000000..1b3adc79 --- /dev/null +++ b/src/Service/AbstractService.php @@ -0,0 +1,214 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service; + +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Ivory\GoogleMap\Service\Utility\XmlParser; +use Psr\Http\Message\RequestInterface; + +/** + * @author GeLo + */ +abstract class AbstractService +{ + const FORMAT_JSON = 'json'; + const FORMAT_XML = 'xml'; + + /** + * @var HttpClient + */ + private $client; + + /** + * @var MessageFactory + */ + private $messageFactory; + + /** + * @var string + */ + private $url; + + /** + * @var bool + */ + private $https = true; + + /** + * @var string + */ + private $format = self::FORMAT_JSON; + + /** + * @var XmlParser + */ + private $xmlParser; + + /** + * @var BusinessAccount|null + */ + private $businessAccount; + + /** + * @param HttpClient $client + * @param MessageFactory $messageFactory + * @param string $url + */ + public function __construct(HttpClient $client, MessageFactory $messageFactory, $url) + { + $this->setClient($client); + $this->setMessageFactory($messageFactory); + $this->setUrl($url); + $this->setXmlParser(new XmlParser()); + } + + /** + * @return HttpClient + */ + public function getClient() + { + return $this->client; + } + + /** + * @param HttpClient $client + */ + public function setClient(HttpClient $client) + { + $this->client = $client; + } + + /** + * @return MessageFactory + */ + public function getMessageFactory() + { + return $this->messageFactory; + } + + /** + * @param MessageFactory $messageFactory + */ + public function setMessageFactory(MessageFactory $messageFactory) + { + $this->messageFactory = $messageFactory; + } + + /** + * @return string + */ + public function getUrl() + { + if ($this->isHttps()) { + return str_replace('http://', 'https://', $this->url); + } + + return $this->url; + } + + /** + * @param string $url + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * @return bool + */ + public function isHttps() + { + return $this->https; + } + + /** + * @param bool $https + */ + public function setHttps($https) + { + $this->https = $https; + } + + /** + * @return string + */ + public function getFormat() + { + return $this->format; + } + + /** + * @param string $format + */ + public function setFormat($format) + { + $this->format = $format; + } + + /** + * @return XmlParser + */ + public function getXmlParser() + { + return $this->xmlParser; + } + + /** + * @param XmlParser $xmlParser + */ + public function setXmlParser(XmlParser $xmlParser) + { + $this->xmlParser = $xmlParser; + } + + /** + * @return bool + */ + public function hasBusinessAccount() + { + return $this->businessAccount !== null; + } + + /** + * @return BusinessAccount + */ + public function getBusinessAccount() + { + return $this->businessAccount; + } + + /** + * @param BusinessAccount $businessAccount + */ + public function setBusinessAccount(BusinessAccount $businessAccount = null) + { + $this->businessAccount = $businessAccount; + } + + /** + * @param string[] $query + * + * @return RequestInterface + */ + protected function createRequest(array $query) + { + $url = $this->getUrl().'/'.$this->getFormat().'?'.http_build_query($query, '', '&'); + + if ($this->hasBusinessAccount()) { + $url = $this->businessAccount->signUrl($url); + } + + return $this->messageFactory->createRequest('GET', $url); + } +} diff --git a/src/Service/Base/Distance.php b/src/Service/Base/Distance.php new file mode 100644 index 00000000..9d1b9836 --- /dev/null +++ b/src/Service/Base/Distance.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Base; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Distance + * + * @author GeLo + */ +class Distance +{ + /** + * @var string + */ + private $text; + + /** + * @var float + */ + private $value; + + /** + * @param string $text + * @param float $value + */ + public function __construct($text, $value) + { + $this->setText($text); + $this->setValue($value); + } + + /** + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * @param string $text + */ + public function setText($text) + { + $this->text = $text; + } + + /** + * @return float + */ + public function getValue() + { + return $this->value; + } + + /** + * @param float $value + */ + public function setValue($value) + { + $this->value = $value; + } +} diff --git a/src/Service/Base/Duration.php b/src/Service/Base/Duration.php new file mode 100644 index 00000000..b5b1b819 --- /dev/null +++ b/src/Service/Base/Duration.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Base; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Duration + * + * @author GeLo + */ +class Duration +{ + /** + * @var string + */ + private $text; + + /** + * @var float + */ + private $value; + + /** + * @param string $text + * @param float $value + */ + public function __construct($text, $value) + { + $this->setText($text); + $this->setValue($value); + } + + /** + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * @param string $text + */ + public function setText($text) + { + $this->text = $text; + } + + /** + * @return float + */ + public function getValue() + { + return $this->value; + } + + /** + * @param float $value + */ + public function setValue($value) + { + $this->value = $value; + } +} diff --git a/src/Services/Base/TravelMode.php b/src/Service/Base/TravelMode.php similarity index 53% rename from src/Services/Base/TravelMode.php rename to src/Service/Base/TravelMode.php index 21ff4209..cd490c78 100644 --- a/src/Services/Base/TravelMode.php +++ b/src/Service/Base/TravelMode.php @@ -9,15 +9,14 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Services\Base; +namespace Ivory\GoogleMap\Service\Base; /** - * A travel mode which describes the google map travel mode. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#TravelMode + * * @author GeLo */ -class TravelMode +final class TravelMode { const BICYCLING = 'BICYCLING'; const DRIVING = 'DRIVING'; @@ -25,27 +24,9 @@ class TravelMode const TRANSIT = 'TRANSIT'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available travel modes. - * - * @return array The available travel modes. - */ - public static function getTravelModes() + private function __construct() { - return array( - self::BICYCLING, - self::DRIVING, - self::WALKING, - self::TRANSIT, - ); } } diff --git a/src/Services/Base/UnitSystem.php b/src/Service/Base/UnitSystem.php similarity index 53% rename from src/Services/Base/UnitSystem.php rename to src/Service/Base/UnitSystem.php index 51ba9d20..7f2f56cc 100644 --- a/src/Services/Base/UnitSystem.php +++ b/src/Service/Base/UnitSystem.php @@ -9,39 +9,22 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Services\Base; +namespace Ivory\GoogleMap\Service\Base; /** - * A unit system which describes the google map unit system. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#UnitSystem + * * @author GeLo */ -class UnitSystem +final class UnitSystem { const IMPERIAL = 'IMPERIAL'; const METRIC = 'METRIC'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available unit systems. - * - * @return array The available unit systems. - */ - public static function getUnitSystems() + private function __construct() { - return array( - self::IMPERIAL, - self::METRIC, - ); } } diff --git a/src/Service/BusinessAccount.php b/src/Service/BusinessAccount.php new file mode 100644 index 00000000..23752a91 --- /dev/null +++ b/src/Service/BusinessAccount.php @@ -0,0 +1,122 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service; + +/** + * @author GeLo + */ +class BusinessAccount +{ + /** + * @var string + */ + private $clientId; + + /** + * @var string + */ + private $secret; + + /** + * @var string + */ + private $channel; + + /** + * @param string $clientId + * @param string $secret + * @param string $channel + */ + public function __construct($clientId, $secret, $channel = null) + { + $this->setClientId($clientId); + $this->setSecret($secret); + $this->setChannel($channel); + } + + /** + * @return string + */ + public function getClientId() + { + return $this->clientId; + } + + /** + * @param string $clientId + */ + public function setClientId($clientId) + { + $this->clientId = $clientId; + } + + /** + * @return string + */ + public function getSecret() + { + return $this->secret; + } + + /** + * @param string $secret + */ + public function setSecret($secret) + { + $this->secret = $secret; + } + + /** + * @return bool + */ + public function hasChannel() + { + return $this->channel !== null; + } + + /** + * @return string|null + */ + public function getChannel() + { + return $this->channel; + } + + /** + * @param string|null $channel + */ + public function setChannel($channel = null) + { + $this->channel = $channel; + } + + /** + * @param string $url + * + * @return string + */ + public function signUrl($url) + { + $url .= '&client=gme-'.$this->clientId; + + if ($this->hasChannel()) { + $url .= '&channel='.$this->channel; + } + + $urlParts = parse_url($url); + $data = $urlParts['path'].'?'.$urlParts['query']; + $key = base64_decode(str_replace(['-', '_'], ['+', '/'], $this->secret)); + $signature = base64_encode(hash_hmac('sha1', $data, $key, true)); + + return $url.'&signature='.str_replace(['+', '/'], ['-', '_'], $signature); + } +} diff --git a/src/Service/Directions/Directions.php b/src/Service/Directions/Directions.php new file mode 100644 index 00000000..2d05e478 --- /dev/null +++ b/src/Service/Directions/Directions.php @@ -0,0 +1,194 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Directions; + +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\GoogleMap\Service\AbstractService; +use Ivory\GoogleMap\Service\Base\Distance; +use Ivory\GoogleMap\Service\Base\Duration; + +/** + * @author GeLo + */ +class Directions extends AbstractService +{ + /** + * @param HttpClient $client + * @param MessageFactory $messageFactory + */ + public function __construct(HttpClient $client, MessageFactory $messageFactory) + { + parent::__construct($client, $messageFactory, 'http://maps.googleapis.com/maps/api/directions'); + } + + /** + * @param DirectionsRequest $request + * + * @return DirectionsResponse + */ + public function route(DirectionsRequest $request) + { + $response = $this->getClient()->sendRequest($this->createRequest($request->buildQuery())); + $data = $this->parse((string) $response->getBody()); + + return $this->buildResponse($data); + } + + /** + * @param string $data + * + * @return mixed[] + */ + private function parse($data) + { + if ($this->getFormat() === self::FORMAT_JSON) { + return json_decode($data, true); + } + + return $this->getXmlParser()->parse($data, [ + 'leg' => 'legs', + 'route' => 'routes', + 'step' => 'steps', + ]); + } + + /** + * @param mixed[] $data + * + * @return DirectionsResponse + */ + private function buildResponse(array $data) + { + $response = new DirectionsResponse(); + $response->setStatus($data['status']); + $response->setRoutes(isset($data['routes']) ? $this->buildRoutes($data['routes']) : []); + + return $response; + } + + /** + * @param mixed[] $data + * + * @return DirectionsRoute[] + */ + private function buildRoutes(array $data) + { + $routes = []; + foreach ($data as $item) { + $routes[] = $this->buildRoute($item); + } + + return $routes; + } + + /** + * @param mixed[] $data + * + * @return DirectionsRoute + */ + private function buildRoute(array $data) + { + $route = new DirectionsRoute(); + $route->setCopyrights(isset($data['copyrights']) ? $data['copyrights'] : null); + $route->setLegs($this->buildLegs($data['legs'])); + $route->setOverviewPolyline(new EncodedPolyline($data['overview_polyline']['points'])); + $route->setSummary(isset($data['summary']) ? $data['summary'] : null); + $route->setWarnings(isset($data['warnings']) ? $data['warnings'] : []); + $route->setWaypointOrders(isset($data['waypoint_order']) ? $data['waypoint_order'] : []); + + $route->setBound(new Bound( + new Coordinate( + $data['bounds']['southwest']['lat'], + $data['bounds']['southwest']['lng'] + ), + new Coordinate( + $data['bounds']['northeast']['lat'], + $data['bounds']['northeast']['lng'] + ) + )); + + return $route; + } + + /** + * @param mixed[] $data + * + * @return DirectionsLeg[] + */ + private function buildLegs(array $data) + { + $legs = []; + foreach ($data as $item) { + $legs[] = $this->buildLeg($item); + } + + return $legs; + } + + /** + * @param mixed[] $data + * + * @return DirectionsLeg + */ + private function buildLeg(array $data) + { + $leg = new DirectionsLeg(); + $leg->setDistance(new Distance($data['distance']['text'], $data['distance']['value'])); + $leg->setDuration(new Duration($data['duration']['text'], $data['duration']['value'])); + $leg->setEndAddress($data['end_address']); + $leg->setEndLocation(new Coordinate($data['end_location']['lat'], $data['end_location']['lng'])); + $leg->setStartAddress($data['start_address']); + $leg->setStartLocation(new Coordinate($data['start_location']['lat'], $data['start_location']['lng'])); + $leg->setSteps($this->buildSteps($data['steps'])); + $leg->setViaWaypoints(isset($data['via_waypoint']) ? $data['via_waypoint'] : []); + + return $leg; + } + + /** + * @param mixed[] $data + * + * @return DirectionsStep[] + */ + private function buildSteps(array $data) + { + $steps = []; + foreach ($data as $item) { + $steps[] = $this->buildStep($item); + } + + return $steps; + } + + /** + * @param mixed[] $data + * + * @return DirectionsStep + */ + private function buildStep(array $data) + { + $step = new DirectionsStep(); + $step->setDistance(new Distance($data['distance']['text'], $data['distance']['value'])); + $step->setDuration(new Duration($data['duration']['text'], $data['duration']['value'])); + $step->setEndLocation(new Coordinate($data['end_location']['lat'], $data['end_location']['lng'])); + $step->setInstructions($data['html_instructions']); + $step->setEncodedPolyline(new EncodedPolyline($data['polyline']['points'])); + $step->setStartLocation(new Coordinate($data['start_location']['lat'], $data['start_location']['lng'])); + $step->setTravelMode($data['travel_mode']); + + return $step; + } +} diff --git a/src/Service/Directions/DirectionsLeg.php b/src/Service/Directions/DirectionsLeg.php new file mode 100644 index 00000000..eab5b53e --- /dev/null +++ b/src/Service/Directions/DirectionsLeg.php @@ -0,0 +1,295 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Base\Distance; +use Ivory\GoogleMap\Service\Base\Duration; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsLeg + * + * @author GeLo + */ +class DirectionsLeg +{ + /** + * @var Distance|null + */ + private $distance; + + /** + * @var Duration|null + */ + private $duration; + + /** + * @var string|null + */ + private $endAddress; + + /** + * @var Coordinate|null + */ + private $endLocation; + + /** + * @var string|null + */ + private $startAddress; + + /** + * @var Coordinate|null + */ + private $startLocation; + + /** + * @var DirectionsStep[] + */ + private $steps = []; + + /** + * @var mixed[] + */ + private $viaWaypoints = []; + + /** + * @return bool + */ + public function hasDistance() + { + return $this->distance !== null; + } + + /** + * @return Distance|null + */ + public function getDistance() + { + return $this->distance; + } + + /** + * @param Distance|null $distance + */ + public function setDistance(Distance $distance = null) + { + $this->distance = $distance; + } + + /** + * @return bool + */ + public function hasDuration() + { + return $this->duration !== null; + } + + /** + * @return Duration|null + */ + public function getDuration() + { + return $this->duration; + } + + /** + * @param Duration|null $duration + */ + public function setDuration(Duration $duration = null) + { + $this->duration = $duration; + } + + /** + * @return bool + */ + public function hasEndAddress() + { + return $this->endAddress !== null; + } + + /** + * @return string|null + */ + public function getEndAddress() + { + return $this->endAddress; + } + + /** + * @param string|null $endAddress + */ + public function setEndAddress($endAddress = null) + { + $this->endAddress = $endAddress; + } + + /** + * @return bool + */ + public function hasEndLocation() + { + return $this->endLocation !== null; + } + + /** + * @return Coordinate|null + */ + public function getEndLocation() + { + return $this->endLocation; + } + + /** + * @param Coordinate|null $endLocation + */ + public function setEndLocation(Coordinate $endLocation = null) + { + $this->endLocation = $endLocation; + } + + /** + * @return bool + */ + public function hasStartAddress() + { + return $this->startAddress !== null; + } + + /** + * @return string|null + */ + public function getStartAddress() + { + return $this->startAddress; + } + + /** + * @param string|null $startAddress + */ + public function setStartAddress($startAddress = null) + { + $this->startAddress = $startAddress; + } + + /** + * @return bool + */ + public function hasStartLocation() + { + return $this->startLocation !== null; + } + + /** + * @return Coordinate|null + */ + public function getStartLocation() + { + return $this->startLocation; + } + + /** + * @param Coordinate|null $startLocation + */ + public function setStartLocation(Coordinate $startLocation = null) + { + $this->startLocation = $startLocation; + } + + /** + * @return bool + */ + public function hasSteps() + { + return !empty($this->steps); + } + + /** + * @return DirectionsStep[] + */ + public function getSteps() + { + return $this->steps; + } + + /** + * @param DirectionsStep[] $steps + */ + public function setSteps(array $steps) + { + $this->steps = []; + $this->addSteps($steps); + } + + /** + * @param DirectionsStep[] $steps + */ + public function addSteps(array $steps) + { + foreach ($steps as $step) { + $this->addStep($step); + } + } + + /** + * @param DirectionsStep $step + * + * @return bool + */ + public function hasStep(DirectionsStep $step) + { + return in_array($step, $this->steps, true); + } + + /** + * @param DirectionsStep $step + */ + public function addStep(DirectionsStep $step) + { + if (!$this->hasStep($step)) { + $this->steps[] = $step; + } + } + + /** + * @param DirectionsStep $step + */ + public function removeStep(DirectionsStep $step) + { + unset($this->steps[array_search($step, $this->steps, true)]); + } + + /** + * @return bool + */ + public function hasViaWaypoints() + { + return !empty($this->viaWaypoints); + } + + /** + * @return mixed[] + */ + public function getViaWaypoints() + { + return $this->viaWaypoints; + } + + /** + * @param mixed[] $viaWaypoints + */ + public function setViaWaypoints(array $viaWaypoints) + { + $this->viaWaypoints = $viaWaypoints; + } +} diff --git a/src/Service/Directions/DirectionsRequest.php b/src/Service/Directions/DirectionsRequest.php new file mode 100644 index 00000000..02192237 --- /dev/null +++ b/src/Service/Directions/DirectionsRequest.php @@ -0,0 +1,516 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Coordinate; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsRequest + * + * @author GeLo + */ +class DirectionsRequest +{ + /** + * @var Coordinate|string + */ + private $origin; + + /** + * @var Coordinate|string + */ + private $destination; + + /** + * @var \DateTime|null + */ + private $departureTime; + + /** + * @var \DateTime|null + */ + private $arrivalTime; + + /** + * @var DirectionsWaypoint[] + */ + private $waypoints = []; + + /** + * @var bool|null + */ + private $optimizeWaypoints; + + /** + * @var string|null + */ + private $travelMode; + + /** + * @var bool|null + */ + private $avoidHighways; + + /** + * @var bool|null + */ + private $avoidTolls; + + /** + * @var bool|null + */ + private $provideRouteAlternatives; + + /** + * @var string|null + */ + private $region; + + /** + * @var string|null + */ + private $unitSystem; + + /** + * @var string|null + */ + private $language; + + /** + * @param Coordinate|string $origin + * @param Coordinate|string $destination + */ + public function __construct($origin, $destination) + { + $this->setOrigin($origin); + $this->setDestination($destination); + } + + /** + * @return Coordinate|string + */ + public function getOrigin() + { + return $this->origin; + } + + /** + * @param Coordinate|string $origin + */ + public function setOrigin($origin) + { + $this->origin = $origin; + } + + /** + * @return Coordinate|string + */ + public function getDestination() + { + return $this->destination; + } + + /** + * @param Coordinate|string $destination + */ + public function setDestination($destination) + { + $this->destination = $destination; + } + + /** + * @return bool + */ + public function hasDepartureTime() + { + return $this->departureTime !== null; + } + + /** + * @return \DateTime|null + */ + public function getDepartureTime() + { + return $this->departureTime; + } + + /** + * @param \DateTime|null $departureTime + */ + public function setDepartureTime(\DateTime $departureTime = null) + { + $this->departureTime = $departureTime; + } + + /** + * @return bool + */ + public function hasArrivalTime() + { + return $this->arrivalTime !== null; + } + + /** + * @return \DateTime|null + */ + public function getArrivalTime() + { + return $this->arrivalTime; + } + + /** + * @param \DateTime|null $arrivalTime + */ + public function setArrivalTime(\DateTime $arrivalTime = null) + { + $this->arrivalTime = $arrivalTime; + } + + /** + * @return bool + */ + public function hasWaypoints() + { + return !empty($this->waypoints); + } + + /** + * @return DirectionsWaypoint[] + */ + public function getWaypoints() + { + return $this->waypoints; + } + + /** + * @param DirectionsWaypoint[] $waypoints + */ + public function setWaypoints(array $waypoints) + { + $this->waypoints = []; + $this->addWaypoints($waypoints); + } + + /** + * @param DirectionsWaypoint[] $waypoints + */ + public function addWaypoints(array $waypoints) + { + foreach ($waypoints as $waypoint) { + $this->addWaypoint($waypoint); + } + } + + /** + * @param DirectionsWaypoint $waypoint + * + * @return bool + */ + public function hasWaypoint(DirectionsWaypoint $waypoint) + { + return in_array($waypoint, $this->waypoints, true); + } + + /** + * @param DirectionsWaypoint $waypoint + */ + public function addWaypoint(DirectionsWaypoint $waypoint) + { + if (!$this->hasWaypoint($waypoint)) { + $this->waypoints[] = $waypoint; + } + } + + /** + * @param DirectionsWaypoint $waypoint + */ + public function removeWaypoint(DirectionsWaypoint $waypoint) + { + unset($this->waypoints[array_search($waypoint, $this->waypoints, true)]); + } + + /** + * @return bool + */ + public function hasOptimizeWaypoints() + { + return $this->optimizeWaypoints !== null; + } + + /** + * @return bool|null + */ + public function getOptimizeWaypoints() + { + return $this->optimizeWaypoints; + } + + /** + * @param bool|null $optimizeWaypoints + */ + public function setOptimizeWaypoints($optimizeWaypoints = null) + { + $this->optimizeWaypoints = $optimizeWaypoints; + } + + /** + * @return bool + */ + public function hasTravelMode() + { + return $this->travelMode !== null; + } + + /** + * @return string|null + */ + public function getTravelMode() + { + return $this->travelMode; + } + + /** + * @param string|null $travelMode + */ + public function setTravelMode($travelMode = null) + { + $this->travelMode = $travelMode; + } + + /** + * @return bool + */ + public function hasAvoidTolls() + { + return $this->avoidTolls !== null; + } + + /** + * @return bool|null + */ + public function getAvoidTolls() + { + return $this->avoidTolls; + } + + /** + * @param bool|null $avoidTolls + */ + public function setAvoidTolls($avoidTolls = null) + { + $this->avoidTolls = $avoidTolls; + + if ($this->hasAvoidTolls()) { + $this->setAvoidHighways(null); + } + } + + /** + * @return bool + */ + public function hasAvoidHighways() + { + return $this->avoidHighways !== null; + } + + /** + * @return bool|null + */ + public function getAvoidHighways() + { + return $this->avoidHighways; + } + + /** + * @param bool|null $avoidHighways + */ + public function setAvoidHighways($avoidHighways = null) + { + $this->avoidHighways = $avoidHighways; + + if ($this->hasAvoidHighways()) { + $this->setAvoidTolls(null); + } + } + + /** + * @return bool + */ + public function hasProvideRouteAlternatives() + { + return $this->provideRouteAlternatives !== null; + } + + /** + * @return bool|null + */ + public function getProvideRouteAlternatives() + { + return $this->provideRouteAlternatives; + } + + /** + * @param bool|null $provideRouteAlternatives + */ + public function setProvideRouteAlternatives($provideRouteAlternatives = null) + { + $this->provideRouteAlternatives = $provideRouteAlternatives; + } + + /** + * @return bool + */ + public function hasRegion() + { + return $this->region !== null; + } + + /** + * @return string|null + */ + public function getRegion() + { + return $this->region; + } + + /** + * @param string|null $region + */ + public function setRegion($region = null) + { + $this->region = $region; + } + + /** + * @return bool + */ + public function hasUnitSystem() + { + return $this->unitSystem !== null; + } + + /** + * @return string|null + */ + public function getUnitSystem() + { + return $this->unitSystem; + } + + /** + * @param string|null $unitSystem + */ + public function setUnitSystem($unitSystem = null) + { + $this->unitSystem = $unitSystem; + } + + /** + * @return bool + */ + public function hasLanguage() + { + return $this->language !== null; + } + + /** + * @return string|null + */ + public function getLanguage() + { + return $this->language; + } + + /** + * @param string|null $language + */ + public function setLanguage($language = null) + { + $this->language = $language; + } + + /** + * @return mixed[] + */ + public function buildQuery() + { + $query = [ + 'origin' => $this->buildPlace($this->origin), + 'destination' => $this->buildPlace($this->destination), + ]; + + if ($this->hasDepartureTime()) { + $query['departure_time'] = $this->departureTime->getTimestamp(); + } + + if ($this->hasArrivalTime()) { + $query['arrival_time'] = $this->arrivalTime->getTimestamp(); + } + + if ($this->hasWaypoints()) { + $waypoints = []; + + if ($this->optimizeWaypoints) { + $waypoints[] = 'optimize:true'; + } + + foreach ($this->waypoints as $waypoint) { + $stopover = $waypoint->getStopover() ? 'via:' : ''; + $waypoints[] = $stopover.$this->buildPlace($waypoint->getLocation()); + } + + $query['waypoints'] = implode('|', $waypoints); + } + + if ($this->hasTravelMode()) { + $query['mode'] = strtolower($this->travelMode); + } + + if ($this->avoidTolls) { + $query['avoid'] = 'tolls'; + } elseif ($this->avoidHighways) { + $query['avoid'] = 'highways'; + } + + if ($this->hasProvideRouteAlternatives()) { + $query['alternatives'] = $this->provideRouteAlternatives ? 'true' : 'false'; + } + + if ($this->hasRegion()) { + $query['region'] = $this->region; + } + + if ($this->hasUnitSystem()) { + $query['units'] = strtolower($this->unitSystem); + } + + if ($this->hasLanguage()) { + $query['language'] = $this->language; + } + + return $query; + } + + /** + * @param Coordinate|string $place + * + * @return string + */ + private function buildPlace($place) + { + if ($place instanceof Coordinate) { + return $place->getLatitude().','.$place->getLongitude(); + } + + return $place; + } +} diff --git a/src/Service/Directions/DirectionsResponse.php b/src/Service/Directions/DirectionsResponse.php new file mode 100644 index 00000000..d7b312d4 --- /dev/null +++ b/src/Service/Directions/DirectionsResponse.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Directions; + +/** + * @author GeLo + */ +class DirectionsResponse +{ + /** + * @var string|null + */ + private $status; + + /** + * @var DirectionsRoute[] + */ + private $routes = []; + + /** + * @return bool + */ + public function hasStatus() + { + return $this->status !== null; + } + + /** + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string|null $status + */ + public function setStatus($status = null) + { + $this->status = $status; + } + + /** + * @return bool + */ + public function hasRoutes() + { + return !empty($this->routes); + } + + /** + * @return DirectionsRoute[] + */ + public function getRoutes() + { + return $this->routes; + } + + /** + * @param DirectionsRoute[] $routes + */ + public function setRoutes(array $routes) + { + $this->routes = []; + $this->addRoutes($routes); + } + + /** + * @param DirectionsRoute[] $routes + */ + public function addRoutes(array $routes) + { + foreach ($routes as $route) { + $this->addRoute($route); + } + } + + /** + * @param DirectionsRoute $route + * + * @return bool + */ + public function hasRoute(DirectionsRoute $route) + { + return in_array($route, $this->routes, true); + } + + /** + * @param DirectionsRoute $route + */ + public function addRoute(DirectionsRoute $route) + { + if (!$this->hasRoute($route)) { + $this->routes[] = $route; + } + } + + /** + * @param DirectionsRoute $route + */ + public function removeRoute(DirectionsRoute $route) + { + unset($this->routes[array_search($route, $this->routes, true)]); + $this->routes = array_values($this->routes); + } +} diff --git a/src/Service/Directions/DirectionsRoute.php b/src/Service/Directions/DirectionsRoute.php new file mode 100644 index 00000000..dc982b74 --- /dev/null +++ b/src/Service/Directions/DirectionsRoute.php @@ -0,0 +1,336 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Overlay\EncodedPolyline; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsRoute + * + * @author GeLo + */ +class DirectionsRoute +{ + /** + * @var Bound|null + */ + private $bound; + + /** + * @var string|null + */ + private $copyrights; + + /** + * @var DirectionsLeg[] + */ + private $legs = []; + + /** + * @var EncodedPolyline|null + */ + private $overviewPolyline; + + /** + * @var string|null + */ + private $summary; + + /** + * @var string[] + */ + private $warnings = []; + + /** + * @var int[] + */ + private $waypointOrders = []; + + /** + * @return bool + */ + public function hasBound() + { + return $this->bound !== null; + } + + /** + * @return Bound|null + */ + public function getBound() + { + return $this->bound; + } + + /** + * @param Bound|null $bound + */ + public function setBound(Bound $bound = null) + { + $this->bound = $bound; + } + + /** + * @return bool + */ + public function hasCopyrights() + { + return $this->copyrights !== null; + } + + /** + * @return string|null + */ + public function getCopyrights() + { + return $this->copyrights; + } + + /** + * @param string|null $copyrights + */ + public function setCopyrights($copyrights = null) + { + $this->copyrights = $copyrights; + } + + /** + * @return bool + */ + public function hasLegs() + { + return !empty($this->legs); + } + + /** + * @return DirectionsLeg[] + */ + public function getLegs() + { + return $this->legs; + } + + /** + * @param DirectionsLeg[] $legs + */ + public function setLegs(array $legs) + { + $this->legs = []; + $this->addLegs($legs); + } + + /** + * @param DirectionsLeg[] $legs + */ + public function addLegs(array $legs) + { + foreach ($legs as $leg) { + $this->addLeg($leg); + } + } + + /** + * @param DirectionsLeg $leg + * + * @return bool + */ + public function hasLeg(DirectionsLeg $leg) + { + return in_array($leg, $this->legs, true); + } + + /** + * @param DirectionsLeg $leg + */ + public function addLeg(DirectionsLeg $leg) + { + if (!$this->hasLeg($leg)) { + $this->legs[] = $leg; + } + } + + /** + * @param DirectionsLeg $leg + */ + public function removeLeg(DirectionsLeg $leg) + { + unset($this->legs[array_search($leg, $this->legs, true)]); + $this->legs = array_values($this->legs); + } + + /** + * @return bool + */ + public function hasOverviewPolyline() + { + return $this->overviewPolyline !== null; + } + + /** + * @return EncodedPolyline|null + */ + public function getOverviewPolyline() + { + return $this->overviewPolyline; + } + + /** + * @param EncodedPolyline|null $overviewPolyline + */ + public function setOverviewPolyline(EncodedPolyline $overviewPolyline = null) + { + $this->overviewPolyline = $overviewPolyline; + } + + /** + * @return bool + */ + public function hasSummary() + { + return $this->summary !== null; + } + + /** + * @return string|null + */ + public function getSummary() + { + return $this->summary; + } + + /** + * @param string|null $summary + */ + public function setSummary($summary = null) + { + $this->summary = $summary; + } + + /** + * @return bool + */ + public function hasWarnings() + { + return !empty($this->warnings); + } + + /** + * @return string[] + */ + public function getWarnings() + { + return $this->warnings; + } + + /** + * @param string[] $warnings + */ + public function setWarnings(array $warnings) + { + $this->warnings = []; + $this->addWarnings($warnings); + } + + /** + * @param string[] $warnings + */ + public function addWarnings(array $warnings) + { + foreach ($warnings as $warning) { + $this->addWarning($warning); + } + } + + /** + * @param $warning + * + * @return bool + */ + public function hasWarning($warning) + { + return in_array($warning, $this->warnings, true); + } + + /** + * @param string $warning + */ + public function addWarning($warning) + { + if (!$this->hasWarning($warning)) { + $this->warnings[] = $warning; + } + } + + /** + * @param string $warning + */ + public function removeWarning($warning) + { + unset($this->warnings[array_search($warning, $this->warnings, true)]); + } + + /** + * @return bool + */ + public function hasWaypointOrders() + { + return !empty($this->waypointOrders); + } + + /** + * @return int[] + */ + public function getWaypointOrders() + { + return $this->waypointOrders; + } + + /** + * @param int[] $waypointOrders + */ + public function setWaypointOrders(array $waypointOrders) + { + $this->waypointOrders = []; + $this->addWaypointOrders($waypointOrders); + } + + /** + * @param int[] $waypointOrders + */ + public function addWaypointOrders(array $waypointOrders) + { + $this->waypointOrders = []; + + foreach ($waypointOrders as $waypointOrder) { + $this->addWaypointOrder($waypointOrder); + } + } + + /** + * @param $waypointOrder + * + * @return bool + */ + public function hasWaypointOrder($waypointOrder) + { + return in_array($waypointOrder, $this->waypointOrders, true); + } + + /** + * @param int $waypointOrder + */ + public function addWaypointOrder($waypointOrder) + { + $this->waypointOrders[] = $waypointOrder; + } +} diff --git a/src/Services/Directions/DirectionsStatus.php b/src/Service/Directions/DirectionsStatus.php similarity index 53% rename from src/Services/Directions/DirectionsStatus.php rename to src/Service/Directions/DirectionsStatus.php index 72ce8dc2..1d3fc521 100644 --- a/src/Services/Directions/DirectionsStatus.php +++ b/src/Service/Directions/DirectionsStatus.php @@ -9,15 +9,14 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Services\Directions; +namespace Ivory\GoogleMap\Service\Directions; /** - * A directions status which describes the google map direction status. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsStatus + * * @author GeLo */ -class DirectionsStatus +final class DirectionsStatus { const INVALID_REQUEST = 'INVALID_REQUEST'; const MAX_WAYPOINTS_EXCEEDED = 'MAX_WAYPOINTS_EXCEEDED'; @@ -29,31 +28,9 @@ class DirectionsStatus const ZERO_RESULTS = 'ZERO_RESULTS'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available directions status. - * - * @return array The available directions status. - */ - public static function getDirectionsStatus() + private function __construct() { - return array( - self::INVALID_REQUEST, - self::MAX_WAYPOINTS_EXCEEDED, - self::NOT_FOUND, - self::OK, - self::OVER_QUERY_LIMIT, - self::REQUEST_DENIED, - self::UNKNOWN_ERROR, - self::ZERO_RESULTS, - ); } } diff --git a/src/Service/Directions/DirectionsStep.php b/src/Service/Directions/DirectionsStep.php new file mode 100644 index 00000000..5482b812 --- /dev/null +++ b/src/Service/Directions/DirectionsStep.php @@ -0,0 +1,228 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\GoogleMap\Service\Base\Distance; +use Ivory\GoogleMap\Service\Base\Duration; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsStep + * + * @author GeLo + */ +class DirectionsStep +{ + /** + * @var Distance|null + */ + private $distance; + + /** + * @var Duration|null + */ + private $duration; + + /** + * @var Coordinate|null + */ + private $endLocation; + + /** + * @var string|null + */ + private $instructions; + + /** + * @var EncodedPolyline|null + */ + private $encodedPolyline; + + /** + * @var Coordinate|null + */ + private $startLocation; + + /** + * @var string|null + */ + private $travelMode; + + /** + * @return bool + */ + public function hasDistance() + { + return $this->distance !== null; + } + + /** + * @return Distance|null + */ + public function getDistance() + { + return $this->distance; + } + + /** + * @param Distance|null $distance + */ + public function setDistance(Distance $distance = null) + { + $this->distance = $distance; + } + + /** + * @return bool + */ + public function hasDuration() + { + return $this->duration !== null; + } + + /** + * @return Duration|null + */ + public function getDuration() + { + return $this->duration; + } + + /** + * @param Duration|null $duration + */ + public function setDuration(Duration $duration = null) + { + $this->duration = $duration; + } + + /** + * @return bool + */ + public function hasEndLocation() + { + return $this->endLocation !== null; + } + + /** + * @return Coordinate|null + */ + public function getEndLocation() + { + return $this->endLocation; + } + + /** + * @param Coordinate|null $endLocation + */ + public function setEndLocation(Coordinate $endLocation = null) + { + $this->endLocation = $endLocation; + } + + /** + * @return bool + */ + public function hasInstructions() + { + return $this->instructions !== null; + } + + /** + * @return string|null + */ + public function getInstructions() + { + return $this->instructions; + } + + /** + * @param string|null $instructions + */ + public function setInstructions($instructions = null) + { + $this->instructions = $instructions; + } + + /** + * @return bool + */ + public function hasEncodedPolyline() + { + return $this->encodedPolyline !== null; + } + + /** + * @return EncodedPolyline|null + */ + public function getEncodedPolyline() + { + return $this->encodedPolyline; + } + + /** + * @param EncodedPolyline|null $encodedPolyline + */ + public function setEncodedPolyline(EncodedPolyline $encodedPolyline = null) + { + $this->encodedPolyline = $encodedPolyline; + } + + /** + * @return bool + */ + public function hasStartLocation() + { + return $this->startLocation !== null; + } + + /** + * @return Coordinate|null + */ + public function getStartLocation() + { + return $this->startLocation; + } + + /** + * @param Coordinate|null $startLocation + */ + public function setStartLocation(Coordinate $startLocation = null) + { + $this->startLocation = $startLocation; + } + + /** + * @return bool + */ + public function hasTravelMode() + { + return $this->travelMode !== null; + } + + /** + * @return string|null + */ + public function getTravelMode() + { + return $this->travelMode; + } + + /** + * @param string|null $travelMode + */ + public function setTravelMode($travelMode = null) + { + $this->travelMode = $travelMode; + } +} diff --git a/src/Service/Directions/DirectionsWaypoint.php b/src/Service/Directions/DirectionsWaypoint.php new file mode 100644 index 00000000..6ea50903 --- /dev/null +++ b/src/Service/Directions/DirectionsWaypoint.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Coordinate; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsWaypoint + * + * @author GeLo + */ +class DirectionsWaypoint +{ + /** + * @var Coordinate|string|null + */ + private $location; + + /** + * @var bool|null + */ + private $stopover; + + /** + * @return bool + */ + public function hasLocation() + { + return $this->location !== null; + } + + /** + * @return Coordinate|string|null + */ + public function getLocation() + { + return $this->location; + } + + /** + * @param Coordinate|string|null $location + */ + public function setLocation($location = null) + { + $this->location = $location; + } + + /** + * @return bool + */ + public function hasStopover() + { + return $this->stopover !== null; + } + + /** + * @return bool|null + */ + public function getStopover() + { + return $this->stopover; + } + + /** + * @param bool|null $stopover + */ + public function setStopover($stopover = null) + { + $this->stopover = $stopover; + } +} diff --git a/src/Service/DistanceMatrix/DistanceMatrix.php b/src/Service/DistanceMatrix/DistanceMatrix.php new file mode 100644 index 00000000..b8ac021f --- /dev/null +++ b/src/Service/DistanceMatrix/DistanceMatrix.php @@ -0,0 +1,138 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\DistanceMatrix; + +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Ivory\GoogleMap\Service\AbstractService; +use Ivory\GoogleMap\Service\Base\Distance; +use Ivory\GoogleMap\Service\Base\Duration; + +/** + * @author GeLo + */ +class DistanceMatrix extends AbstractService +{ + /** + * @param HttpClient $client + * @param MessageFactory $messageFactory + */ + public function __construct(HttpClient $client, MessageFactory $messageFactory) + { + parent::__construct($client, $messageFactory, 'http://maps.googleapis.com/maps/api/distancematrix'); + } + + /** + * @param DistanceMatrixRequest $request + * + * @return DistanceMatrixResponse + */ + public function process(DistanceMatrixRequest $request) + { + $response = $this->getClient()->sendRequest($this->createRequest($request->buildQuery())); + $data = $this->parse((string) $response->getBody()); + + return $this->buildResponse($data); + } + + /** + * @param string $data + * + * @return mixed[] + */ + private function parse($data) + { + if ($this->getFormat() === 'json') { + return json_decode($data, true); + } + + return $this->getXmlParser()->parse($data, [ + 'destination_address' => 'destination_addresses', + 'element' => 'elements', + 'origin_address' => 'origin_addresses', + 'row' => 'rows', + ]); + } + + /** + * @param mixed[] $data + * + * @return DistanceMatrixResponse + */ + private function buildResponse(array $data) + { + $response = new DistanceMatrixResponse(); + $response->setStatus($data['status']); + $response->setDestinations($data['destination_addresses']); + $response->setOrigins($data['origin_addresses']); + $response->setRows($this->buildRows($data['rows'])); + + return $response; + } + + /** + * @param mixed[] $data + * + * @return DistanceMatrixRow[] + */ + private function buildRows($data) + { + $rows = []; + + foreach ($data as $item) { + $rows[] = $this->buildRow($item); + } + + return $rows; + } + + /** + * @param mixed[] $data + * + * @return DistanceMatrixRow + */ + private function buildRow($data) + { + $elements = []; + foreach ($data['elements'] as $element) { + $elements[] = $this->buildElement($element); + } + + $row = new DistanceMatrixRow(); + $row->setElements($elements); + + return $row; + } + + /** + * @param mixed[] $data + * + * @return DistanceMatrixElement + */ + private function buildElement(array $data) + { + $distance = isset($data['distance']) + ? new Distance($data['distance']['text'], $data['distance']['value']) + : null; + + $duration = isset($data['duration']) + ? new Duration($data['duration']['text'], $data['duration']['value']) + : null; + + $element = new DistanceMatrixElement(); + $element->setStatus($data['status']); + $element->setDistance($distance); + $element->setDuration($duration); + + return $element; + } +} diff --git a/src/Service/DistanceMatrix/DistanceMatrixElement.php b/src/Service/DistanceMatrix/DistanceMatrixElement.php new file mode 100644 index 00000000..2477545c --- /dev/null +++ b/src/Service/DistanceMatrix/DistanceMatrixElement.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\DistanceMatrix; + +use Ivory\GoogleMap\Service\Base\Distance; +use Ivory\GoogleMap\Service\Base\Duration; + +/** + * @author GeLo + */ +class DistanceMatrixElement +{ + /** + * @var string|null + */ + private $status; + + /** + * @var Distance|null + */ + private $distance; + + /** + * @var Duration|null + */ + private $duration; + + /** + * @return bool + */ + public function hasStatus() + { + return $this->status !== null; + } + + /** + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string|null $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @return bool + */ + public function hasDistance() + { + return $this->distance !== null; + } + + /** + * @return Distance|null + */ + public function getDistance() + { + return $this->distance; + } + + /** + * @param Distance|null $distance + */ + public function setDistance(Distance $distance = null) + { + $this->distance = $distance; + } + + /** + * @return bool + */ + public function hasDuration() + { + return $this->duration !== null; + } + + /** + * @return Duration|null + */ + public function getDuration() + { + return $this->duration; + } + + /** + * @param Duration|null $duration + */ + public function setDuration(Duration $duration = null) + { + $this->duration = $duration; + } +} diff --git a/src/Service/DistanceMatrix/DistanceMatrixElementStatus.php b/src/Service/DistanceMatrix/DistanceMatrixElementStatus.php new file mode 100644 index 00000000..168e5ecb --- /dev/null +++ b/src/Service/DistanceMatrix/DistanceMatrixElementStatus.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\DistanceMatrix; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DistanceMatrixElementStatus + * + * @author GeLo + */ +final class DistanceMatrixElementStatus +{ + const NOT_FOUND = 'NOT_FOUND'; + const OK = 'OK'; + const ZERO_RESULTS = 'ZERO_RESULTS'; + + /** + * @codeCoverageIgnore + */ + private function __construct() + { + } +} diff --git a/src/Service/DistanceMatrix/DistanceMatrixRequest.php b/src/Service/DistanceMatrix/DistanceMatrixRequest.php new file mode 100644 index 00000000..b2a15853 --- /dev/null +++ b/src/Service/DistanceMatrix/DistanceMatrixRequest.php @@ -0,0 +1,411 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\DistanceMatrix; + +use Ivory\GoogleMap\Base\Coordinate; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DistanceMatrixRequest + * + * @author GeLo + */ +class DistanceMatrixRequest +{ + /** + * @var Coordinate[]|string[] + */ + private $origins = []; + + /** + * @var Coordinate[]|string[] + */ + private $destinations = []; + + /** + * @var string|null + */ + private $travelMode; + + /** + * @var bool|null + */ + private $avoidHighways; + + /** + * @var bool|null + */ + private $avoidTolls; + + /** + * @var string|null + */ + private $region; + + /** + * @var string|null + */ + private $unitSystem; + + /** + * @var string|null + */ + private $language; + + /** + * @param Coordinate[]|string[] $origins + * @param Coordinate[]|string[] $destinations + */ + public function __construct(array $origins, array $destinations) + { + $this->setOrigins($origins); + $this->setDestinations($destinations); + } + + /** + * @return bool + */ + public function hasOrigins() + { + return !empty($this->origins); + } + + /** + * @return Coordinate[]|string[] + */ + public function getOrigins() + { + return $this->origins; + } + + /** + * @param Coordinate[]|string[] $origins + */ + public function setOrigins(array $origins) + { + $this->origins = []; + $this->addOrigins($origins); + } + + /** + * @param Coordinate[]|string[] $origins + */ + public function addOrigins(array $origins) + { + foreach ($origins as $origin) { + $this->addOrigin($origin); + } + } + + /** + * @param Coordinate|string $origin + * + * @return bool + */ + public function hasOrigin($origin) + { + return in_array($origin, $this->origins, true); + } + + /** + * @param Coordinate|string $origin + */ + public function addOrigin($origin) + { + if (!$this->hasOrigin($origin)) { + $this->origins[] = $origin; + } + } + + /** + * @param Coordinate|string $origin + */ + public function removeOrigin($origin) + { + unset($this->origins[array_search($origin, $this->origins, true)]); + $this->origins = array_values($this->origins); + } + + /** + * @return bool + */ + public function hasDestinations() + { + return !empty($this->destinations); + } + + /** + * @return Coordinate[]|string[] + */ + public function getDestinations() + { + return $this->destinations; + } + + /** + * @param Coordinate[]|string[] $destinations + */ + public function setDestinations(array $destinations) + { + $this->destinations = []; + $this->addDestinations($destinations); + } + + /** + * @param Coordinate[]|string[] $destinations + */ + public function addDestinations(array $destinations) + { + foreach ($destinations as $destination) { + $this->addDestination($destination); + } + } + + /** + * @param Coordinate|string $destination + * + * @return bool + */ + public function hasDestination($destination) + { + return in_array($destination, $this->destinations, true); + } + + /** + * @param Coordinate|string $destination + */ + public function addDestination($destination) + { + if (!$this->hasDestination($destination)) { + $this->destinations[] = $destination; + } + } + + /** + * @param Coordinate|string $destination + */ + public function removeDestination($destination) + { + unset($this->destinations[array_search($destination, $this->destinations, true)]); + $this->destinations = array_values($this->destinations); + } + + /** + * @return bool + */ + public function hasTravelMode() + { + return $this->travelMode !== null; + } + + /** + * @return string|null + */ + public function getTravelMode() + { + return $this->travelMode; + } + + /** + * @param string|null $travelMode + */ + public function setTravelMode($travelMode = null) + { + $this->travelMode = $travelMode; + } + + /** + * @return bool + */ + public function hasAvoidHighways() + { + return $this->avoidHighways !== null; + } + + /** + * @return bool|null + */ + public function getAvoidHighways() + { + return $this->avoidHighways; + } + + /** + * @param bool|null $avoidHighways + */ + public function setAvoidHighways($avoidHighways = null) + { + $this->avoidHighways = $avoidHighways; + } + + /** + * @return bool + */ + public function hasAvoidTolls() + { + return $this->avoidTolls !== null; + } + + /** + * @return bool|null + */ + public function getAvoidTolls() + { + return $this->avoidTolls; + } + + /** + * @param bool|null $avoidTolls + */ + public function setAvoidTolls($avoidTolls = null) + { + $this->avoidTolls = $avoidTolls; + } + + /** + * @return bool + */ + public function hasRegion() + { + return $this->region !== null; + } + + /** + * @return string|null + */ + public function getRegion() + { + return $this->region; + } + + /** + * @param string|null $region + */ + public function setRegion($region = null) + { + $this->region = $region; + } + + /** + * @return bool + */ + public function hasUnitSystem() + { + return $this->unitSystem !== null; + } + + /** + * @return string|null + */ + public function getUnitSystem() + { + return $this->unitSystem; + } + + /** + * @param string|null $unitSystem + */ + public function setUnitSystem($unitSystem = null) + { + $this->unitSystem = $unitSystem; + } + + /** + * @return bool + */ + public function hasLanguage() + { + return $this->language !== null; + } + + /** + * @return string|null + */ + public function getLanguage() + { + return $this->language; + } + + /** + * @param string|null $language + */ + public function setLanguage($language = null) + { + $this->language = $language; + } + + /** + * @return mixed[] + */ + public function buildQuery() + { + $query = [ + 'origins' => implode('|', $this->buildPlaces($this->origins)), + 'destinations' => implode('|', $this->buildPlaces($this->destinations)), + ]; + + if ($this->hasTravelMode()) { + $query['mode'] = strtolower($this->travelMode); + } + + if ($this->avoidTolls) { + $query['avoidTolls'] = true; + } + + if ($this->avoidHighways) { + $query['avoidHighways'] = true; + } + + if ($this->hasUnitSystem()) { + $query['units'] = strtolower($this->unitSystem); + } + + if ($this->hasRegion()) { + $query['region'] = $this->region; + } + + if ($this->hasLanguage()) { + $query['language'] = $this->language; + } + + return $query; + } + + /** + * @param Coordinate[]|string[] $places + * + * @return string[] + */ + private function buildPlaces(array $places) + { + $result = []; + + foreach ($places as $place) { + $result[] = $this->buildPlace($place); + } + + return $result; + } + + /** + * @param Coordinate|string $place + * + * @return string + */ + private function buildPlace($place) + { + if ($place instanceof Coordinate) { + return $place->getLatitude().','.$place->getLongitude(); + } + + return $place; + } +} diff --git a/src/Service/DistanceMatrix/DistanceMatrixResponse.php b/src/Service/DistanceMatrix/DistanceMatrixResponse.php new file mode 100644 index 00000000..efb9cadb --- /dev/null +++ b/src/Service/DistanceMatrix/DistanceMatrixResponse.php @@ -0,0 +1,254 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\DistanceMatrix; + +/** + * @author GeLo + */ +class DistanceMatrixResponse +{ + /** + * @var string|null + */ + private $status; + + /** + * @var string[] + */ + private $origins = []; + + /** + * @var string[] + */ + private $destinations = []; + + /** + * @var DistanceMatrixRow[] + */ + private $rows = []; + + /** + * @return bool + */ + public function hasStatus() + { + return $this->status !== null; + } + + /** + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string|null $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @return bool + */ + public function hasOrigins() + { + return !empty($this->origins); + } + + /** + * @return string[] + */ + public function getOrigins() + { + return $this->origins; + } + + /** + * @param string[] $origins + */ + public function setOrigins(array $origins) + { + $this->origins = []; + $this->addOrigins($origins); + } + + /** + * @param string[] $origins + */ + public function addOrigins(array $origins) + { + foreach ($origins as $origin) { + $this->addOrigin($origin); + } + } + + /** + * @param string $origin + * + * @return bool + */ + public function hasOrigin($origin) + { + return in_array($origin, $this->origins, true); + } + + /** + * @param string $origin + */ + public function addOrigin($origin) + { + if (!$this->hasOrigin($origin)) { + $this->origins[] = $origin; + } + } + + /** + * @param string $origin + */ + public function removeOrigin($origin) + { + unset($this->origins[array_search($origin, $this->origins, true)]); + $this->origins = array_values($this->origins); + } + + /** + * @return bool + */ + public function hasDestinations() + { + return !empty($this->destinations); + } + + /** + * @return string[] + */ + public function getDestinations() + { + return $this->destinations; + } + + /** + * @param string[] $destinations + */ + public function setDestinations(array $destinations) + { + $this->destinations = []; + $this->addDestinations($destinations); + } + + /** + * @param string[] $destinations + */ + public function addDestinations(array $destinations) + { + foreach ($destinations as $destination) { + $this->addDestination($destination); + } + } + + /** + * @param string $destination + * + * @return bool + */ + public function hasDestination($destination) + { + return in_array($destination, $this->destinations, true); + } + + /** + * @param string $destination + */ + public function addDestination($destination) + { + if (!$this->hasDestination($destination)) { + $this->destinations[] = $destination; + } + } + + /** + * @param string $destination + */ + public function removeDestination($destination) + { + unset($this->destinations[array_search($destination, $this->destinations, true)]); + $this->destinations = array_values($this->destinations); + } + + /** + * @return bool + */ + public function hasRows() + { + return !empty($this->rows); + } + + /** + * @return DistanceMatrixRow[] + */ + public function getRows() + { + return $this->rows; + } + + /** + * @param DistanceMatrixRow[] $rows + */ + public function setRows(array $rows) + { + $this->rows = []; + $this->addRows($rows); + } + + /** + * @param DistanceMatrixRow[] $rows + */ + public function addRows(array $rows) + { + foreach ($rows as $row) { + $this->addRow($row); + } + } + + /** + * @param DistanceMatrixRow $row + * + * @return bool + */ + public function hasRow(DistanceMatrixRow $row) + { + return in_array($row, $this->rows, true); + } + + /** + * @param DistanceMatrixRow $row + */ + public function addRow(DistanceMatrixRow $row) + { + if (!$this->hasRow($row)) { + $this->rows[] = $row; + } + } + + /** + * @param DistanceMatrixRow $row + */ + public function removeRow(DistanceMatrixRow $row) + { + unset($this->rows[array_search($row, $this->rows, true)]); + $this->rows = array_values($this->rows); + } +} diff --git a/src/Service/DistanceMatrix/DistanceMatrixRow.php b/src/Service/DistanceMatrix/DistanceMatrixRow.php new file mode 100644 index 00000000..a27bb1a1 --- /dev/null +++ b/src/Service/DistanceMatrix/DistanceMatrixRow.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\DistanceMatrix; + +/** + * @author GeLo + */ +class DistanceMatrixRow +{ + /** + * @var DistanceMatrixElement[] + */ + private $elements = []; + + /** + * @return bool + */ + public function hasElements() + { + return !empty($this->elements); + } + + /** + * @return DistanceMatrixElement[] + */ + public function getElements() + { + return $this->elements; + } + + /** + * @param DistanceMatrixElement[] $elements + */ + public function setElements(array $elements) + { + $this->elements = []; + $this->addElements($elements); + } + + /** + * @param DistanceMatrixElement[] $elements + */ + public function addElements(array $elements) + { + foreach ($elements as $element) { + $this->addElement($element); + } + } + + /** + * @param DistanceMatrixElement $element + * + * @return bool + */ + public function hasElement(DistanceMatrixElement $element) + { + return in_array($element, $this->elements, true); + } + + /** + * @param DistanceMatrixElement $element + */ + public function addElement(DistanceMatrixElement $element) + { + if (!$this->hasElement($element)) { + $this->elements[] = $element; + } + } + + /** + * @param DistanceMatrixElement $element + */ + public function removeElement(DistanceMatrixElement $element) + { + unset($this->elements[array_search($element, $this->elements, true)]); + $this->elements = array_values($this->elements); + } +} diff --git a/src/Services/DistanceMatrix/DistanceMatrixStatus.php b/src/Service/DistanceMatrix/DistanceMatrixStatus.php similarity index 50% rename from src/Services/DistanceMatrix/DistanceMatrixStatus.php rename to src/Service/DistanceMatrix/DistanceMatrixStatus.php index fdb0fb27..e56ec282 100644 --- a/src/Services/DistanceMatrix/DistanceMatrixStatus.php +++ b/src/Service/DistanceMatrix/DistanceMatrixStatus.php @@ -9,16 +9,14 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Services\DistanceMatrix; +namespace Ivory\GoogleMap\Service\DistanceMatrix; /** - * A distance matrix status which describes the google map distance matrix status. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DistanceMatrixStatus + * * @author GeLo - * @author Tyler Sommer */ -class DistanceMatrixStatus +final class DistanceMatrixStatus { const INVALID_REQUEST = 'INVALID_REQUEST'; const MAX_DIMENSIONS_EXCEEDED = 'MAX_DIMENSIONS_EXCEEDED'; @@ -29,30 +27,9 @@ class DistanceMatrixStatus const UNKNOWN_ERROR = 'UNKNOWN_ERROR'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available distance matrix status. - * - * @return array The available distance matrix status. - */ - public static function getDistanceMatrixStatus() + private function __construct() { - return array( - self::INVALID_REQUEST, - self::MAX_DIMENSIONS_EXCEEDED, - self::MAX_ELEMENTS_EXCEEDED, - self::OK, - self::OVER_QUERY_LIMIT, - self::REQUEST_DENIED, - self::UNKNOWN_ERROR, - ); } } diff --git a/src/Service/Geocoder/GeocoderAddressComponent.php b/src/Service/Geocoder/GeocoderAddressComponent.php new file mode 100644 index 00000000..e5146b48 --- /dev/null +++ b/src/Service/Geocoder/GeocoderAddressComponent.php @@ -0,0 +1,147 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Geocoder; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderAddressComponent + * + * @author GeLo + */ +class GeocoderAddressComponent +{ + /** + * @var string|null + */ + private $longName; + + /** + * @var string|null + */ + private $shortName; + + /** + * @var string[] + */ + private $types = []; + + /** + * @return bool + */ + public function hasLongName() + { + return $this->longName !== null; + } + + /** + * @return string|null + */ + public function getLongName() + { + return $this->longName; + } + + /** + * @param string|null $longName + */ + public function setLongName($longName = null) + { + $this->longName = $longName; + } + + /** + * @return bool + */ + public function hasShortName() + { + return $this->shortName !== null; + } + + /** + * @return string|null + */ + public function getShortName() + { + return $this->shortName; + } + + /** + * @param string|null $shortName + */ + public function setShortName($shortName = null) + { + $this->shortName = $shortName; + } + + /** + * @return bool + */ + public function hasTypes() + { + return !empty($this->types); + } + + /** + * @return string[] + */ + public function getTypes() + { + return $this->types; + } + + /** + * @param string[] $types + */ + public function setTypes(array $types) + { + $this->types = []; + $this->addTypes($types); + } + + /** + * @param string[] $types + */ + public function addTypes(array $types) + { + foreach ($types as $type) { + $this->addType($type); + } + } + + /** + * @param string $type + * + * @return bool + */ + public function hasType($type) + { + return in_array($type, $this->types, true); + } + + /** + * @param string $type + */ + public function addType($type) + { + if (!$this->hasType($type)) { + $this->types[] = $type; + } + } + + /** + * @param string $type + */ + public function removeType($type) + { + unset($this->types[array_search($type, $this->types, true)]); + $this->types = array_values($this->types); + } +} diff --git a/src/Service/Geocoder/GeocoderGeometry.php b/src/Service/Geocoder/GeocoderGeometry.php new file mode 100644 index 00000000..0f57d16e --- /dev/null +++ b/src/Service/Geocoder/GeocoderGeometry.php @@ -0,0 +1,139 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Geocoder; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderGeometry + * + * @author GeLo + */ +class GeocoderGeometry +{ + /** + * @var Coordinate|null + */ + private $location; + + /** + * @var string|null + */ + private $locationType; + + /** + * @var Bound|null + */ + private $viewport; + + /** + * @var Bound|null + */ + private $bound; + + /** + * @return bool + */ + public function hasLocation() + { + return $this->location !== null; + } + + /** + * @return Coordinate|null + */ + public function getLocation() + { + return $this->location; + } + + /** + * @param Coordinate|null $location + */ + public function setLocation(Coordinate $location = null) + { + $this->location = $location; + } + + /** + * @return bool + */ + public function hasLocationType() + { + return $this->locationType !== null; + } + + /** + * @return string|null + */ + public function getLocationType() + { + return $this->locationType; + } + + /** + * @param string|null $locationType + */ + public function setLocationType($locationType = null) + { + $this->locationType = $locationType; + } + + /** + * @return bool + */ + public function hasViewport() + { + return $this->viewport !== null; + } + + /** + * @return Bound|null + */ + public function getViewport() + { + return $this->viewport; + } + + /** + * @param Bound|null $viewport + */ + public function setViewport(Bound $viewport = null) + { + $this->viewport = $viewport; + } + + /** + * @return bool + */ + public function hasBound() + { + return $this->bound !== null; + } + + /** + * @return Bound|null + */ + public function getBound() + { + return $this->bound; + } + + /** + * @param Bound|null $bound + */ + public function setBound(Bound $bound = null) + { + $this->bound = $bound; + } +} diff --git a/src/Services/Geocoding/Result/GeocoderLocationType.php b/src/Service/Geocoder/GeocoderLocationType.php similarity index 51% rename from src/Services/Geocoding/Result/GeocoderLocationType.php rename to src/Service/Geocoder/GeocoderLocationType.php index 4b3d63e7..4ecf7030 100644 --- a/src/Services/Geocoding/Result/GeocoderLocationType.php +++ b/src/Service/Geocoder/GeocoderLocationType.php @@ -9,15 +9,14 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Services\Geocoding\Result; +namespace Ivory\GoogleMap\Service\Geocoder; /** - * GeocoderLocationType which describes a google map geocoder location type. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderLocationType + * * @author GeLo */ -class GeocoderLocationType +final class GeocoderLocationType { const APPROXIMATE = 'APPROXIMATE'; const GEOMETRIC_CENTER = 'GEOMETRIC_CENTER'; @@ -25,27 +24,9 @@ class GeocoderLocationType const ROOFTOP = 'ROOFTOP'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available geocoder location types. - * - * @return array The availabel geocoder location types. - */ - public static function getGeocoderLocationTypes() + private function __construct() { - return array( - self::APPROXIMATE, - self::GEOMETRIC_CENTER, - self::RANGE_INTERPOLATED, - self::ROOFTOP, - ); } } diff --git a/src/Service/Geocoder/GeocoderProvider.php b/src/Service/Geocoder/GeocoderProvider.php new file mode 100644 index 00000000..da7c919e --- /dev/null +++ b/src/Service/Geocoder/GeocoderProvider.php @@ -0,0 +1,209 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Geocoder; + +use Geocoder\Provider\LocaleAwareProvider; +use Geocoder\Provider\LocaleTrait; +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\AbstractService; + +/** + * @author GeLo + */ +class GeocoderProvider extends AbstractService implements LocaleAwareProvider +{ + use LocaleTrait; + + /** + * @var int|null + */ + private $limit; + + /** + * @param HttpClient $client + * @param MessageFactory $messageFactory + */ + public function __construct(HttpClient $client, MessageFactory $messageFactory) + { + parent::__construct($client, $messageFactory, 'http://maps.googleapis.com/maps/api/geocode'); + } + + /** + * {@inheritdoc} + */ + public function getLimit() + { + return $this->limit; + } + + /** + * {@inheritdoc} + */ + public function limit($limit) + { + $this->limit = $limit; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function geocode($request) + { + if (!$request instanceof GeocoderRequest) { + $request = new GeocoderRequest($request); + } + + if ($this->locale !== null && !$request->hasLanguage()) { + $request->setLanguage($this->locale); + } + + $response = $this->getClient()->sendRequest($this->createRequest($request->buildQuery())); + $data = $this->parse((string) $response->getBody()); + + return $this->buildResponse($data); + } + + /** + * {@inheritdoc} + */ + public function reverse($latitude, $longitude) + { + return $this->geocode(new Coordinate($latitude, $longitude)); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'ivory_google_map'; + } + + /** + * @param string $data + * + * @return mixed[] + */ + private function parse($data) + { + if ($this->getFormat() === self::FORMAT_JSON) { + return json_decode($data, true); + } + + return $this->getXmlParser()->parse($data, [ + 'address_component' => 'address_components', + 'type' => 'types', + 'result' => 'results', + ]); + } + + /** + * @param mixed[] $data + * + * @return GeocoderResponse + */ + private function buildResponse(array $data) + { + $results = []; + foreach ($data['results'] as $index => $response) { + $results[] = $this->buildResult($response); + + if ($this->limit !== null && ++$index >= $this->limit) { + break; + } + } + + $response = new GeocoderResponse(); + $response->setStatus($data['status']); + $response->setResults($results); + + return $response; + } + + /** + * @param mixed[] $data + * + * @return GeocoderResult + */ + private function buildResult(array $data) + { + $result = new GeocoderResult(); + $result->setAddressComponents($this->buildAddressComponents($data['address_components'])); + $result->setFormattedAddress($data['formatted_address']); + $result->setGeometry($this->buildGeometry($data['geometry'])); + $result->setTypes(isset($data['types']) ? $data['types'] : []); + $result->setPartialMatch(isset($data['partial_match']) ? $data['partial_match'] : null); + + return $result; + } + + /** + * @param mixed[] $data + * + * @return GeocoderAddressComponent[] + */ + private function buildAddressComponents(array $data) + { + $addressComponents = []; + + foreach ($data as $item) { + $addressComponents[] = $this->buildAddressComponent($item); + } + + return $addressComponents; + } + + /** + * @param mixed[] $data + * + * @return GeocoderAddressComponent + */ + private function buildAddressComponent(array $data) + { + $addressComponent = new GeocoderAddressComponent(); + $addressComponent->setLongName($data['long_name']); + $addressComponent->setShortName($data['short_name']); + $addressComponent->setTypes($data['types']); + + return $addressComponent; + } + + /** + * @param mixed[] $data + * + * @return GeocoderGeometry + */ + private function buildGeometry(array $data) + { + $geometry = new GeocoderGeometry(); + $geometry->setLocation(new Coordinate($data['location']['lat'], $data['location']['lng'])); + $geometry->setLocationType($data['location_type']); + $geometry->setViewport(new Bound( + new Coordinate($data['viewport']['southwest']['lat'], $data['viewport']['southwest']['lng']), + new Coordinate($data['viewport']['northeast']['lat'], $data['viewport']['northeast']['lng']) + )); + + if (isset($data['bounds'])) { + $geometry->setBound(new Bound( + new Coordinate($data['bounds']['southwest']['lat'], $data['bounds']['southwest']['lng']), + new Coordinate($data['bounds']['northeast']['lat'], $data['bounds']['northeast']['lng']) + )); + } + + return $geometry; + } +} diff --git a/src/Service/Geocoder/GeocoderRequest.php b/src/Service/Geocoder/GeocoderRequest.php new file mode 100644 index 00000000..0bfb8a0f --- /dev/null +++ b/src/Service/Geocoder/GeocoderRequest.php @@ -0,0 +1,180 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Geocoder; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderRequest + * + * @author GeLo + */ +class GeocoderRequest +{ + /** + * @var Coordinate|string + */ + private $address; + + /** + * @var Bound|null + */ + private $bound; + + /** + * @var string|null + */ + private $region; + + /** + * @var string|null + */ + private $language; + + /** + * @param Coordinate|string $address + */ + public function __construct($address) + { + $this->setAddress($address); + } + + /** + * @return Coordinate|string + */ + public function getAddress() + { + return $this->address; + } + + /** + * @param Coordinate|string $address + */ + public function setAddress($address) + { + $this->address = $address; + } + + /** + * @return bool + */ + public function hasBound() + { + return $this->bound !== null; + } + + /** + * @return Bound|null + */ + public function getBound() + { + return $this->bound; + } + + /** + * @param Bound|null $bound + */ + public function setBound(Bound $bound = null) + { + $this->bound = $bound; + } + + /** + * @return bool + */ + public function hasRegion() + { + return $this->region !== null; + } + + /** + * @return string|null + */ + public function getRegion() + { + return $this->region; + } + + /** + * @param string|null $region + */ + public function setRegion($region = null) + { + $this->region = $region; + } + + /** + * @return bool + */ + public function hasLanguage() + { + return $this->language !== null; + } + + /** + * @return string|null + */ + public function getLanguage() + { + return $this->language; + } + + /** + * @param string|null $language + */ + public function setLanguage($language = null) + { + $this->language = $language; + } + + /** + * @return mixed[] + */ + public function buildQuery() + { + $query = []; + + if ($this->address instanceof Coordinate) { + $query['latlng'] = $this->buildPlace($this->address); + } else { + $query['address'] = $this->address; + } + + if ($this->hasBound()) { + $query['bound'] = implode('|', [ + $this->buildPlace($this->bound->getSouthWest()), + $this->buildPlace($this->bound->getNorthEast()), + ]); + } + + if ($this->hasRegion()) { + $query['region'] = $this->region; + } + + if ($this->hasLanguage()) { + $query['language'] = $this->language; + } + + return $query; + } + + /** + * @param Coordinate $place + * + * @return string + */ + private function buildPlace(Coordinate $place) + { + return $place->getLatitude().','.$place->getLongitude(); + } +} diff --git a/src/Service/Geocoder/GeocoderResponse.php b/src/Service/Geocoder/GeocoderResponse.php new file mode 100644 index 00000000..4ecd3c3d --- /dev/null +++ b/src/Service/Geocoder/GeocoderResponse.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Geocoder; + +/** + * @author GeLo + */ +class GeocoderResponse +{ + /** + * @var string|null + */ + private $status; + + /** + * @var GeocoderResult[] + */ + private $results = []; + + /** + * @return bool + */ + public function hasStatus() + { + return $this->status !== null; + } + + /** + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string|null $status + */ + public function setStatus($status = null) + { + $this->status = $status; + } + + /** + * @return bool + */ + public function hasResults() + { + return !empty($this->results); + } + + /** + * @return GeocoderResult[] + */ + public function getResults() + { + return $this->results; + } + + /** + * @param GeocoderResult[] $results + */ + public function setResults(array $results) + { + $this->results = []; + $this->addResults($results); + } + + /** + * @param GeocoderResult[] $results + */ + public function addResults(array $results) + { + foreach ($results as $result) { + $this->addResult($result); + } + } + + /** + * @param GeocoderResult $result + * + * @return bool + */ + public function hasResult(GeocoderResult $result) + { + return in_array($result, $this->results, true); + } + + /** + * @param GeocoderResult $result + */ + public function addResult(GeocoderResult $result) + { + if (!$this->hasResult($result)) { + $this->results[] = $result; + } + } + + /** + * @param GeocoderResult $result + */ + public function removeResult(GeocoderResult $result) + { + unset($this->results[array_search($result, $this->results, true)]); + $this->results = array_values($this->results); + } +} diff --git a/src/Service/Geocoder/GeocoderResult.php b/src/Service/Geocoder/GeocoderResult.php new file mode 100644 index 00000000..f1b001df --- /dev/null +++ b/src/Service/Geocoder/GeocoderResult.php @@ -0,0 +1,263 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Geocoder; + +/** + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderResult + * + * @author GeLo + */ +class GeocoderResult +{ + /** + * @var GeocoderAddressComponent[] + */ + private $addressComponents = []; + + /** + * @var string|null + */ + private $formattedAddress; + + /** + * @var GeocoderGeometry|null + */ + private $geometry; + + /** + * @var bool|null + */ + private $partialMatch; + + /** + * @var string[] + */ + private $types = []; + + /** + * @param string|null $type + * + * @return bool + */ + public function hasAddressComponents($type = null) + { + $addressComponents = $this->getAddressComponents($type); + + return !empty($addressComponents); + } + + /** + * @param string|null $type + * + * @return GeocoderAddressComponent[] + */ + public function getAddressComponents($type = null) + { + if ($type === null) { + return $this->addressComponents; + } + + $addressComponents = []; + + foreach ($this->addressComponents as $addressComponent) { + if (in_array($type, $addressComponent->getTypes(), true)) { + $addressComponents[] = $addressComponent; + } + } + + return $addressComponents; + } + + /** + * @param GeocoderAddressComponent[] $addressComponents + */ + public function setAddressComponents(array $addressComponents) + { + $this->addressComponents = []; + $this->addAddressComponents($addressComponents); + } + + /** + * @param GeocoderAddressComponent[] $addressComponents + */ + public function addAddressComponents(array $addressComponents) + { + foreach ($addressComponents as $addressComponent) { + $this->addAddressComponent($addressComponent); + } + } + + /** + * @param GeocoderAddressComponent $addressComponent + * + * @return bool + */ + public function hasAddressComponent(GeocoderAddressComponent $addressComponent) + { + return in_array($addressComponent, $this->addressComponents, true); + } + + /** + * @param GeocoderAddressComponent $addressComponent + */ + public function addAddressComponent(GeocoderAddressComponent $addressComponent) + { + if (!$this->hasAddressComponent($addressComponent)) { + $this->addressComponents[] = $addressComponent; + } + } + + /** + * @param GeocoderAddressComponent $addressComponent + */ + public function removeAddressComponent(GeocoderAddressComponent $addressComponent) + { + unset($this->addressComponents[array_search($addressComponent, $this->addressComponents, true)]); + $this->addressComponents = array_values($this->addressComponents); + } + + /** + * @return bool + */ + public function hasFormattedAddress() + { + return !empty($this->formattedAddress); + } + + /** + * @return string|null + */ + public function getFormattedAddress() + { + return $this->formattedAddress; + } + + /** + * @param string|null $formattedAddress + */ + public function setFormattedAddress($formattedAddress = null) + { + $this->formattedAddress = $formattedAddress; + } + + /** + * @return bool + */ + public function hasGeometry() + { + return $this->geometry !== null; + } + + /** + * @return GeocoderGeometry|null + */ + public function getGeometry() + { + return $this->geometry; + } + + /** + * @param GeocoderGeometry|null $geometry + */ + public function setGeometry(GeocoderGeometry $geometry = null) + { + $this->geometry = $geometry; + } + + /** + * @return bool + */ + public function hasPartialMatch() + { + return $this->partialMatch !== null; + } + + /** + * @return bool + */ + public function isPartialMatch() + { + return $this->partialMatch; + } + + /** + * @param bool|null $partialMatch + */ + public function setPartialMatch($partialMatch = null) + { + $this->partialMatch = $partialMatch; + } + + /** + * @return bool + */ + public function hasTypes() + { + return !empty($this->types); + } + + /** + * @return string[] + */ + public function getTypes() + { + return $this->types; + } + + /** + * @param string[] $types + */ + public function setTypes(array $types) + { + $this->types = []; + $this->addTypes($types); + } + + /** + * @param string[] $types + */ + public function addTypes(array $types) + { + foreach ($types as $type) { + $this->addType($type); + } + } + + /** + * @param string $type + * + * @return bool + */ + public function hasType($type) + { + return in_array($type, $this->types, true); + } + + /** + * @param string $type + */ + public function addType($type) + { + if (!$this->hasType($type)) { + $this->types[] = $type; + } + } + + /** + * @param string $type + */ + public function removeType($type) + { + unset($this->types[array_search($type, $this->types, true)]); + $this->types = array_values($this->types); + } +} diff --git a/src/Services/Geocoding/Result/GeocoderStatus.php b/src/Service/Geocoder/GeocoderStatus.php similarity index 52% rename from src/Services/Geocoding/Result/GeocoderStatus.php rename to src/Service/Geocoder/GeocoderStatus.php index e3a94e8d..d590de8c 100644 --- a/src/Services/Geocoding/Result/GeocoderStatus.php +++ b/src/Service/Geocoder/GeocoderStatus.php @@ -9,15 +9,14 @@ * file that was distributed with this source code. */ -namespace Ivory\GoogleMap\Services\Geocoding\Result; +namespace Ivory\GoogleMap\Service\Geocoder; /** - * Geocoder status which describes a google map geocoder status. - * * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderStatus + * * @author GeLo */ -class GeocoderStatus +final class GeocoderStatus { const ERROR = 'ERROR'; const INVALID_REQUEST = 'INVALID_REQUEST'; @@ -28,30 +27,9 @@ class GeocoderStatus const ZERO_RESULTS = 'ZERO_RESULTS'; /** - * Disabled constructor. - * * @codeCoverageIgnore */ - final private function __construct() - { - - } - - /** - * Gets the available geocoder status. - * - * @return array The available geocoder status. - */ - public static function getGeocoderStatus() + private function __construct() { - return array( - self::ERROR, - self::INVALID_REQUEST, - self::OK, - self::OVER_QUERY_LIMIT, - self::REQUEST_DENIED, - self::UNKNOWN_ERROR, - self::ZERO_RESULTS, - ); } } diff --git a/src/Service/Utility/XmlParser.php b/src/Service/Utility/XmlParser.php new file mode 100644 index 00000000..cad7c1ef --- /dev/null +++ b/src/Service/Utility/XmlParser.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Service\Utility; + +/** + * @author GeLo + */ +class XmlParser +{ + /** + * @param string $xml + * @param string[] $rules + * + * @return mixed[] + */ + public function parse($xml, array $rules = []) + { + return $this->pluralize(json_decode(json_encode(new \SimpleXMLElement($xml)), true), $rules); + } + + /** + * @param mixed[] $xml + * @param string[] $rules + * + * @return mixed[] + */ + private function pluralize(array $xml, array $rules) + { + foreach ($xml as $attribute => $value) { + if (isset($rules[$attribute])) { + $xml[$rules[$attribute]] = $value; + unset($xml[$attribute]); + + $attribute = $rules[$attribute]; + + if (!is_array($value) || is_string(key($value))) { + $xml[$attribute] = [$value]; + } + } + + if (is_array($xml[$attribute])) { + $xml[$attribute] = $this->pluralize($xml[$attribute], $rules); + } + } + + return $xml; + } +} diff --git a/src/Services/AbstractService.php b/src/Services/AbstractService.php deleted file mode 100644 index b5e056b0..00000000 --- a/src/Services/AbstractService.php +++ /dev/null @@ -1,267 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services; - -use Ivory\GoogleMap\Exception\ServiceException; -use Ivory\GoogleMap\Services\Utils\XmlParser; -use Widop\HttpAdapter\HttpAdapterInterface; - -/** - * Abstract class for accesing google API. - * - * @author GeLo - */ -abstract class AbstractService -{ - /** @var \Widop\HttpAdapter\HttpAdapterInterface */ - protected $httpAdapter; - - /** @var string */ - protected $url; - - /** @var boolean */ - protected $https; - - /** @var string */ - protected $format; - - /** @var \Ivory\GoogleMap\Services\Utils\XmlParser */ - protected $xmlParser; - - /** @var \Ivory\GoogleMap\Services\BusinessAccount */ - protected $businessAccount; - - /** - * Creates a service. - * - * @param \Widop\HttpAdapter\HttpAdapterInterface $httpAdapter The http adapter. - * @param string $url The service url. - * @param boolean $https TRUE if the service uses HTTPS else FALSE. - * @param string $format Format used by the service. - * @param \Ivory\GoogleMap\Services\Utils\XmlParser $xmlParser The xml parser. - * @param \Ivory\GoogleMap\Services\BusinessAccount $businessAccount The business account. - */ - public function __construct( - HttpAdapterInterface $httpAdapter, - $url, - $https = false, - $format = 'json', - XmlParser $xmlParser = null, - BusinessAccount $businessAccount = null - ) { - if ($xmlParser === null) { - $xmlParser = new XmlParser(); - } - - $this->setHttpAdapter($httpAdapter); - $this->setUrl($url); - $this->setHttps($https); - $this->setFormat($format); - $this->setXmlParser($xmlParser); - $this->setBusinessAccount($businessAccount); - } - - /** - * Gets the http adapter. - * - * @return \Widop\HttpAdapter\HttpAdapterInterface The http adapter. - */ - public function getHttpAdapter() - { - return $this->httpAdapter; - } - - /** - * Sets the http adapter. - * - * @param \Widop\HttpAdapter\HttpAdapterInterface $httpAdapter The http adapter. - */ - public function setHttpAdapter(HttpAdapterInterface $httpAdapter) - { - $this->httpAdapter = $httpAdapter; - } - - /** - * Gets the service API url according to the https flag. - * - * @return string The service API url. - */ - public function getUrl() - { - if ($this->isHttps()) { - return str_replace('http://', 'https://', $this->url); - } - - return $this->url; - } - - /** - * Sets the service API url. - * - * @param string $url The service API url. - * - * @throws \Ivory\GoogleMap\Exception\ServiceException If the url is not valid. - */ - public function setUrl($url) - { - if (!is_string($url)) { - throw ServiceException::invalidServiceUrl(); - } - - $this->url = $url; - } - - /** - * Checks if the service uses HTTPS. - * - * @return boolean TRUE if the service uses HTTPS else FALSE. - */ - public function isHttps() - { - return $this->https; - } - - /** - * Sets the service HTTPS flag. - * - * @param boolean $https TRUE if the service uses HTTPS else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\ServiceException If the https flag is not valid. - */ - public function setHttps($https) - { - if (!is_bool($https)) { - throw ServiceException::invalidServiceHttps(); - } - - $this->https = $https; - } - - /** - * Gets the service format. - * - * @return string The service format. - */ - public function getFormat() - { - return $this->format; - } - - /** - * Sets the service format - * - * @param string $format The service format. - * - * @throws \Ivory\GoogleMap\Exception\ServiceException If the format is not valid. - */ - public function setFormat($format) - { - if (!in_array($format, array('json', 'xml'))) { - throw ServiceException::invalidServiceFormat(); - } - - $this->format = $format; - } - - /** - * Gets the xml parser. - * - * @return \Ivory\GoogleMap\Services\Utils\XmlParser The xml parser. - */ - public function getXmlParser() - { - return $this->xmlParser; - } - - /** - * Sets the xml parser. - * - * @param \Ivory\GoogleMap\Services\Geocoding\XmlParser $xmlParser The xml parser. - */ - public function setXmlParser(XmlParser $xmlParser) - { - $this->xmlParser = $xmlParser; - } - - /** - * Checks if the service has a business account. - * - * @return boolean TRUE if the service has a business account else FALSE. - */ - public function hasBusinessAccount() - { - return $this->businessAccount !== null; - } - - /** - * Gets the business account. - * - * @return \Ivory\GoogleMap\Services\BusinessAccount The business account. - */ - public function getBusinessAccount() - { - return $this->businessAccount; - } - - /** - * Sets the business account. - * - * @param \Ivory\GoogleMap\Services\BusinessAccount $businessAccount The business account. - */ - public function setBusinessAccount(BusinessAccount $businessAccount = null) - { - $this->businessAccount = $businessAccount; - } - - /** - * Sign an url for business account. - * - * @param string $url The url. - * - * @return string The signed url. - */ - protected function signUrl($url) - { - if (!$this->hasBusinessAccount()) { - return $url; - } - - return $this->businessAccount->signUrl($url); - } - - /** - * Sends a service request. - * - * @param string $url The service url. - * - * @return \Widop\HttpAdapter\HttpResponse The response. - * - * @throws \Ivory\GoogleMap\Exception\ServiceException If the response is null. - * @throws \Ivory\GoogleMap\Exception\ServiceException If the response has an error 4XX or 5XX. - */ - protected function send($url) - { - $response = $this->httpAdapter->getContent($url); - - if ($response === null) { - throw ServiceException::invalidServiceResult(); - } - - $statusCode = (string) $response->getStatusCode(); - - if ($statusCode[0] === '4' || $statusCode[0] === '5') { - throw ServiceException::invalidResponse($url, $statusCode); - } - - return $response; - } -} diff --git a/src/Services/Base/Distance.php b/src/Services/Base/Distance.php deleted file mode 100644 index e51bc527..00000000 --- a/src/Services/Base/Distance.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Base; - -use Ivory\GoogleMap\Exception\ServiceException; - -/** - * Distance which describes a google map distance. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Distance - * @author GeLo - */ -class Distance -{ - /** @var string */ - protected $text; - - /** @var double */ - protected $value; - - /** - * Creates a distance. - * - * @param string $text The distance as text. - * @param double $value The distance in meters. - */ - public function __construct($text, $value) - { - $this->setText($text); - $this->setValue($value); - } - - /** - * Gets the string representation of the distance value. - * - * @return string The distance as text. - */ - public function getText() - { - return $this->text; - } - - /** - * Sets the string representation of the distance value. - * - * @param string $text The distance as text. - * - * @throws \Ivory\GoogleMap\Exception\ServiceException If the text is not valid. - */ - public function setText($text) - { - if (!is_string($text)) { - throw ServiceException::invalidDistanceText(); - } - - $this->text = $text; - } - - /** - * Gets the distance in meters. - * - * @return double The distance in meters. - */ - public function getValue() - { - return $this->value; - } - - /** - * Sets the distance in meters. - * - * @param double $value The distance in meters. - * - * @throws \Ivory\GoogleMap\Exception\ServiceException If the distance is not valid. - */ - public function setValue($value) - { - if (!is_numeric($value)) { - throw ServiceException::invalidDistanceValue(); - } - - $this->value = $value; - } -} diff --git a/src/Services/Base/Duration.php b/src/Services/Base/Duration.php deleted file mode 100644 index 55f76ec9..00000000 --- a/src/Services/Base/Duration.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Base; - -use Ivory\GoogleMap\Exception\ServiceException; - -/** - * A duration which describes a google map duration. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Duration - * @author GeLo - */ -class Duration -{ - /** @var string */ - protected $text; - - /** @var double */ - protected $value; - - /** - * Creates a duration. - * - * @param string $text The duration as text. - * @param double $value The duration in minutes. - */ - public function __construct($text, $value) - { - $this->setText($text); - $this->setValue($value); - } - - /** - * Gets the string representation of the duration value. - * - * @return string The duration as text. - */ - public function getText() - { - return $this->text; - } - - /** - * Sets the string representation of the duration value - * - * @param string $text The duration as text. - * - * @throws \Ivory\GoogleMap\Exception\ServiceException If the text is not valid. - */ - public function setText($text) - { - if (!is_string($text)) { - throw ServiceException::invalidDurationText(); - } - - $this->text = $text; - } - - /** - * Gets the duration in minutes - * - * @return double The duration in minutes. - */ - public function getValue() - { - return $this->value; - } - - /** - * Sets the duration in minutes - * - * @param double $value The duration in minutes. - * - * @throws \Ivory\GoogleMap\Exception\ServiceException If the value is not valid. - */ - public function setValue($value) - { - if (!is_numeric($value)) { - throw ServiceException::invalidDurationValue(); - } - - $this->value = $value; - } -} diff --git a/src/Services/BusinessAccount.php b/src/Services/BusinessAccount.php deleted file mode 100644 index 11297bcc..00000000 --- a/src/Services/BusinessAccount.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services; - -/** - * Google Map business account. - * - * @author GeLo - */ -class BusinessAccount -{ - /** @var string */ - protected $clientId; - - /** @var string */ - protected $secret; - - /** @var string */ - protected $channel; - - /** - * Creates a business account. - * - * @param string $clientId The client identifier. - * @param string $secret The secret. - * @param string $channel The channel. - */ - public function __construct($clientId, $secret, $channel = null) - { - $this->setClientId($clientId); - $this->setSecret($secret); - $this->setChannel($channel); - } - - /** - * Gets the client identifier. - * - * @return string The client identifier. - */ - public function getClientId() - { - return $this->clientId; - } - - /** - * Sets the client identifier. - * - * @param string $clientId The client identifier. - */ - public function setClientId($clientId) - { - $this->clientId = $clientId; - } - - /** - * Gets the secret. - * - * @return string The secret. - */ - public function getSecret() - { - return $this->secret; - } - - /** - * Sets the secret. - * - * @param string $secret The secret. - */ - public function setSecret($secret) - { - $this->secret = $secret; - } - - /** - * Checks if the business account has a channel. - * - * @return boolean TRUE if the business account has a channel else FALSE. - */ - public function hasChannel() - { - return $this->channel !== null; - } - - /** - * Sets the channel. - * - * @return string The channel. - */ - public function getChannel() - { - return $this->channel; - } - - /** - * Sets the channel. - * - * @param string $channel The channel. - */ - public function setChannel($channel) - { - $this->channel = $channel; - } - - /** - * Sign an url for business purpose. - * - * @param string $url The url. - * - * @return string The signed url. - */ - public function signUrl($url) - { - $url .= sprintf('&client=gme-%s', $this->clientId); - - if ($this->hasChannel()) { - $url .= sprintf('&channel=%s', $this->channel); - } - - $urlParts = parse_url($url); - $data = sprintf('%s?%s', $urlParts['path'], $urlParts['query']); - $key = base64_decode(str_replace(array('-', '_'), array('+', '/'), $this->secret)); - $signature = base64_encode(hash_hmac('sha1', $data, $key, true)); - - $url .= sprintf('&signature=%s', str_replace(array('+', '/'), array('-', '_'), $signature)); - - return $url; - } -} diff --git a/src/Services/Directions/Directions.php b/src/Services/Directions/Directions.php deleted file mode 100644 index 92462007..00000000 --- a/src/Services/Directions/Directions.php +++ /dev/null @@ -1,400 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\DirectionsException; -use Ivory\GoogleMap\Overlays\EncodedPolyline; -use Ivory\GoogleMap\Services\AbstractService; -use Ivory\GoogleMap\Services\Base\Distance; -use Ivory\GoogleMap\Services\Base\Duration; -use Widop\HttpAdapter\HttpAdapterInterface; - -/** - * Directions service. - * - * @author GeLo - */ -class Directions extends AbstractService -{ - /** - * Creates a directions service. - * - * @param \Widop\HttpAdapter\HttpAdapterInterface $httpAdapter The http adapter. - */ - public function __construct(HttpAdapterInterface $httpAdapter) - { - parent::__construct($httpAdapter, 'http://maps.googleapis.com/maps/api/directions'); - } - - /** - * Routes the given request. - * - * Available prototypes: - * - function route(string $origin, string $destination) - * - function route(Ivory\GoogleMap\Services\Directions\DirectionsRequest $request) - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the request is not valid (prototypes). - */ - public function route() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof DirectionsRequest)) { - $directionsRequest = $args[0]; - } elseif ((isset($args[0]) && is_string($args[0])) && (isset($args[1]) && is_string($args[1]))) { - $directionsRequest = new DirectionsRequest(); - - $directionsRequest->setOrigin($args[0]); - $directionsRequest->setDestination($args[1]); - } else { - throw DirectionsException::invalidDirectionsRequestParameters(); - } - - if (!$directionsRequest->isValid()) { - throw DirectionsException::invalidDirectionsRequest(); - } - - $response = $this->send($this->generateUrl($directionsRequest)); - $directionsResponse = $this->buildDirectionsResponse($this->parse($response->getBody())); - - return $directionsResponse; - } - - /** - * Generates directions URL API according to the request. - * - * @param \Ivory\GoogleMap\Services\Directions\DirectionsRequest $directionsRequest The direction request. - * - * @return string The generated URL. - */ - protected function generateUrl(DirectionsRequest $directionsRequest) - { - $httpQuery = array(); - - if (is_string($directionsRequest->getOrigin())) { - $httpQuery['origin'] = $directionsRequest->getOrigin(); - } else { - $httpQuery['origin'] = sprintf( - '%s,%s', - $directionsRequest->getOrigin()->getLatitude(), - $directionsRequest->getOrigin()->getLongitude() - ); - } - - if (is_string($directionsRequest->getDestination())) { - $httpQuery['destination'] = $directionsRequest->getDestination(); - } else { - $httpQuery['destination'] = sprintf( - '%s,%s', - $directionsRequest->getDestination()->getLatitude(), - $directionsRequest->getDestination()->getLongitude() - ); - } - - if ($directionsRequest->hasWaypoints()) { - $waypoints = array(); - - if ($directionsRequest->hasOptimizeWaypoints() && $directionsRequest->getOptimizeWaypoints()) { - $waypoints[] = 'optimize:true'; - } - - foreach ($directionsRequest->getWaypoints() as $waypoint) { - $stopover = $waypoint->getStopover() ? 'via:' : ''; - - if (is_string($waypoint->getLocation())) { - $waypoints[] = $stopover.$waypoint->getLocation(); - } else { - $waypoints[] = sprintf( - '%s%s,%s', - $stopover, - $waypoint->getLocation()->getLatitude(), - $waypoint->getLocation()->getLongitude() - ); - } - } - - $httpQuery['waypoints'] = implode('|', $waypoints); - } - - if ($directionsRequest->hasTravelMode()) { - $httpQuery['mode'] = strtolower($directionsRequest->getTravelMode()); - } - - if ($directionsRequest->hasProvideRouteAlternatives()) { - $httpQuery['alternatives'] = $directionsRequest->getProvideRouteAlternatives() ? 'true' : 'false'; - } - - if ($directionsRequest->hasAvoidTolls() && $directionsRequest->getAvoidTolls()) { - $httpQuery['avoid'] = 'tolls'; - } elseif ($directionsRequest->hasAvoidHighways() && $directionsRequest->getAvoidHighways()) { - $httpQuery['avoid'] = 'highways'; - } - - if ($directionsRequest->hasUnitSystem()) { - $httpQuery['units'] = strtolower($directionsRequest->getUnitSystem()); - } - - if ($directionsRequest->hasRegion()) { - $httpQuery['region'] = $directionsRequest->getRegion(); - } - - if ($directionsRequest->hasLanguage()) { - $httpQuery['language'] = $directionsRequest->getLanguage(); - } - - if ($directionsRequest->hasDepartureTime()) { - $httpQuery['departure_time'] = $directionsRequest->getDepartureTime()->getTimestamp(); - } - - if ($directionsRequest->hasArrivalTime()) { - $httpQuery['arrival_time'] = $directionsRequest->getArrivalTime()->getTimestamp(); - } - - $httpQuery['sensor'] = $directionsRequest->hasSensor() ? 'true' : 'false'; - - $url = sprintf('%s/%s?%s', $this->getUrl(), $this->getFormat(), http_build_query($httpQuery)); - - return $this->signUrl($url); - } - - /** - * Parses & normalizes the directions API result response. - * - * @param string $response The directions API response. - * - * @return \stdClass The parsed & normalized directions response. - */ - protected function parse($response) - { - if ($this->format === 'json') { - return $this->parseJSON($response); - } - - return $this->parseXML($response); - } - - /** - * Parses & normalizes a JSON directions API result response. - * - * @param string $response The directions API JSON response. - * - * @return \stdClass The parsed & normalized directions response. - */ - protected function parseJSON($response) - { - return json_decode($response); - } - - /** - * Parses & normalizes an XML directions API result response. - * - * @param string $response The directions API XML response. - * - * @return \stdClass The parsed & normalized directions response. - */ - protected function parseXML($response) - { - $rules = array( - 'leg' => 'legs', - 'route' => 'routes', - 'step' => 'steps', - ); - - return $this->xmlParser->parse($response, $rules); - } - - /** - * Builds the directions response according to the normalized directions API results. - * - * @param \stdClass $directionsResponse The normalied directions response. - * - * @return \Ivory\GoogleMap\Services\Directions\DirectionsResponse The builded directions response. - */ - protected function buildDirectionsResponse(\stdClass $directionsResponse) - { - $routes = $this->buildDirectionsRoutes($directionsResponse->routes); - $status = $directionsResponse->status; - - return new DirectionsResponse($routes, $status); - } - - /** - * Builds the directions routes according to the normalized directions API routes. - * - * @param \stdClass $directionsRoutes The normalized directions routes. - * - * @return array The builded directions routes. - */ - protected function buildDirectionsRoutes(array $directionsRoutes) - { - $results = array(); - foreach ($directionsRoutes as $directionsRoute) { - $results[] = $this->buildDirectionsRoute($directionsRoute); - } - - return $results; - } - - /** - * Builds the directions route according to the normalized directions API route. - * - * @param \stdClass $directionsRoute The normalized directions route. - * - * @return \Ivory\GoogleMap\Services\Directions\DirectionsRoute The builded directions route. - */ - protected function buildDirectionsRoute(\stdClass $directionsRoute) - { - $bound = new Bound( - new Coordinate($directionsRoute->bounds->southwest->lat, $directionsRoute->bounds->southwest->lng), - new Coordinate($directionsRoute->bounds->northeast->lat, $directionsRoute->bounds->northeast->lng) - ); - - // @see https://github.com/egeloen/IvoryGoogleMapBundle/issues/72 - // @codeCoverageIgnoreStart - if (!isset($directionsRoute->copyrights)) { - $directionsRoute->copyrights = ''; - } - - if (!isset($directionsRoute->summary)) { - $directionsRoute->summary = ''; - } - // @codeCoverageIgnoreEnd - - $summary = $directionsRoute->summary; - $copyrights = $directionsRoute->copyrights; - - $directionsLegs = $this->buildDirectionsLegs($directionsRoute->legs); - $overviewPolyline = new EncodedPolyline($directionsRoute->overview_polyline->points); - - // The warnings & waypoint_order properties can not be defined in the xml format. - if (!isset($directionsRoute->warnings)) { - $directionsRoute->warnings = array(); - } - - if (!isset($directionsRoute->waypoint_order)) { - $directionsRoute->waypoint_order = array(); - } - - $warnings = $directionsRoute->warnings; - $waypointOrder = $directionsRoute->waypoint_order; - - return new DirectionsRoute( - $bound, - $copyrights, - $directionsLegs, - $overviewPolyline, - $summary, - $warnings, - $waypointOrder - ); - } - - /** - * Builds the directions legs according to the normalized directions API legs. - * - * @param array $directionsLegs The normalized directions legs. - * - * @return array The builded directions legs. - */ - protected function buildDirectionsLegs(array $directionsLegs) - { - $results = array(); - foreach ($directionsLegs as $directionsLeg) { - $results[] = $this->buildDirectionsLeg($directionsLeg); - } - - return $results; - } - - /** - * Buildd the directions leg according to the normalized directions API leg. - * - * @param \stdClass $directionsLeg The normalized directions leg. - * - * @return \Ivory\GoogleMap\Services\Directions\DirectionsLeg The builded directions leg. - */ - protected function buildDirectionsLeg(\stdClass $directionsLeg) - { - $distance = new Distance($directionsLeg->distance->text, $directionsLeg->distance->value); - $duration = new Duration($directionsLeg->duration->text, $directionsLeg->duration->value); - $endAddress = $directionsLeg->end_address; - $endLocation = new Coordinate($directionsLeg->end_location->lat, $directionsLeg->end_location->lng); - $startAddress = $directionsLeg->start_address; - $startLocation = new Coordinate($directionsLeg->start_location->lat, $directionsLeg->start_location->lng); - $steps = $this->buildDirectionsSteps($directionsLeg->steps); - - // The via_waypoint property can not be defined in the xml format. - if (!isset($directionsLeg->via_waypoint)) { - $directionsLeg->via_waypoint = array(); - } - - $viaWaypoint = $directionsLeg->via_waypoint; - - return new DirectionsLeg( - $distance, - $duration, - $endAddress, - $endLocation, - $startAddress, - $startLocation, - $steps, - $viaWaypoint - ); - } - - /** - * Builds the directions steps according to the normalized directions API steps. - * - * @param array $directionsSteps The normalized directions steps. - * - * @return array The builded directions steps. - */ - protected function buildDirectionsSteps(array $directionsSteps) - { - $results = array(); - foreach ($directionsSteps as $directionsStep) { - $results[] = $this->buildDirectionsStep($directionsStep); - } - - return $results; - } - - /** - * Builds the directions step according to the normalized directions API step. - * - * @param \stdClass $directionsStep The normalized directions step. - * - * @return \Ivory\GoogleMap\Services\Directions\DirectionsStep The builded directions step. - */ - protected function buildDirectionsStep(\stdClass $directionsStep) - { - $distance = new Distance($directionsStep->distance->text, $directionsStep->distance->value); - $duration = new Duration($directionsStep->duration->text, $directionsStep->duration->value); - $endLocation = new Coordinate($directionsStep->end_location->lat, $directionsStep->end_location->lng); - $instructions = $directionsStep->html_instructions; - $encodedPolyline = new EncodedPolyline($directionsStep->polyline->points); - $startLocation = new Coordinate($directionsStep->start_location->lat, $directionsStep->start_location->lng); - $travelMode = $directionsStep->travel_mode; - - return new DirectionsStep( - $distance, - $duration, - $endLocation, - $instructions, - $encodedPolyline, - $startLocation, - $travelMode - ); - } -} diff --git a/src/Services/Directions/DirectionsLeg.php b/src/Services/Directions/DirectionsLeg.php deleted file mode 100644 index 5f76777d..00000000 --- a/src/Services/Directions/DirectionsLeg.php +++ /dev/null @@ -1,268 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\DirectionsException; -use Ivory\GoogleMap\Services\Base\Distance; -use Ivory\GoogleMap\Services\Base\Duration; - -/** - * A directions leg which describes a google map directions leg. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsLeg - * @author GeLo - */ -class DirectionsLeg -{ - /** @var \Ivory\GoogleMap\Services\Base\Distance */ - protected $distance; - - /** @var \Ivory\GoogleMap\Services\Base\Duration */ - protected $duration; - - /** @var string */ - protected $endAddress; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $endLocation; - - /** @var string */ - protected $startAddress; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $startLocation; - - /** @var array */ - protected $steps; - - /** @var array */ - protected $viaWaypoints; - - /** - * Creates a directions leg. - * - * @param \Ivory\GoogleMap\Services\Base\Distance $distance The distance. - * @param \Ivory\GoogleMap\Services\Base\Duration $duration The duration. - * @param string $endAddress The end address. - * @param \Ivory\GoogleMap\Base\Coordinate $endLocation The end location. - * @param string $startAddress The start address. - * @param \Ivory\GoogleMap\Base\Coordinate $startLocation The start location. - * @param array $steps The steps. - * @param array $viaWaypoint The via waypoint. - */ - public function __construct( - Distance $distance, - Duration $duration, - $endAddress, - Coordinate $endLocation, - $startAddress, - Coordinate $startLocation, - array $steps, - array $viaWaypoint - ) { - $this->setDistance($distance); - $this->setDuration($duration); - $this->setEndAddress($endAddress); - $this->setEndLocation($endLocation); - $this->setStartAddress($startAddress); - $this->setStartLocation($startLocation); - $this->setSteps($steps); - $this->setViaWaypoints($viaWaypoint); - } - - /** - * Gets the leg distance. - * - * @return \Ivory\GoogleMap\Services\Base\Distance The leg distance. - */ - public function getDistance() - { - return $this->distance; - } - - /** - * Sets the leg distance. - * - * @param \Ivory\GoogleMap\Services\Base\Distance $distance The leg distance. - */ - public function setDistance(Distance $distance) - { - $this->distance = $distance; - } - - /** - * Gets the leg duration. - * - * @return \Ivory\GoogleMap\Services\Base\Duration The leg duration. - */ - public function getDuration() - { - return $this->duration; - } - - /** - * Sets the leg duration - * - * @param \Ivory\GoogleMap\Services\Base\Duration $duration The leg duration. - */ - public function setDuration(Duration $duration) - { - $this->duration = $duration; - } - - /** - * Gets the leg end address. - * - * @return string The leg end address. - */ - public function getEndAddress() - { - return $this->endAddress; - } - - /** - * Sets the leg end address. - * - * @param string The leg end address. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the and address is not valid. - */ - public function setEndAddress($endAddress) - { - if (!is_string($endAddress)) { - throw DirectionsException::invalidDirectionsLegEndAddress(); - } - - $this->endAddress = $endAddress; - } - - /** - * Gets the leg end location. - * - * @return \Ivory\GoogleMap\Base\Coordinate The leg end location. - */ - public function getEndLocation() - { - return $this->endLocation; - } - - /** - * Sets the leg end location. - * - * @param \Ivory\GoogleMap\Base\Coordinate $endLocation The leg end location. - */ - public function setEndLocation(Coordinate $endLocation) - { - $this->endLocation = $endLocation; - } - - /** - * Gets the leg start address. - * - * @return string The leg start address. - */ - public function getStartAddress() - { - return $this->startAddress; - } - - /** - * Sets the leg start address. - * - * @param string $startAddress The leg start address. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the start address is not valid. - */ - public function setStartAddress($startAddress) - { - if (!is_string($startAddress)) { - throw DirectionsException::invalidDirectionsLegStartAddress(); - } - - $this->startAddress = $startAddress; - } - - /** - * Gets the leg start location. - * - * @return \Ivory\GoogleMap\Base\Coordinate The leg start location. - */ - public function getStartLocation() - { - return $this->startLocation; - } - - /** - * Sets the leg start location. - * - * @param \Ivory\GoogleMap\Base\Coordinate $startLocation The leg start location. - */ - public function setStartLocation(Coordinate $startLocation) - { - $this->startLocation = $startLocation; - } - - /** - * Gets the leg steps. - * - * @return array The leg steps. - */ - public function getSteps() - { - return $this->steps; - } - - /** - * Sets the leg steps. - * - * @param array $steps The leg steps. - */ - public function setSteps(array $steps) - { - $this->steps = array(); - - foreach ($steps as $step) { - $this->addStep($step); - } - } - - /** - * Add a step to the leg. - * - * @param \Ivory\GoogleMap\Services\Directions\DirectionsStep The step to add. - */ - public function addStep(DirectionsStep $step) - { - $this->steps[] = $step; - } - - /** - * Gets the via waypoint. - * - * @return array The via waypoint. - */ - public function getViaWaypoints() - { - return $this->viaWaypoints; - } - - /** - * Sets the via waypoint. - * - * @param array $viaWaypoints The via waypoint. - */ - public function setViaWaypoints(array $viaWaypoints) - { - $this->viaWaypoints = $viaWaypoints; - } -} diff --git a/src/Services/Directions/DirectionsRequest.php b/src/Services/Directions/DirectionsRequest.php deleted file mode 100644 index 495dbee6..00000000 --- a/src/Services/Directions/DirectionsRequest.php +++ /dev/null @@ -1,650 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Directions; - -use \DateTime; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\DirectionsException; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; - -/** - * Directions request represents a google map directions request. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsRequest - * @author GeLo - */ -class DirectionsRequest -{ - /** @var boolean */ - protected $avoidHighways; - - /** @var boolean */ - protected $avoidTolls; - - /** @var string | \Ivory\GoogleMap\Base\Coordinate */ - protected $destination; - - /** @var boolean */ - protected $optimizeWaypoints; - - /** @var string | \Ivory\GoogleMap\Base\Coordinate */ - protected $origin; - - /** @var \DateTime */ - protected $departureTime; - - /** @var \DateTime */ - protected $arrivalTime; - - /** @var boolean */ - protected $provideRouteAlternatives; - - /** @var string */ - protected $region; - - /** @var string */ - protected $language; - - /** @var string */ - protected $travelMode; - - /** @var string */ - protected $unitSystem; - - /** @var array */ - protected $waypoints; - - /** @var boolean */ - protected $sensor; - - /** - * Creates a directions request. - */ - public function __construct() - { - $this->waypoints = array(); - $this->sensor = false; - } - - /** - * Checks if the directions request has an avoid hightways flag. - * - * @return boolean TRUE if the directions request has an avoid hightways flag else FALSE. - */ - public function hasAvoidHighways() - { - return $this->avoidHighways !== null; - } - - /** - * Checks if the directions request avoid hightways. - * - * @return boolean TRUE if the directions request avoids hightways else FALSE. - */ - public function getAvoidHighways() - { - return $this->avoidHighways; - } - - /** - * Sets if the the directions request avoids hightways. - * - * @param boolean $avoidHighways TRUE if the directions request avoids hightways else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the avoid highways flag is not valid. - */ - public function setAvoidHighways($avoidHighways = null) - { - if (!is_bool($avoidHighways) && ($avoidHighways !== null)) { - throw DirectionsException::invalidDirectionsRequestAvoidHighways(); - } - - $this->avoidHighways = $avoidHighways; - } - - /** - * Checks if the directions request has an avoid tolls flag. - * - * @return boolean TRUE if the directions request has an avoid tolls flag else FALSE. - */ - public function hasAvoidTolls() - { - return $this->avoidTolls !== null; - } - - /** - * Checks if the directions request avoid tolls. - * - * @return boolean TRUE if the directions request avoids tolls else FALSE. - */ - public function getAvoidTolls() - { - return $this->avoidTolls; - } - - /** - * Sets if the the directions request avoids tolls. - * - * @param boolean $avoidTolls TRUE if the directions request avoids tolls else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the avoid tolls flag is not valid. - */ - public function setAvoidTolls($avoidTolls = null) - { - if (!is_bool($avoidTolls) && ($avoidTolls !== null)) { - throw DirectionsException::invalidDirectionsRequestAvoidTolls(); - } - - $this->avoidTolls = $avoidTolls; - } - - /** - * Checks if the directions request has a destination. - * - * @return boolean TRUE if the directions request has a destination else FALSE. - */ - public function hasDestination() - { - return $this->destination !== null; - } - - /** - * Gets the directions request destination. - * - * @return string | \Ivory\GoogleMap\Base\Coordinate The directions request destination. - */ - public function getDestination() - { - return $this->destination; - } - - /** - * Sets the directions request destination. - * - * Available prototypes: - * - function setDestination(string $destination) - * - function setDestination(Ivory\GoogleMap\Base\Coordinate $destination) - * - function setDestination(double $latitude, double $longitude, boolean $noWrap) - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the destination is not valid (prototypes). - */ - public function setDestination() - { - $args = func_get_args(); - - if (isset($args[0]) && is_string($args[0])) { - $this->destination = $args[0]; - } elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->destination = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->destination === null) { - $this->destination = new Coordinate(); - } - - $this->destination->setLatitude($args[0]); - $this->destination->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->destination->setNoWrap($args[2]); - } - } else { - throw DirectionsException::invalidDirectionsRequestDestination(); - } - } - - /** - * Checks if the directions request has the optimize waypoints flag. - * - * @return boolean TRUE if the directions request has the optimize waypoints flag else FALSE. - */ - public function hasOptimizeWaypoints() - { - return $this->optimizeWaypoints !== null; - } - - /** - * Checks if the directions request optimizes waypoints. - * - * @return boolean TRUE if the directions request optmizes waypoints else FALSE. - */ - public function getOptimizeWaypoints() - { - return $this->optimizeWaypoints; - } - - /** - * Sets if the directions request optimizes waypoints. - * - * @param boolean $optimizeWaypoints TRUE if the directions request optimizes waypoints else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the optimize waypoints flag is not valid. - */ - public function setOptimizeWaypoints($optimizeWaypoints = null) - { - if (!is_bool($optimizeWaypoints) && ($optimizeWaypoints !== null)) { - throw DirectionsException::invalidDirectionsRequestOptimizeWaypoints(); - } - - $this->optimizeWaypoints = $optimizeWaypoints; - } - - /** - * Checks if the directions request has an origin. - * - * @return boolean TRUE if the directions request has an origin else FALSE. - */ - public function hasOrigin() - { - return $this->origin !== null; - } - - /** - * Gets the directions request origin. - * - * @return string | \Ivory\GoogleMap\Base\Coordinate The directions request origin. - */ - public function getOrigin() - { - return $this->origin; - } - - /** - * Sets the directions request origin. - * - * Available prototypes: - * - function setOrigin(string $destination) - * - function setOrigin(Ivory\GoogleMap\Base\Coordinate $destination) - * - function setOrigin(double $latitude, double $longitude, boolean $noWrap) - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the origin is not valid (prototypes). - */ - public function setOrigin() - { - $args = func_get_args(); - - if (isset($args[0]) && is_string($args[0])) { - $this->origin = $args[0]; - } elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->origin = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->origin === null) { - $this->origin = new Coordinate(); - } - - $this->origin->setLatitude($args[0]); - $this->origin->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->origin->setNoWrap($args[2]); - } - } else { - throw DirectionsException::invalidDirectionsRequestOrigin(); - } - } - - /** - * Checks if the directions request has a departure time. - * - * @return boolean TRUE if the directions request has a departure time else FALSE. - */ - public function hasDepartureTime() - { - return $this->departureTime !== null; - } - - /** - * Gets the directions request departure time. - * - * @return \DateTime The directions request departure time. - */ - public function getDepartureTime() - { - return $this->departureTime; - } - - /** - * Sets the directions departure time - * - * @param \DateTime $departureTime The directions departure time. - */ - public function setDepartureTime(DateTime $departureTime = null) - { - $this->departureTime = $departureTime; - } - - /** - * Checks if the directions request has an arrival time. - * - * @return boolean TRUE if the directions request has an arrival time else FALSE. - */ - public function hasArrivalTime() - { - return $this->arrivalTime !== null; - } - - /** - * Gets the directions request arrival time. - * - * @return \DateTime The directions request arrival time. - */ - public function getArrivalTime() - { - return $this->arrivalTime; - } - - /** - * Sets the directions arrival time - * - * @param \DateTime $arrivalTime The directions arrival time. - */ - public function setArrivalTime(DateTime $arrivalTime = null) - { - $this->arrivalTime = $arrivalTime; - } - - /** - * Checks if the directions request has a provide route alternatives flag. - * - * @return boolean TRUE if the directions request has a provide route alternative flag else FALSE. - */ - public function hasProvideRouteAlternatives() - { - return $this->provideRouteAlternatives !== null; - } - - /** - * Checks if the directions request provides route alternatives. - * - * @return boolean TRUE if the directions request provides route alternatives else FALSE. - */ - public function getProvideRouteAlternatives() - { - return $this->provideRouteAlternatives; - } - - /** - * Sets if the directions request provides route alternatives. - * - * @param boolean $provideRouteAlternatives TRUE if the directions request provides route alternatives else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the provide route alternatives flag is not valid. - */ - public function setProvideRouteAlternatives($provideRouteAlternatives = null) - { - if (!is_bool($provideRouteAlternatives) && ($provideRouteAlternatives !== null)) { - throw DirectionsException::invalidDirectionsRequestProvideRouteAlternatives(); - } - - $this->provideRouteAlternatives = $provideRouteAlternatives; - } - - /** - * Checks if the directions request has a region. - * - * @return boolean TRUE if the directions request has a region else FALSE. - */ - public function hasRegion() - { - return $this->region !== null; - } - - /** - * Gets the directions request region. - * - * @return string The direction request region. - */ - public function getRegion() - { - return $this->region; - } - - /** - * Sets the directions request region. - * - * @param string $region The directions request region. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the region is not valid. - */ - public function setRegion($region = null) - { - if ((!is_string($region) || (strlen($region) !== 2)) && ($region !== null)) { - throw DirectionsException::invalidDirectionsRequestRegion(); - } - - $this->region = $region; - } - - /** - * Checks if the directions request has a language. - * - * @return boolean TRUE if the directions request has a language else FALSE. - */ - public function hasLanguage() - { - return $this->language !== null; - } - - /** - * Gets the directions request language. - * - * @return string The direction request language. - */ - public function getLanguage() - { - return $this->language; - } - - /** - * Sets the directions request language. - * - * @param string $language The directions request language. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the language is not valid. - */ - public function setLanguage($language = null) - { - if ((!is_string($language) || ((strlen($language) !== 2) && (strlen($language) !== 5))) && ($language !== null)) { - throw DirectionsException::invalidDirectionsRequestLanguage(); - } - - $this->language = $language; - } - - /** - * Checks if the directions request has a travel mode. - * - * @return boolean TRUE if the directions request has a travel mode else FALSE. - */ - public function hasTravelMode() - { - return $this->travelMode !== null; - } - - /** - * Gets the directions request travel mode. - * - * @return string The directions request travel mode. - */ - public function getTravelMode() - { - return $this->travelMode; - } - - /** - * Sets the directions request travel mode. - * - * @param string $travelMode The directions request travel mode. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the travel mode is not valid. - */ - public function setTravelMode($travelMode = null) - { - if (!in_array($travelMode, TravelMode::getTravelModes()) && ($travelMode !== null)) { - throw DirectionsException::invalidDirectionsRequestTravelMode(); - } - - $this->travelMode = $travelMode; - } - - /** - * Checks if the directions request has a unit system. - * - * @return boolean TRUE if the directions request has a unit system else FALSE. - */ - public function hasUnitSystem() - { - return $this->unitSystem !== null; - } - - /** - * Gets the directions request unit system. - * - * @return string The directions request unit system. - */ - public function getUnitSystem() - { - return $this->unitSystem; - } - - /** - * Sets the directions request unit system. - * - * @param string $unitSystem The directions request unit system. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the unit system is not valid. - */ - public function setUnitSystem($unitSystem = null) - { - if (!in_array($unitSystem, UnitSystem::getUnitSystems()) && ($unitSystem !== null)) { - throw DirectionsException::invalidDirectionsRequestUnitSystem(); - } - - $this->unitSystem = $unitSystem; - } - - /** - * Checks if the directions request has waypoints. - * - * @return boolean TRUE if the directions request has waypoints else FALSE. - */ - public function hasWaypoints() - { - return !empty($this->waypoints); - } - - /** - * Gets the directions request waypoints. - * - * @return array The directions request waypoints. - */ - public function getWaypoints() - { - return $this->waypoints; - } - - /** - * Sets the directions request waypoints. - * - * @param array $waypoints The directions request waypoints. - */ - public function setWaypoints(array $waypoints = array()) - { - $this->waypoints = array(); - - foreach ($waypoints as $waypoint) { - $this->addWaypoint($waypoint); - } - } - - /** - * Adds a waypoint to the directions request. - * - * Available prototypes: - * - function addWaypoint(Ivory\GoogleMap\Services\Directions\DirectionsWaypoint $waypoint) - * - function addWaypoint(string $location) - * - function addWaypoint(double $latitude, double $longitude, boolean $noWrap) - * - function addWaypoint(Ivory\GoogleMap\Base\Coordinate $location) - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the waypoint is not valid (prototypes). - */ - public function addWaypoint() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof DirectionsWaypoint)) { - $this->waypoints[] = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - $waypoint = new DirectionsWaypoint(); - $waypoint->setLocation($args[0], $args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $waypoint->getLocation()->setNoWrap($args[2]); - } - - $this->waypoints[] = $waypoint; - } elseif (isset($args[0]) && (is_string($args[0]) || ($args[0] instanceof Coordinate))) { - $waypoint = new DirectionsWaypoint(); - $waypoint->setLocation($args[0]); - - $this->waypoints[] = $waypoint; - } else { - throw DirectionsException::invalidDirectionsRequestWaypoint(); - } - } - - /** - * Checks if the directions request has a sensor. - * - * @return boolean TRUE if the directions request has a sensor else FALSE. - */ - public function hasSensor() - { - return $this->sensor; - } - - /** - * Sets the directions request sensor. - * - * @param boolean $sensor TRUE if the directions request has a sensor else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the sensor flag is not valid. - */ - public function setSensor($sensor) - { - if (!is_bool($sensor)) { - throw DirectionsException::invalidDirectionsRequestSensor(); - } - - $this->sensor = $sensor; - } - - /** - * Checks if the directions request is valid. - * - * @return boolean TRUE if the directions request is valid else FALSE. - */ - public function isValid() - { - $isValid = $this->hasDestination() && $this->hasOrigin(); - - for ($i = 0; $isValid && ($i < count($this->waypoints)); $i++) { - $isValid = $this->waypoints[$i]->isValid(); - } - - if ($this->getTravelMode() === TravelMode::TRANSIT) { - $isValid = $this->hasArrivalTime() || $this->hasDepartureTime(); - } - - return $isValid; - } -} diff --git a/src/Services/Directions/DirectionsResponse.php b/src/Services/Directions/DirectionsResponse.php deleted file mode 100644 index 24f9677b..00000000 --- a/src/Services/Directions/DirectionsResponse.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Exception\DirectionsException; - -/** - * A directions response wraps the directions results (routes) & the response status. - * - * @author GeLo - */ -class DirectionsResponse -{ - /** @var array */ - protected $routes; - - /** @var string */ - protected $status; - - /** - * Create a directions response. - * - * @param array $routes The response routes. - * @param string $status The response status. - */ - public function __construct(array $routes, $status) - { - $this->setRoutes($routes); - $this->setStatus($status); - } - - /** - * Gets the directions routes. - * - * @return array The directions routes. - */ - public function getRoutes() - { - return $this->routes; - } - - /** - * Sets the directions routes. - * - * @param array $routes The directions routes. - */ - public function setRoutes(array $routes) - { - $this->routes = array(); - - foreach ($routes as $route) { - $this->addRoute($route); - } - } - - /** - * Add a directions route. - * - * @param Ivory\GoogleMapBundle\Model\Services\Directions\DirectionsRoute $route The route to add. - */ - public function addRoute(DirectionsRoute $route) - { - $this->routes[] = $route; - } - - /** - * Gets the directions response status. - * - * @return string The directions response status. - */ - public function getStatus() - { - return $this->status; - } - - /** - * Sets the directions response status. - * - * @param string $status The directions response status. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the status is not valid. - */ - public function setStatus($status) - { - if (!in_array($status, DirectionsStatus::getDirectionsStatus())) { - throw DirectionsException::invalidDirectionsResponseStatus(); - } - - $this->status = $status; - } -} diff --git a/src/Services/Directions/DirectionsRoute.php b/src/Services/Directions/DirectionsRoute.php deleted file mode 100644 index c66d9d87..00000000 --- a/src/Services/Directions/DirectionsRoute.php +++ /dev/null @@ -1,281 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Exception\DirectionsException; -use Ivory\GoogleMap\Overlays\EncodedPolyline; - -/** - * A directions route which describes a google map route. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsRoute - * @author GeLo - */ -class DirectionsRoute -{ - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** @var string */ - protected $copyrights; - - /** @var array */ - protected $legs; - - /** @var \Ivory\GoogleMap\Overlays\EncodedPolyline */ - protected $overviewPolyline; - - /** @var string */ - protected $summary; - - /** @var array */ - protected $warnings; - - /** @var array */ - protected $waypointOrder; - - /** - * Creates a directions route. - * - * @param \Ivory\GoogleMap\Base\Bound $bound The bound. - * @param string $copyrights The copyrights. - * @param array $legs The legs. - * @param \Ivory\GoogleMap\Overlays\EncodedPolyline $overviewPolyline The encoded polyline. - * @param string $summary The summary. - * @param array $warnings The warnings. - * @param array $waypointOrder The waypoint order. - */ - public function __construct( - Bound $bound, - $copyrights, - array $legs, - EncodedPolyline $overviewPolyline, - $summary, - array $warnings, - array $waypointOrder - ) { - $this->setBound($bound); - $this->setCopyrights($copyrights); - $this->setLegs($legs); - $this->setOverviewPolyline($overviewPolyline); - $this->setSummary($summary); - $this->setWarnings($warnings); - $this->setWaypointOrder($waypointOrder); - } - - /** - * Gets the route bound. - * - * @return \Ivory\GoogleMap\Base\Bound The route bound. - */ - public function getBound() - { - return $this->bound; - } - - /** - * Sets the route bound. - * - * @param \Ivory\GoogleMap\Base\Bound $bound The route bound. - */ - public function setBound(Bound $bound) - { - $this->bound = $bound; - } - - /** - * Gets the route copyrights. - * - * @return string The route copyrights. - */ - public function getCopyrights() - { - return $this->copyrights; - } - - /** - * Sets the route copyrights. - * - * @param string $copyrights The route copyrights. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the copyrights is not valid. - */ - public function setCopyrights($copyrights) - { - if (!is_string($copyrights)) { - throw DirectionsException::invalidDirectionsRouteCopyrights(); - } - - $this->copyrights = $copyrights; - } - - /** - * Gets the route legs - * - * @return array The route legs. - */ - public function getLegs() - { - return $this->legs; - } - - /** - * Sets the route legs - * - * @param array $legs The route legs. - */ - public function setLegs(array $legs) - { - $this->legs = array(); - - foreach ($legs as $leg) { - $this->addLeg($leg); - } - } - - /** - * Adds a leg to the route. - * - * @param \Ivory\GoogleMap\Services\Directions\DirectionsLeg The leg to add. - */ - public function addLeg(DirectionsLeg $leg) - { - $this->legs[] = $leg; - } - - /** - * Gets the route overview polyline. - * - * @return \Ivory\GoogleMap\Overlays\EncodedPolyline The route overview polyline. - */ - public function getOverviewPolyline() - { - return $this->overviewPolyline; - } - - /** - * Sets the route overview polyline. - * - * @param \Ivory\GoogleMap\Overlays\EncodedPolyline $overviewPolyline The route overview polyline. - */ - public function setOverviewPolyline(EncodedPolyline $overviewPolyline) - { - $this->overviewPolyline = $overviewPolyline; - } - - /** - * Gets the route summary. - * - * @return string The route summary. - */ - public function getSummary() - { - return $this->summary; - } - - /** - * Sets the route summary. - * - * @param string $summary The route summary. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the summary is not valid. - */ - public function setSummary($summary) - { - if (!is_string($summary)) { - throw DirectionsException::invalidDirectionsRouteSummary(); - } - - $this->summary = $summary; - } - - /** - * Gets the route warnings. - * - * @return array The route warnings. - */ - public function getWarnings() - { - return $this->warnings; - } - - /** - * Sets the route warnings. - * - * @param array $warnings The route warnings. - */ - public function setWarnings(array $warnings) - { - $this->warnings = array(); - - foreach ($warnings as $warning) { - $this->addWarning($warning); - } - } - - /** - * Adds a warning to the route. - * - * @param string $warning The warning to add. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the warning is not valid. - */ - public function addWarning($warning) - { - if (!is_string($warning)) { - throw DirectionsException::invalidDirectionsRouteWarning(); - } - - $this->warnings[] = $warning; - } - - /** - * Gets the route waypoint order. - * - * @return array The route waypoint order. - */ - public function getWaypointOrder() - { - return $this->waypointOrder; - } - - /** - * Sets the routes waypoint order. - * - * @param array $waypointOrder The route waypoint order. - */ - public function setWaypointOrder(array $waypointOrder) - { - $this->waypointOrder = array(); - - foreach ($waypointOrder as $waypointOrder) { - $this->addWaypointOrder($waypointOrder); - } - } - - /** - * Adds a waypoint order to the route. - * - * @param integer $waypointOrder The waypoint to add. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the waypoint order is not valid. - */ - public function addWaypointOrder($waypointOrder) - { - if (!is_int($waypointOrder)) { - throw DirectionsException::invalidDirectionsRouteWaypointOrder(); - } - - $this->waypointOrder[] = $waypointOrder; - } -} diff --git a/src/Services/Directions/DirectionsStep.php b/src/Services/Directions/DirectionsStep.php deleted file mode 100644 index 7f333da4..00000000 --- a/src/Services/Directions/DirectionsStep.php +++ /dev/null @@ -1,230 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\DirectionsException; -use Ivory\GoogleMap\Overlays\EncodedPolyline; -use Ivory\GoogleMap\Services\Base\Distance; -use Ivory\GoogleMap\Services\Base\Duration; -use Ivory\GoogleMap\Services\Base\TravelMode; - -/** - * A directions step which describes a google map directions step. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsStep - * @author GeLo - */ -class DirectionsStep -{ - /** @var \Ivory\GoogleMap\Services\Base\Distance */ - protected $distance; - - /** @var \Ivory\GoogleMap\Services\Base\Duration */ - protected $duration; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $endLocation; - - /** @var string */ - protected $instructions; - - /** @var \Ivory\GoogleMap\Overlays\EncodedPolyline */ - protected $encodedPolyline; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $startLocation; - - /** @var string */ - protected $travelMode; - - /** - * Creates a directions step. - * - * @param \Ivory\GoogleMap\Services\Base\Distance $distance The distance. - * @param \Ivory\GoogleMap\Services\Base\Duration $duration The duration. - * @param \Ivory\GoogleMap\Base\Coordinate $endLocation The end location. - * @param string $instructions The instructions. - * @param \Ivory\GoogleMap\Overlays\EncodedPolyline $encodedPolyline The encoded polyline. - * @param \Ivory\GoogleMap\Base\Coordinate $startLocation The start location. - * @param string $travelMode The travel mode. - */ - public function __construct( - Distance $distance, - Duration $duration, - Coordinate $endLocation, - $instructions, - EncodedPolyline $encodedPolyline, - Coordinate $startLocation, - $travelMode - ) { - $this->setDistance($distance); - $this->setDuration($duration); - $this->setEndLocation($endLocation); - $this->setInstructions($instructions); - $this->setEncodedPolyline($encodedPolyline); - $this->setStartLocation($startLocation); - $this->setTravelMode($travelMode); - } - - /** - * Gets the step distance. - * - * @return \Ivory\GoogleMap\Services\Base\Distance The step distance. - */ - public function getDistance() - { - return $this->distance; - } - - /** - * Sets the step distance. - * - * @param \Ivory\GoogleMap\Services\Base\Distance $distance The step distance. - */ - public function setDistance(Distance $distance) - { - $this->distance = $distance; - } - - /** - * Gets the step duration. - * - * @return \Ivory\GoogleMap\Services\Base\Duration The step duration. - */ - public function getDuration() - { - return $this->duration; - } - - /** - * Sets the step duration - * - * @param \Ivory\GoogleMap\Services\Base\Duration $duration The step duration. - */ - public function setDuration(Duration $duration) - { - $this->duration = $duration; - } - - /** - * Gets the step end location. - * - * @return \Ivory\GoogleMap\Base\Coordinate The step end location. - */ - public function getEndLocation() - { - return $this->endLocation; - } - - /** - * Sets the step end location. - * - * @param \Ivory\GoogleMap\Base\Coordinate $endLocation The step end location. - */ - public function setEndLocation(Coordinate $endLocation) - { - $this->endLocation = $endLocation; - } - - /** - * Gets the step instructions. - * - * @return string The step instructions. - */ - public function getInstructions() - { - return $this->instructions; - } - - /** - * Sets the step instructions. - * - * @param string $instructions The step instructions. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the instructions is not valid. - */ - public function setInstructions($instructions) - { - if (!is_string($instructions)) { - throw DirectionsException::invalidDirectionsStepInstructions(); - } - - $this->instructions = $instructions; - } - - /** - * Gets the encoded polyline which describes the step. - * - * @return \Ivory\GoogleMap\Overlays\EncodedPolyline The encoded polyline. - */ - public function getEncodedPolyline() - { - return $this->encodedPolyline; - } - - /** - * Sets the encoded polyline which describes the step. - * - * @param \Ivory\GoogleMap\Overlays\EncodedPolyline $encodedPolyline The encoded polyline. - */ - public function setEncodedPolyline(EncodedPolyline $encodedPolyline) - { - $this->encodedPolyline = $encodedPolyline; - } - - /** - * Gets the step start location. - * - * @return \Ivory\GoogleMap\Base\Coordinate The step start location. - */ - public function getStartLocation() - { - return $this->startLocation; - } - - /** - * Sets the step start location. - * - * @param \Ivory\GoogleMap\Base\Coordinate $startLocation The step start position. - */ - public function setStartLocation(Coordinate $startLocation) - { - $this->startLocation = $startLocation; - } - - /** - * Gets the step travel mode. - * - * @return string The step travel mode. - */ - public function getTravelMode() - { - return $this->travelMode; - } - - /** - * Sets the step travel mode. - * - * @param string $travelMode The step travel mode. - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the travel mode is not valid. - */ - public function setTravelMode($travelMode) - { - if (!in_array($travelMode, TravelMode::getTravelModes())) { - throw DirectionsException::invalidDirectionsStepTravelMode(); - } - - $this->travelMode = $travelMode; - } -} diff --git a/src/Services/Directions/DirectionsWaypoint.php b/src/Services/Directions/DirectionsWaypoint.php deleted file mode 100644 index 5d1033ab..00000000 --- a/src/Services/Directions/DirectionsWaypoint.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\DirectionsException; - -/** - * A directions waypoint which describes the google map directions waypoint. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsWaypoint - * @author GeLo - */ -class DirectionsWaypoint -{ - /** @var string | \Ivory\GoogleMap\Base\Coordinate */ - protected $location; - - /** @var boolean */ - protected $stopover; - - /** - * Checks if the directions waypoint has a location. - * - * @return boolean TRUE if the directions waypoint has a location else FALSE. - */ - public function hasLocation() - { - return $this->location !== null; - } - - /** - * Gets the directions waypoint location. - * - * @return string | \Ivory\GoogleMap\Base\Coordinate The directions waypoint location. - */ - public function getLocation() - { - return $this->location; - } - - /** - * Sets the directions waypoint location. - * - * Available prototypes: - * - function setLocation(string $destination) - * - function setLocation(Ivory\GoogleMap\Base\Coordinate $destination) - * - function setLocation(double $latitude, double $longitude, boolean $noWrap) - * - * @throws \Ivory\GoogleMap\Exception\DirectionsException If the location is not valid (prototypes). - */ - public function setLocation() - { - $args = func_get_args(); - - if (isset($args[0]) && is_string($args[0])) { - $this->location = $args[0]; - } elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->location = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if ($this->location === null) { - $this->location = new Coordinate(); - } - - $this->location->setLatitude($args[0]); - $this->location->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->location->setNoWrap($args[2]); - } - } else { - throw DirectionsException::invalidDirectionsWaypointLocation(); - } - } - - /** - * Checks if the directions waypoint has a stopover flag. - * - * @return boolean TRUE if the directions waypoint has a stopover flag else FALSE. - */ - public function hasStopover() - { - return $this->stopover !== null; - } - - /** - * Gets the directions waypoint stopover flag. - * - * @return boolean The directions waypoint stopover flag. - */ - public function getStopover() - { - return $this->stopover; - } - - /** - * Sets the directions waypoint stopover flag. - * - * @param boolean $stopover The directions waypoint stopover flag. - */ - public function setStopover($stopover = null) - { - if (!is_bool($stopover) && ($stopover !== null)) { - throw DirectionsException::invalidDirectionsWaypointStopover(); - } - - $this->stopover = $stopover; - } - - /** - * Checks if the directions waypoint is valid. - * - * @return boolean TRUE if the directions waypoint is valid else FALSE. - */ - public function isValid() - { - return $this->hasLocation(); - } -} diff --git a/src/Services/DistanceMatrix/DistanceMatrix.php b/src/Services/DistanceMatrix/DistanceMatrix.php deleted file mode 100644 index f0416faf..00000000 --- a/src/Services/DistanceMatrix/DistanceMatrix.php +++ /dev/null @@ -1,264 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Services\AbstractService; -use Ivory\GoogleMap\Exception\DistanceMatrixException; -use Ivory\GoogleMap\Services\Base\Distance; -use Ivory\GoogleMap\Services\Base\Duration; -use Widop\HttpAdapter\HttpAdapterInterface; - -/** - * DistanceMatrix service. - * - * @author GeLo - * @author Tyler Sommer - */ -class DistanceMatrix extends AbstractService -{ - /** - * Creates a distance matrix service. - * - * @param \Widop\HttpAdapter\HttpAdapterInterface $httpAdapter The http adapter. - */ - public function __construct(HttpAdapterInterface $httpAdapter) - { - parent::__construct($httpAdapter, 'http://maps.googleapis.com/maps/api/distancematrix'); - } - - /** - * Processes the given request. - * - * Available prototypes: - * - function process(array $origins, array $destinations) - * - function process(Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest $request) - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the request is not valid (prototypes). - */ - public function process() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof DistanceMatrixRequest)) { - $distanceMatrixRequest = $args[0]; - } elseif ((isset($args[0]) && is_array($args[0])) && (isset($args[1]) && is_array($args[1]))) { - $distanceMatrixRequest = new DistanceMatrixRequest(); - - $distanceMatrixRequest->setOrigins($args[0]); - $distanceMatrixRequest->setDestinations($args[1]); - } else { - throw DistanceMatrixException::invalidDistanceMatrixRequestParameters(); - } - - if (!$distanceMatrixRequest->isValid()) { - throw DistanceMatrixException::invalidDistanceMatrixRequest(); - } - - $response = $this->send($this->generateUrl($distanceMatrixRequest)); - $distanceMatrixResponse = $this->buildDistanceMatrixResponse($this->parse($response->getBody())); - - return $distanceMatrixResponse; - } - - /** - * Generates distance matrix URL API according to the request. - * - * @param \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest $distanceMatrixRequest The distance matrix request. - * - * @return string The generated URL. - */ - protected function generateUrl(DistanceMatrixRequest $distanceMatrixRequest) - { - $httpQuery = array( - 'origins' => array(), - 'destinations' => array(), - ); - - foreach ($distanceMatrixRequest->getOrigins() as $origin) { - if (is_string($origin)) { - $httpQuery['origins'][] = $origin; - } else { - $httpQuery['origins'][] = sprintf( - '%s,%s', - $origin->getLatitude(), - $origin->getLongitude() - ); - } - } - - foreach ($distanceMatrixRequest->getDestinations() as $destination) { - if (is_string($destination)) { - $httpQuery['destinations'][] = $destination; - } else { - $httpQuery['destinations'][] = sprintf( - '%s,%s', - $destination->getLatitude(), - $destination->getLongitude() - ); - } - } - - $httpQuery['origins'] = implode('|', $httpQuery['origins']); - $httpQuery['destinations'] = implode('|', $httpQuery['destinations']); - - if ($distanceMatrixRequest->hasTravelMode()) { - $httpQuery['mode'] = strtolower($distanceMatrixRequest->getTravelMode()); - } - - if ($distanceMatrixRequest->hasAvoidTolls() && $distanceMatrixRequest->getAvoidTolls()) { - $httpQuery['avoidTolls'] = true; - } - - if ($distanceMatrixRequest->hasAvoidHighways() && $distanceMatrixRequest->getAvoidHighways()) { - $httpQuery['avoidHighways'] = true; - } - - if ($distanceMatrixRequest->hasUnitSystem()) { - $httpQuery['units'] = strtolower($distanceMatrixRequest->getUnitSystem()); - } - - if ($distanceMatrixRequest->hasRegion()) { - $httpQuery['region'] = $distanceMatrixRequest->getRegion(); - } - - if ($distanceMatrixRequest->hasLanguage()) { - $httpQuery['language'] = $distanceMatrixRequest->getLanguage(); - } - - $httpQuery['sensor'] = $distanceMatrixRequest->hasSensor() ? 'true' : 'false'; - - $url = sprintf('%s/%s?%s', $this->getUrl(), $this->getFormat(), http_build_query($httpQuery)); - - return $this->signUrl($url); - } - - /** - * Parses & normalizes the distance matrix API result response. - * - * @param string $response The distance matrix API response. - * - * @return \stdClass The parsed & normalized distance matrix response. - */ - protected function parse($response) - { - if ($this->format === 'json') { - return $this->parseJSON($response); - } - - return $this->parseXML($response); - } - - /** - * Parses & normalizes a JSON distance matrix API result response. - * - * @param string $response The distance matrix API JSON response. - * - * @return \stdClass The parsed & normalized distance matrix response. - */ - protected function parseJSON($response) - { - return json_decode($response); - } - - /** - * Parses & normalizes an XML distance matrix API result response. - * - * @param string $response The distance matrix API XML response. - * - * @return \stdClass The parsed & normalized distance matrix response. - */ - protected function parseXML($response) - { - $rules = array( - 'destination_address' => 'destination_addresses', - 'element' => 'elements', - 'origin_address' => 'origin_addresses', - 'row' => 'rows', - ); - - return $this->xmlParser->parse($response, $rules); - } - - /** - * Builds the distance matrix response according to the normalized distance matrix API results. - * - * @param \stdClass $distanceMatrixResponse The normalized distance matrix response. - * - * @return \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponse The built distance matrix response. - */ - protected function buildDistanceMatrixResponse(\stdClass $distanceMatrixResponse) - { - $status = $distanceMatrixResponse->status; - $destinations = $distanceMatrixResponse->destination_addresses; - $origins = $distanceMatrixResponse->origin_addresses; - $rows = $this->buildDistanceMatrixRows($distanceMatrixResponse->rows); - - return new DistanceMatrixResponse($status, $origins, $destinations, $rows); - } - - /** - * Builds the distance matrix response rows according to the normalized distance matrix API results. - * - * @param array $rows The normalized distance matrix response rows. - * - * @return array The built distance matrix response rows. - */ - protected function buildDistanceMatrixRows($rows) - { - $results = array(); - - foreach ($rows as $row) { - $results[] = $this->buildDistanceMatrixRow($row); - } - - return $results; - } - - /** - * Builds a distance matrix response row according to the normalized distance matrix API response row. - * - * @param \stdClass $row The normalized distance matrix response row. - * - * @return \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseRow The built distance matrix response row. - */ - protected function buildDistanceMatrixRow($row) - { - $elements = array(); - - foreach ($row->elements as $element) { - $elements[] = $this->buildDistanceMatrixResponseElement($element); - } - - return new DistanceMatrixResponseRow($elements); - } - - /** - * Builds a distance matrix response element according to the normalized distance matrix API response elements. - * - * @param \stdClass $element The normalized distance matrix response element. - * - * @return \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseElement The built distance matrix response element. - */ - protected function buildDistanceMatrixResponseElement($element) - { - $status = $element->status; - $distance = null; - $duration = null; - - if ($element->status === DistanceMatrixElementStatus::OK) { - $distance = new Distance($element->distance->text, $element->distance->value); - $duration = new Duration($element->duration->text, $element->duration->value); - } - - return new DistanceMatrixResponseElement($status, $distance, $duration); - } -} diff --git a/src/Services/DistanceMatrix/DistanceMatrixElementStatus.php b/src/Services/DistanceMatrix/DistanceMatrixElementStatus.php deleted file mode 100644 index d4371a2f..00000000 --- a/src/Services/DistanceMatrix/DistanceMatrixElementStatus.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\DistanceMatrix; - -/** - * A distance matrix status which describes the google map distance matrix status. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DistanceMatrixElementStatus - * @author GeLo - * @author Tyler Sommer - */ -class DistanceMatrixElementStatus -{ - const NOT_FOUND = 'NOT_FOUND'; - const OK = 'OK'; - const ZERO_RESULTS = 'ZERO_RESULTS'; - - /** - * Disabled constructor. - * - * @codeCoverageIgnore - */ - final private function __construct() - { - - } - - /** - * Gets the available distance matrix status. - * - * @return array The available distance matrix status. - */ - public static function getDistanceMatrixElementStatus() - { - return array( - self::NOT_FOUND, - self::OK, - self::ZERO_RESULTS, - ); - } -} diff --git a/src/Services/DistanceMatrix/DistanceMatrixRequest.php b/src/Services/DistanceMatrix/DistanceMatrixRequest.php deleted file mode 100644 index 3269d592..00000000 --- a/src/Services/DistanceMatrix/DistanceMatrixRequest.php +++ /dev/null @@ -1,452 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\DistanceMatrixException; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; - -/** - * DistanceMatrixRequest represents a google map distance matrix query. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#DistanceMatrixRequest - * @author GeLo - * @author Tyler Sommer - */ -class DistanceMatrixRequest -{ - /** @var boolean */ - protected $avoidHighways; - - /** @var boolean */ - protected $avoidTolls; - - /** @var array */ - protected $destinations; - - /** @var array */ - protected $origins; - - /** @var string */ - protected $region; - - /** @var string */ - protected $language; - - /** @var string */ - protected $travelMode; - - /** @var string */ - protected $unitSystem; - - /** @var boolean */ - protected $sensor; - - /** - * Creates a distance matrix request. - */ - public function __construct() - { - $this->origins = array(); - $this->destinations = array(); - $this->sensor = false; - } - - /** - * Checks if the distance matrix request has an avoid hightways flag. - * - * @return boolean TRUE if the distance matrix request has an avoid hightways flag else FALSE. - */ - public function hasAvoidHighways() - { - return $this->avoidHighways !== null; - } - - /** - * Checks if the distance matrix request avoid hightways. - * - * @return boolean TRUE if the distance matrix request avoids hightways else FALSE. - */ - public function getAvoidHighways() - { - return $this->avoidHighways; - } - - /** - * Sets if the the distance matrix request avoids hightways. - * - * @param boolean $avoidHighways TRUE if the distance matrix request avoids hightways else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the avoid highways flag is not valid. - */ - public function setAvoidHighways($avoidHighways = null) - { - if (!is_bool($avoidHighways) && ($avoidHighways !== null)) { - throw DistanceMatrixException::invalidDistanceMatrixRequestAvoidHighways(); - } - - $this->avoidHighways = $avoidHighways; - } - - /** - * Checks if the distance matrix request has an avoid tolls flag. - * - * @return boolean TRUE if the distance matrix request has an avoid tolls flag else FALSE. - */ - public function hasAvoidTolls() - { - return $this->avoidTolls !== null; - } - - /** - * Checks if the distance matrix request avoid tolls. - * - * @return boolean TRUE if the distance matrix request avoids tolls else FALSE. - */ - public function getAvoidTolls() - { - return $this->avoidTolls; - } - - /** - * Sets if the the distance matrix request avoids tolls. - * - * @param boolean $avoidTolls TRUE if the distance matrix request avoids tolls else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the avoid tolls flag is not valid. - */ - public function setAvoidTolls($avoidTolls = null) - { - if (!is_bool($avoidTolls) && ($avoidTolls !== null)) { - throw DistanceMatrixException::invalidDistanceMatrixRequestAvoidTolls(); - } - - $this->avoidTolls = $avoidTolls; - } - - /** - * Checks if the distance matrix request has destinations. - * - * @return boolean TRUE if the distance matrix request has a destination else FALSE. - */ - public function hasDestinations() - { - return !empty($this->destinations); - } - - /** - * Gets the distance matrix request destinations - * - * @return array The distance matrix request destination. - */ - public function getDestinations() - { - return $this->destinations; - } - - /** - * Sets the request destinations. - * - * @param array $destinations The distance matrix request destinations. - */ - public function setDestinations(array $destinations = array()) - { - $this->destinations = array(); - - foreach ($destinations as $destination) { - $this->addDestination($destination); - } - } - - /** - * Adds a destination to the request. - * - * Available prototypes: - * - function addDestination(string $destination) - * - function addDestination(Ivory\GoogleMap\Base\Coordinate $destination) - * - function addDestination(double $latitude, double $longitude, boolean $noWrap) - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the destination is not valid (prototypes). - */ - public function addDestination() - { - $args = func_get_args(); - - if (isset($args[0]) && is_string($args[0])) { - $this->destinations[] = $args[0]; - } elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->destinations[] = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - $destination = new Coordinate(); - $destination->setLatitude($args[0]); - $destination->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $destination->setNoWrap($args[2]); - } - - $this->destinations[] = $destination; - } else { - throw DistanceMatrixException::invalidDistanceMatrixRequestDestination(); - } - } - - /** - * Checks if the distance matrix request has origins. - * - * @return boolean TRUE if the distance matrix request has origins else FALSE. - */ - public function hasOrigins() - { - return !empty($this->origins); - } - - /** - * Gets the distance matrix request origin. - * - * @return array The distance matrix request origin. - */ - public function getOrigins() - { - return $this->origins; - } - - /** - * Sets the request origins. - * - * @param array $origins The distance matrix request origins. - */ - public function setOrigins(array $origins = array()) - { - $this->origins = array(); - - foreach ($origins as $origin) { - $this->addOrigin($origin); - } - } - - /** - * Adds an origin to the request. - * - * Available prototypes: - * - function addOrigin(string $destination) - * - function addOrigin(Ivory\GoogleMap\Base\Coordinate $destination) - * - function addOrigin(double $latitude, double $longitude, boolean $noWrap) - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the origin is not valid (prototypes). - */ - public function addOrigin() - { - $args = func_get_args(); - - if (isset($args[0]) && is_string($args[0])) { - $this->origins[] = $args[0]; - } elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->origins[] = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - $origin = new Coordinate(); - $origin->setLatitude($args[0]); - $origin->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $origin->setNoWrap($args[2]); - } - - $this->origins[] = $origin; - } else { - throw DistanceMatrixException::invalidDistanceMatrixRequestOrigin(); - } - } - - /** - * Checks if the distance matrix request has a region. - * - * @return boolean TRUE if the distance matrix request has a region else FALSE. - */ - public function hasRegion() - { - return $this->region !== null; - } - - /** - * Gets the distance matrix request region. - * - * @return string The direction request region. - */ - public function getRegion() - { - return $this->region; - } - - /** - * Sets the distance matrix request region. - * - * @param string $region The distance matrix request region. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the region is not valid. - */ - public function setRegion($region = null) - { - if ((!is_string($region) || (strlen($region) !== 2)) && ($region !== null)) { - throw DistanceMatrixException::invalidDistanceMatrixRequestRegion(); - } - - $this->region = $region; - } - - /** - * Checks if the distance matrix request has a language. - * - * @return boolean TRUE if the distance matrix request has a language else FALSE. - */ - public function hasLanguage() - { - return $this->language !== null; - } - - /** - * Gets the distance matrix request language. - * - * @return string The direction request language. - */ - public function getLanguage() - { - return $this->language; - } - - /** - * Sets the distance matrix request language. - * - * @param string $language The distance matrix request language. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the language is not valid. - */ - public function setLanguage($language = null) - { - if ((!is_string($language) || ((strlen($language) !== 2) && (strlen($language) !== 5))) && ($language !== null)) { - throw DistanceMatrixException::invalidDistanceMatrixRequestLanguage(); - } - - $this->language = $language; - } - - /** - * Checks if the distance matrix request has a travel mode. - * - * @return boolean TRUE if the distance matrix request has a travel mode else FALSE. - */ - public function hasTravelMode() - { - return $this->travelMode !== null; - } - - /** - * Gets the distance matrix request travel mode. - * - * @return string The distance matrix request travel mode. - */ - public function getTravelMode() - { - return $this->travelMode; - } - - /** - * Sets the distance matrix request travel mode. - * - * @param string $travelMode The distance matrix request travel mode. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the travel mode is not valid. - */ - public function setTravelMode($travelMode = null) - { - $travelModes = array_diff(TravelMode::getTravelModes(), array(TravelMode::TRANSIT)); - - if (!in_array($travelMode, $travelModes) && ($travelMode !== null)) { - throw DistanceMatrixException::invalidDistanceMatrixRequestTravelMode(); - } - - $this->travelMode = $travelMode; - } - - /** - * Checks if the distance matrix request has a unit system. - * - * @return boolean TRUE if the distance matrix request has a unit system else FALSE. - */ - public function hasUnitSystem() - { - return $this->unitSystem !== null; - } - - /** - * Gets the distance matrix request unit system. - * - * @return string The distance matrix request unit system. - */ - public function getUnitSystem() - { - return $this->unitSystem; - } - - /** - * Sets the distance matrix request unit system. - * - * @param string $unitSystem The distance matrix request unit system. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the unit system is not valid. - */ - public function setUnitSystem($unitSystem = null) - { - if (!in_array($unitSystem, UnitSystem::getUnitSystems()) && ($unitSystem !== null)) { - throw DistanceMatrixException::invalidDistanceMatrixRequestUnitSystem(); - } - - $this->unitSystem = $unitSystem; - } - - /** - * Checks if the distance matrix request has a sensor. - * - * @return boolean TRUE if the distance matrix request has a sensor else FALSE. - */ - public function hasSensor() - { - return $this->sensor; - } - - /** - * Sets the distance matrix request sensor. - * - * @param boolean $sensor TRUE if the distance matrix request has a sensor else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the sensor flag is not valid. - */ - public function setSensor($sensor) - { - if (!is_bool($sensor)) { - throw DistanceMatrixException::invalidDistanceMatrixRequestSensor(); - } - - $this->sensor = $sensor; - } - - /** - * Checks if the distance matrix request is valid. - * - * @return boolean TRUE if the distance matrix request is valid else FALSE. - */ - public function isValid() - { - return $this->hasDestinations() && $this->hasOrigins(); - } -} diff --git a/src/Services/DistanceMatrix/DistanceMatrixResponse.php b/src/Services/DistanceMatrix/DistanceMatrixResponse.php deleted file mode 100644 index 6da34aec..00000000 --- a/src/Services/DistanceMatrix/DistanceMatrixResponse.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Exception\DistanceMatrixException; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixStatus; - -/** - * A distance matrix response wraps the distance results & the response status. - * - * @author GeLo - * @author Tyler Sommer - */ -class DistanceMatrixResponse -{ - /** @var string */ - protected $status; - - /** @var array */ - protected $destinations; - - /** @var array */ - protected $origins; - - /** @var array */ - protected $rows; - - /** - * Create a distance matrix response. - * - * @param string $status The response status. - * @param array $origins The normalized origins. - * @param array $destinations The normalized destinations. - * @param array $rows The rows of data returned. - */ - public function __construct($status, array $origins, array $destinations, array $rows) - { - $this->setStatus($status); - $this->setOrigins($origins); - $this->setDestinations($destinations); - $this->setRows($rows); - } - - /** - * Gets the distance matrix routes. - * - * @return array The distance matrix origins. - */ - public function getOrigins() - { - return $this->origins; - } - - /** - * Sets the distance matrix routes. - * - * @param array $origins The distance matrix origins. - */ - public function setOrigins(array $origins) - { - $this->origins = array(); - - foreach ($origins as $origin) { - $this->addOrigin($origin); - } - } - - /** - * Add a distance matrix origin. - * - * @param string $origin The origin to add. - */ - public function addOrigin($origin) - { - $this->origins[] = $origin; - } - - /** - * Gets the distance matrix destinations. - * - * @return array The distance matrix destinations. - */ - public function getDestinations() - { - return $this->destinations; - } - - /** - * Sets the distance matrix destinations. - * - * @param array $destinations The distance matrix routes. - */ - public function setDestinations(array $destinations) - { - $this->destinations = array(); - - foreach ($destinations as $destination) { - $this->addDestination($destination); - } - } - - /** - * Add a distance matrix destination. - * - * @param string $destination The destination to add. - */ - public function addDestination($destination) - { - $this->destinations[] = $destination; - } - - /** - * Gets the distance matrix routes. - * - * @return array The distance matrix rows. - */ - public function getRows() - { - return $this->rows; - } - - /** - * Sets the distance matrix routes. - * - * @param array $rows The distance matrix routes. - */ - public function setRows(array $rows) - { - $this->rows = array(); - - foreach ($rows as $row) { - $this->addRow($row); - } - } - - /** - * Add a distance matrix route. - * - * @param \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseRow $row The row to add. - */ - public function addRow(DistanceMatrixResponseRow $row) - { - $this->rows[] = $row; - } - - /** - * Gets the distance matrix response status. - * - * @return string The distance matrix response status. - */ - public function getStatus() - { - return $this->status; - } - - /** - * Sets the distance matrix response status. - * - * @param string $status The distance matrix status. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the status is not valid. - */ - public function setStatus($status) - { - if (!in_array($status, DistanceMatrixStatus::getDistanceMatrixStatus())) { - throw DistanceMatrixException::invalidDistanceMatrixResponseStatus(); - } - - $this->status = $status; - } -} diff --git a/src/Services/DistanceMatrix/DistanceMatrixResponseElement.php b/src/Services/DistanceMatrix/DistanceMatrixResponseElement.php deleted file mode 100644 index fd4ef801..00000000 --- a/src/Services/DistanceMatrix/DistanceMatrixResponseElement.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Exception\DistanceMatrixException; -use Ivory\GoogleMap\Services\Base\Distance; -use Ivory\GoogleMap\Services\Base\Duration; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixElementStatus; - -/** - * A distance matrix response wraps the distance results & the response status. - * - * @author GeLo - * @author Tyler Sommer - */ -class DistanceMatrixResponseElement -{ - /** @var string */ - protected $status; - - /** @var null|\Ivory\GoogleMap\Services\Base\Distance */ - protected $distance; - - /** @var null|\Ivory\GoogleMap\Services\Base\Duration */ - protected $duration; - - /** - * Create a distance matrix response element. - * - * @param \Ivory\GoogleMap\Services\Base\Distance $distance The element distance. - * @param \Ivory\GoogleMap\Services\Base\Duration $duration The element duration. - * @param string $status The element status. - */ - public function __construct($status, Distance $distance = null, Duration $duration = null) - { - $this->setStatus($status); - - if ($distance !== null) { - $this->setDistance($distance); - } - - if ($duration !== null) { - $this->setDuration($duration); - } - } - - /** - * Gets the distance matrix response status. - * - * @return string The distance matrix response status. - */ - public function getStatus() - { - return $this->status; - } - - /** - * Sets the distance matrix response status. - * - * @param string $status The distance matrix status. - * - * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the status is not valid. - */ - public function setStatus($status) - { - if (!in_array($status, DistanceMatrixElementStatus::getDistanceMatrixElementStatus())) { - throw DistanceMatrixException::invalidDistanceMatrixResponseElementStatus(); - } - - $this->status = $status; - } - - /** - * Gets the step distance. - * - * @return \Ivory\GoogleMap\Services\Base\Distance The step distance. - */ - public function getDistance() - { - return $this->distance; - } - - /** - * Sets the step distance. - * - * @param \Ivory\GoogleMap\Services\Base\Distance $distance The step distance. - */ - public function setDistance(Distance $distance) - { - $this->distance = $distance; - } - - /** - * Gets the step duration. - * - * @return \Ivory\GoogleMap\Services\Base\Duration The step duration. - */ - public function getDuration() - { - return $this->duration; - } - - /** - * Sets the step duration - * - * @param \Ivory\GoogleMap\Services\Base\Duration $duration The step duration. - */ - public function setDuration(Duration $duration) - { - $this->duration = $duration; - } -} diff --git a/src/Services/DistanceMatrix/DistanceMatrixResponseRow.php b/src/Services/DistanceMatrix/DistanceMatrixResponseRow.php deleted file mode 100644 index 1f813931..00000000 --- a/src/Services/DistanceMatrix/DistanceMatrixResponseRow.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\DistanceMatrix; - -/** - * A distance matrix response wraps the distance results & the response status. - * - * @author GeLo - * @author Tyler Sommer - */ -class DistanceMatrixResponseRow -{ - /** @var array */ - protected $elements; - - /** - * Create a distance matrix response row. - * - * @param array $elements The row elements. - */ - public function __construct(array $elements) - { - $this->setElements($elements); - } - - /** - * Gets the distance matrix row elements. - * - * @return array The row elements. - */ - public function getElements() - { - return $this->elements; - } - - /** - * Sets the distance matrix row elements. - * - * @param array $elements The row elements. - */ - public function setElements(array $elements) - { - $this->elements = array(); - - foreach ($elements as $element) { - $this->addElement($element); - } - } - - /** - * Add a distance matrix element. - * - * @param \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseElement $element The element to add. - */ - public function addElement(DistanceMatrixResponseElement $element) - { - $this->elements[] = $element; - } -} diff --git a/src/Services/Geocoding/Geocoder.php b/src/Services/Geocoding/Geocoder.php deleted file mode 100644 index 87014aea..00000000 --- a/src/Services/Geocoding/Geocoder.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Geocoding; - -use Geocoder\Geocoder as BaseGeocoder; - -/** - * Geocoder which describes a google map geocoder. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Geocoder - * @author GeLo - */ -class Geocoder extends BaseGeocoder -{ - /** - * {@inheritdoc} - */ - public function geocode($request) - { - if ($this->getProvider() instanceof GeocoderProvider) { - return $this->getProvider()->getGeocodedData($request); - } - - return parent::geocode($request); - } - - /** - * {@inheritdoc} - */ - public function reverse($latitude, $longitude) - { - if ($this->getProvider() instanceof GeocoderProvider) { - return $this->getProvider()->getReversedData(array($latitude, $longitude)); - } - - return parent::reverse($latitude, $longitude); - } -} diff --git a/src/Services/Geocoding/GeocoderProvider.php b/src/Services/Geocoding/GeocoderProvider.php deleted file mode 100644 index 36e9b32b..00000000 --- a/src/Services/Geocoding/GeocoderProvider.php +++ /dev/null @@ -1,456 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Geocoding; - -use Geocoder\HttpAdapter\HttpAdapterInterface; -use Geocoder\Provider\AbstractProvider; -use Geocoder\Provider\ProviderInterface; -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\GeocodingException; -use Ivory\GoogleMap\Services\BusinessAccount; -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderAddressComponent; -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry; -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse; -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResult; -use Ivory\GoogleMap\Services\Utils\XmlParser; - -/** - * Geocoder provider. - * - * @author GeLo - */ -class GeocoderProvider extends AbstractProvider implements ProviderInterface -{ - /** @var string */ - protected $url; - - /** @var boolean */ - protected $https; - - /** @var string */ - protected $format; - - /** @var \Ivory\GoogleMap\Services\Utils\XmlParser */ - protected $xmlParser; - - /** @var \Ivory\GoogleMap\Services\BusinessAccount */ - protected $businessAccount; - - /** - * {@inheritdoc} - */ - public function __construct(HttpAdapterInterface $adapter, $locale = null) - { - parent::__construct($adapter, $locale); - - $this->setUrl('http://maps.googleapis.com/maps/api/geocode'); - $this->setHttps(false); - $this->setFormat('json'); - $this->setXmlParser(new XmlParser()); - } - - /** - * Gets the service url according to the https flag. - * - * @return string The service url. - */ - public function getUrl() - { - if ($this->isHttps()) { - return str_replace('http://', 'https://', $this->url); - } - - return $this->url; - } - - /** - * Sets the service url. - * - * @param string $url The service url. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the url is not valid. - */ - public function setUrl($url) - { - if (!is_string($url)) { - throw GeocodingException::invalidGeocoderProviderUrl(); - } - - $this->url = $url; - } - - /** - * Checks if the service uses HTTPS. - * - * @return boolean TRUE if the service uses HTTPS else FALSE. - */ - public function isHttps() - { - return $this->https; - } - - /** - * Sets the service HTTPS flag. - * - * @param boolean $https TRUE if the service uses HTTPS else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the https flag is not valid. - */ - public function setHttps($https) - { - if (!is_bool($https)) { - throw GeocodingException::invalidGeocoderProviderHttps(); - } - - $this->https = $https; - } - - /** - * Gets the service format. - * - * @return string The service format. - */ - public function getFormat() - { - return $this->format; - } - - /** - * Sets the service format. - * - * @param string $format The service format. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the format is not valid. - */ - public function setFormat($format) - { - if (($format !== 'json') && ($format !== 'xml')) { - throw GeocodingException::invalidGeocoderProviderFormat(); - } - - $this->format = $format; - } - - /** - * Gets the xml parser. - * - * @return \Ivory\GoogleMap\Services\Utils\XmlParser The xml parser. - */ - public function getXmlParser() - { - return $this->xmlParser; - } - - /** - * Sets the xml parser. - * - * @param \Ivory\GoogleMap\Services\Geocoding\XmlParser $xmlParser The xml parser. - */ - public function setXmlParser(XmlParser $xmlParser) - { - $this->xmlParser = $xmlParser; - } - - /** - * Checks if the geocoder provider has a business account. - * - * @return boolean TRUE if the geocoder provider has a business account else FALSE. - */ - public function hasBusinessAccount() - { - return $this->businessAccount !== null; - } - - /** - * Gets the business account. - * - * @return \Ivory\GoogleMap\Services\BusinessAccount The business account. - */ - public function getBusinessAccount() - { - return $this->businessAccount; - } - - /** - * Sets the business account. - * - * @param \Ivory\GoogleMap\Services\BusinessAccount $businessAccount The business account. - */ - public function setBusinessAccount(BusinessAccount $businessAccount = null) - { - $this->businessAccount = $businessAccount; - } - - /** - * {@inheritdoc} - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the request is not valid. - */ - public function getGeocodedData($request) - { - if (is_string($request)) { - $geocoderRequest = new GeocoderRequest(); - $geocoderRequest->setAddress($request); - } elseif ($request instanceof GeocoderRequest) { - $geocoderRequest = $request; - } else { - throw GeocodingException::invalidGeocoderProviderRequestArguments(); - } - - if (!$geocoderRequest->isValid()) { - throw GeocodingException::invalidGeocoderProviderRequest(); - } - - $url = $this->generateUrl($geocoderRequest); - $response = $this->getAdapter()->getContent($url); - - if ($response === null) { - throw GeocodingException::invalidServiceResult(); - } - - $normalizedResponse = $this->parse($response); - - return $this->buildGeocoderResponse($normalizedResponse); - } - - /** - * {@inheritdoc} - */ - public function getReversedData(array $coordinates) - { - $request = new GeocoderRequest(); - $request->setCoordinate($coordinates[0], $coordinates[1]); - - return $this->getGeocodedData($request); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'ivory_google_map'; - } - - /** - * Generates geocoding URL according to the request. - * - * @param \Ivory\GoogleMap\Services\Geocoding\GeocoderRequest $geocoderRequest The geocoder request. - * - * @return string The generated URL. - */ - protected function generateUrl(GeocoderRequest $geocoderRequest) - { - $httpQuery = array(); - - if ($geocoderRequest->hasAddress()) { - $httpQuery['address'] = $geocoderRequest->getAddress(); - } else { - $httpQuery['latlng'] = sprintf( - '%s,%s', - $geocoderRequest->getCoordinate()->getLatitude(), - $geocoderRequest->getCoordinate()->getLongitude() - ); - } - - if ($geocoderRequest->hasBound()) { - $httpQuery['bound'] = sprintf( - '%s,%s|%s,%s', - $geocoderRequest->getBound()->getSouthWest()->getLatitude(), - $geocoderRequest->getBound()->getSouthWest()->getLongitude(), - $geocoderRequest->getBound()->getNorthEast()->getLatitude(), - $geocoderRequest->getBound()->getNorthEast()->getLongitude() - ); - } - - if ($geocoderRequest->hasRegion()) { - $httpQuery['region'] = $geocoderRequest->getRegion(); - } - - if ($geocoderRequest->hasLanguage()) { - $httpQuery['language'] = $geocoderRequest->getLanguage(); - } - - $httpQuery['sensor'] = $geocoderRequest->hasSensor() ? 'true' : 'false'; - - $url = sprintf('%s/%s?%s', $this->getUrl(), $this->getFormat(), http_build_query($httpQuery)); - - return $this->signUrl($url); - } - - /** - * Sign an url for business account. - * - * @param string $url The url. - * - * @return string The signed url. - */ - protected function signUrl($url) - { - if (!$this->hasBusinessAccount()) { - return $url; - } - - return $this->businessAccount->signUrl($url); - } - - /** - * Parses & normalizes the geocoding result response. - * - * @param string $response The response. - * - * @return \stdClass The parsed & normalized response. - */ - protected function parse($response) - { - if ($this->format == 'json') { - return $this->parseJSON($response); - } - - return $this->parseXML($response); - } - - /** - * Parses & normalizes a JSON geocoding result response. - * - * @param string $response The response. - * - * @return \stdClass The parsed & normalized response. - */ - protected function parseJSON($response) - { - return json_decode($response); - } - - /** - * Parses & normalizes an XML geocoding result response. - * - * @param string $response The response. - * - * @return \stdClass The parsed & normalized response. - */ - protected function parseXML($response) - { - $rules = array( - 'address_component' => 'address_components', - 'type' => 'types', - 'result' => 'results', - ); - - return $this->xmlParser->parse($response, $rules); - } - - /** - * Builds the geocoder results accordint to a normalized geocoding results. - * - * @param \stdClass $geocoderResponse The normalized geocder response. - * - * @return \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse The builded geocoder response. - */ - protected function buildGeocoderResponse(\stdClass $geocoderResponse) - { - $results = array(); - foreach ($geocoderResponse->results as $geocoderResult) { - $results[] = $this->buildGeocoderResult($geocoderResult); - } - - $status = $geocoderResponse->status; - - return new GeocoderResponse($results, $status); - } - - /** - * Builds a geocoder result according to a normalized geocoding result. - * - * @param \stdClass $geocoderResult The normalized geocoder result. - * - * @return \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResult The builded geocoder result. - */ - protected function buildGeocoderResult(\stdClass $geocoderResult) - { - $addressComponents = $this->buildGeocoderAddressComponents($geocoderResult->address_components); - $formattedAddress = $geocoderResult->formatted_address; - $geometry = $this->buildGeocoderGeometry($geocoderResult->geometry); - $types = $geocoderResult->types; - $partialMatch = isset($geocoderResult->partial_match) ? $geocoderResult->partial_match : null; - - return new GeocoderResult($addressComponents, $formattedAddress, $geometry, $types, $partialMatch); - } - - /** - * Builds the gecoder address components according to a normalized geocoding address components. - * - * @param array $geocoderAddressComponents The normalized geocoder address components. - * - * @return array The builded geocoder address components. - */ - protected function buildGeocoderAddressComponents(array $geocoderAddressComponents) - { - $results = array(); - - foreach ($geocoderAddressComponents as $geocoderAddressComponent) { - $results[] = $this->buildGeocoderAddressComponent($geocoderAddressComponent); - } - - return $results; - } - - /** - * Builds a geocoder address component according to a normalized geocoding address component. - * - * @param \stdClass $geocoderAddressComponent The normalized geocoder address component. - * - * @return \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderAddressComponent The builded geocoder address - * component. - */ - protected function buildGeocoderAddressComponent(\stdClass $geocoderAddressComponent) - { - $longName = $geocoderAddressComponent->long_name; - $shortName = $geocoderAddressComponent->short_name; - $types = $geocoderAddressComponent->types; - - return new GeocoderAddressComponent($longName, $shortName, $types); - } - - /** - * Builds a geocoder geometry according to a normalized geocoding geometry. - * - * @param \stdClass $geocoderGeometry The normalized geocoder geomety. - * - * @return \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry The builded geocoder geometry. - */ - protected function buildGeocoderGeometry(\stdClass $geocoderGeometry) - { - $location = new Coordinate( - $geocoderGeometry->location->lat, - $geocoderGeometry->location->lng - ); - - $locationType = $geocoderGeometry->location_type; - - $viewport = new Bound( - new Coordinate($geocoderGeometry->viewport->southwest->lat, $geocoderGeometry->viewport->southwest->lng), - new Coordinate($geocoderGeometry->viewport->northeast->lat, $geocoderGeometry->viewport->northeast->lng) - ); - - $bound = null; - if (isset($geocoderGeometry->bounds)) { - $bound = new Bound( - new Coordinate($geocoderGeometry->bounds->southwest->lat, $geocoderGeometry->bounds->southwest->lng), - new Coordinate($geocoderGeometry->bounds->northeast->lat, $geocoderGeometry->bounds->northeast->lng) - ); - } - - return new GeocoderGeometry($location, $locationType, $viewport, $bound); - } -} diff --git a/src/Services/Geocoding/GeocoderRequest.php b/src/Services/Geocoding/GeocoderRequest.php deleted file mode 100644 index 04587261..00000000 --- a/src/Services/Geocoding/GeocoderRequest.php +++ /dev/null @@ -1,328 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Geocoding; - -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\GeocodingException; - -/** - * Geocoder request which describes a google map geocoder request. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderRequest - * @author GeLo - */ -class GeocoderRequest -{ - /** @var string */ - protected $address; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $coordinate; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** @var string */ - protected $region; - - /** @var string */ - protected $language; - - /** @var boolean */ - protected $sensor; - - /** - * Creates a geocoder request. - */ - public function __construct() - { - $this->sensor = false; - } - - /** - * Checks if the geocoder request has an address. - * - * @return boolean TRUE if the geocoder request has an address else FALSE. - */ - public function hasAddress() - { - return $this->address !== null; - } - - /** - * Gets the geocoder request address. - * - * @return string The geocoder request address. - */ - public function getAddress() - { - return $this->address; - } - - /** - * Sets the geocoder request address. - * - * @param string $address The geocoder request address. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the address is not valid. - */ - public function setAddress($address) - { - if (!is_string($address) && ($address !== null)) { - throw GeocodingException::invalidGeocoderRequestAddress(); - } - - $this->address = $address; - } - - /** - * Checks if the geocoder request has a coordinate. - * - * @return boolean TRUE if the geocoder request has a coordinate else FALSE. - */ - public function hasCoordinate() - { - return $this->coordinate !== null; - } - - /** - * Gets the geocoder request coordinate. - * - * @return \Ivory\GoogleMap\Base\Coordinate The geocoder request coordinate. - */ - public function getCoordinate() - { - return $this->coordinate; - } - - /** - * Sets the geocoder request coordinate - * - * Available prototypes: - * - function setCoordinate(\Ivory\GoogleMap\Base\Coordinate $coordinate = null) - * - function setCoordinate(double $latitude, double $longitude, boolean $noWrap = true) - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the coordinate is not valid (prototypes). - */ - public function setCoordinate() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Coordinate)) { - $this->coordinate = $args[0]; - } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) { - if (!$this->hasCoordinate()) { - $this->coordinate = new Coordinate(); - } - - $this->coordinate->setLatitude($args[0]); - $this->coordinate->setLongitude($args[1]); - - if (isset($args[2]) && is_bool($args[2])) { - $this->coordinate->setNoWrap($args[2]); - } - } elseif (!isset($args[0])) { - $this->coordinate = null; - } else { - throw GeocodingException::invalidGeocoderRequestCoordinate(); - } - - return $this; - } - - /** - * Checks if the geocoder request has a bound. - * - * @return boolean TRUE if the geocoder request has a bound else FALSE. - */ - public function hasBound() - { - return $this->bound !== null; - } - - /** - * Gets the geocoder request bound. - * - * @return \Ivory\GoogleMap\Base\Bound The geocoder request bound. - */ - public function getBound() - { - return $this->bound; - } - - /** - * Sets the geocoder request bound. - * - * Available prototypes: - * - function setBound(Ivory\GoogleMap\Base\Bound $bound = null) - * - function setBount(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the bound is not valid. - */ - public function setBound() - { - $args = func_get_args(); - - if (isset($args[0]) && ($args[0] instanceof Bound)) { - $this->bound = $args[0]; - } elseif ((isset($args[0]) && ($args[0] instanceof Coordinate)) - && (isset($args[1]) && ($args[1] instanceof Coordinate)) - ) { - if (!$this->hasBound()) { - $this->bound = new Bound(); - } - - $this->bound->setSouthWest($args[0]); - $this->bound->setNorthEast($args[1]); - } elseif ((isset($args[0]) && is_numeric($args[0])) - && (isset($args[1]) && is_numeric($args[1])) - && (isset($args[2]) && is_numeric($args[2])) - && (isset($args[3]) && is_numeric($args[3])) - ) { - if (!$this->hasBound()) { - $this->bound = new Bound(); - } - - $this->bound->setSouthWest(new Coordinate($args[0], $args[1])); - $this->bound->setNorthEast(new Coordinate($args[2], $args[3])); - - if (isset($args[4]) && is_bool($args[4])) { - $this->bound->getSouthWest()->setNoWrap($args[4]); - } - - if (isset($args[5]) && is_bool($args[5])) { - $this->bound->getNorthEast()->setNoWrap($args[5]); - } - } elseif (!isset($args[0])) { - $this->bound = null; - } else { - throw GeocodingException::invalidGeocoderRequestBound(); - } - } - - /** - * Checks if the geocoder request has a region. - * - * @return boolean TRUE if the geocoder request has a region else FALSE. - */ - public function hasRegion() - { - return $this->region !== null; - } - - /** - * Gets the geocoder request region - * - * @return string - */ - public function getRegion() - { - return $this->region; - } - - /** - * Sets the geocoder request region. - * - * @param string $region The geocoder request region. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the regin is not valid. - */ - public function setRegion($region = null) - { - if ((!is_string($region) || (strlen($region) !== 2)) && ($region !== null)) { - throw GeocodingException::invalidGeocoderRequestRegion(); - } - - $this->region = $region; - } - - /** - * Checks if the geocoder request has a language. - * - * @return boolean TRUE if the geocoder request has a language else FALSE. - */ - public function hasLanguage() - { - return $this->language !== null; - } - - /** - * Gets the geocoder request language. - * - * @return string The geocoder request language. - */ - public function getLanguage() - { - return $this->language; - } - - /** - * Sets the geocoder request language. - * - * @param string $language The geocoder request language. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the language is not valid. - */ - public function setLanguage($language = null) - { - if ((!is_string($language) || ((strlen($language) !== 2) && (strlen($language) !== 5))) && ($language !== null)) { - throw GeocodingException::invalidGeocoderRequestLanguage(); - } - - $this->language = $language; - } - - /** - * Checks if the geocoder request has a sensor. - * - * @return boolean TRUE if the geocoder request has a sensor else FALSE. - */ - public function hasSensor() - { - return $this->sensor; - } - - /** - * Sets the geocoder request sensor. - * - * @param boolean $sensor TRUE if the geocoder request has a sensor else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingRequest If the sensor flag is not valid. - */ - public function setSensor($sensor) - { - if (!is_bool($sensor)) { - throw GeocodingException::invalidGeocoderRequestSensor(); - } - - $this->sensor = $sensor; - } - - /** - * Checks if the geocoder request is valid. - * - * @return boolean TRUE if the geocoder request is valid else FALSE. - */ - public function isValid() - { - return $this->hasAddress() || $this->hasCoordinate(); - } -} diff --git a/src/Services/Geocoding/Result/GeocoderAddressComponent.php b/src/Services/Geocoding/Result/GeocoderAddressComponent.php deleted file mode 100644 index 24a836ed..00000000 --- a/src/Services/Geocoding/Result/GeocoderAddressComponent.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Exception\GeocodingException; - -/** - * GeocoderAddressComponent which describes a google map geocoder address component. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderAddressComponent - * @author GeLo - */ -class GeocoderAddressComponent -{ - /** @var string */ - protected $longName; - - /** @var string */ - protected $shortName; - - /** @var array */ - protected $types; - - /** - * Creates a geocoder address component. - * - * @param string $longName The long name. - * @param string $shortName The short name. - * @param array $types The types. - */ - public function __construct($longName, $shortName, array $types) - { - $this->setLongName($longName); - $this->setShortName($shortName); - $this->setTypes($types); - } - - /** - * Gets the address component long name. - * - * @return string The address component long name. - */ - public function getLongName() - { - return $this->longName; - } - - /** - * Sets the address component long name. - * - * @param string $longName The address componenet long name. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the long name is not valid. - */ - public function setLongName($longName) - { - if (!is_string($longName)) { - throw GeocodingException::invalidGeocoderAddressComponentLongName(); - } - - $this->longName = $longName; - } - - /** - * Gets the address component short name. - * - * @return string The address component short name. - */ - public function getShortName() - { - return $this->shortName; - } - - /** - * Sets the address component short name. - * - * @param string $shortName The address component short name. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the short name is not valid. - */ - public function setShortName($shortName) - { - if (!is_string($shortName)) { - throw GeocodingException::invalidGeocoderAddressComponentShortName(); - } - - $this->shortName = $shortName; - } - - /** - * Gets the address component types. - * - * @return array The address component types. - */ - public function getTypes() - { - return $this->types; - } - - /** - * Sets the address component types. - * - * @param array $types The address component types. - */ - public function setTypes(array $types) - { - $this->types = array(); - - foreach ($types as $type) { - $this->addType($type); - } - } - - /** - * Add an address component type. - * - * @param string $type The type to add. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the type is not valid. - */ - public function addType($type) - { - if (!is_string($type)) { - throw GeocodingException::invalidGeocoderAddressComponentType(); - } - - $this->types[] = $type; - } -} diff --git a/src/Services/Geocoding/Result/GeocoderGeometry.php b/src/Services/Geocoding/Result/GeocoderGeometry.php deleted file mode 100644 index 628f195d..00000000 --- a/src/Services/Geocoding/Result/GeocoderGeometry.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Exception\GeocodingException; - -/** - * GeocoderGeometry which describes a google map geocoder geometry. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderGeometry - * @author GeLo - */ -class GeocoderGeometry -{ - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $location; - - /** @var string */ - protected $locationType; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $viewport; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** - * Create a geocoder geometry. - * - * @param \Ivory\GoogleMap\Base\Coordinate $location The geometry location. - * @param string $locationType The geometry location type. - * @param \Ivory\GoogleMap\Base\Bound $viewport The geometry viewport. - * @param \Ivory\GoogleMap\Base\Bound $bound The geometry bound. - */ - public function __construct(Coordinate $location, $locationType, Bound $viewport, Bound $bound = null) - { - $this->setLocation($location); - $this->setLocationType($locationType); - $this->setViewport($viewport); - $this->setBound($bound); - } - - /** - * Gets the geometry location. - * - * @return \Ivory\GoogleMap\Base\Coordinate The geometry location. - */ - public function getLocation() - { - return $this->location; - } - - /** - * Sets the geometry location. - * - * @param \Ivory\GoogleMap\Base\Coordinate $location The geometry location. - */ - public function setLocation(Coordinate $location) - { - $this->location = $location; - } - - /** - * Gets the geometry location type. - * - * @return string The geometry location type. - */ - public function getLocationType() - { - return $this->locationType; - } - - /** - * Sets the geometry location type. - * - * @param string $locationType The geometry location type. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the location type is not valid. - */ - public function setLocationType($locationType) - { - if (!in_array($locationType, GeocoderLocationType::getGeocoderLocationTypes())) { - throw GeocodingException::invalidGeocoderLocationType(); - } - - $this->locationType = $locationType; - } - - /** - * Gets the geometry viewport - * - * @return \Ivory\GoogleMap\Base\Bound The geometry viewport. - */ - public function getViewport() - { - return $this->viewport; - } - - /** - * Sets the geometry viewport. - * - * @param \Ivory\GoogleMap\Base\Bound $viewport The geometry viewport. - */ - public function setViewport(Bound $viewport) - { - $this->viewport = $viewport; - } - - /** - * Gets the geometry bound. - * - * @return \Ivory\GoogleMap\Base\Bound The geometry bound. - */ - public function getBound() - { - return $this->bound; - } - - /** - * Sets the geometry bound. - * - * @param \Ivory\GoogleMap\Base\Bound $bound The geometry bound. - */ - public function setBound(Bound $bound = null) - { - $this->bound = $bound; - } -} diff --git a/src/Services/Geocoding/Result/GeocoderResponse.php b/src/Services/Geocoding/Result/GeocoderResponse.php deleted file mode 100644 index 3e7e5d1f..00000000 --- a/src/Services/Geocoding/Result/GeocoderResponse.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Exception\GeocodingException; - -/** - * A geocoder response wraps the geocoder results & the response status. - * - * @author GeLo - */ -class GeocoderResponse -{ - /** @var array */ - protected $results; - - /** @var string */ - protected $status; - - /** - * Create a geocoder results. - * - * @param array $results The geocoder results. - * @param string $status The geocoder status. - */ - public function __construct(array $results, $status) - { - $this->setResults($results); - $this->setStatus($status); - } - - /** - * Gets the geocoder results. - * - * @return array The geocoder results. - */ - public function getResults() - { - return $this->results; - } - - /** - * Sets the geocoder results - * - * @param array $results The geocoder results. - */ - public function setResults(array $results) - { - $this->results = array(); - - foreach ($results as $result) { - $this->addResult($result); - } - } - - /** - * Adds a geocoder result. - * - * @param \Ivory\GoogleMap\Services\Result\GeocoderResult $result The geocoder result to add. - */ - public function addResult(GeocoderResult $result) - { - $this->results[] = $result; - } - - /** - * Gets the geocoder results status. - * - * @return string The geocoder results status. - */ - public function getStatus() - { - return $this->status; - } - - /** - * Sets the geocoder results status. - * - * @param string $status The geocoder result status. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the status is not valid. - */ - public function setStatus($status) - { - if (!in_array($status, GeocoderStatus::getGeocoderStatus())) { - throw GeocodingException::invalidGeocoderResponseStatus(); - } - - $this->status = $status; - } -} diff --git a/src/Services/Geocoding/Result/GeocoderResult.php b/src/Services/Geocoding/Result/GeocoderResult.php deleted file mode 100644 index a1a5b5dd..00000000 --- a/src/Services/Geocoding/Result/GeocoderResult.php +++ /dev/null @@ -1,222 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Exception\GeocodingException; - -/** - * Geocoder result which describes a google map geocoder result. - * - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderResult - * @author GeLo - */ -class GeocoderResult -{ - /** @var array */ - protected $addressComponents; - - /** @var string */ - protected $formattedAddress; - - /** @var \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry */ - protected $geometry; - - /** @var boolean */ - protected $partialMatch; - - /** @var array */ - protected $types; - - /** - * Create a gecoder result. - * - * @param array $addressComponents The address components. - * @param string $formattedAddress The formatted address. - * @param \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry $geometry The geometry. - * @param array $types The types. - * @param boolean $partialMatch The partial match flag. - */ - public function __construct( - array $addressComponents, - $formattedAddress, - GeocoderGeometry $geometry, - array $types, - $partialMatch = null - ) { - $this->setAddressComponents($addressComponents); - $this->setFormattedAddress($formattedAddress); - $this->setGeometry($geometry); - $this->setTypes($types); - $this->setPartialMatch($partialMatch); - } - - /** - * Gets the address components. - * - * @param string|null The type of the address components. - * - * @return array The address components. - */ - public function getAddressComponents($type = null) - { - if ($type === null) { - return $this->addressComponents; - } - - $addressComponents = array(); - - foreach ($this->addressComponents as $addressComponent) { - if (in_array($type, $addressComponent->getTypes())) { - $addressComponents[] = $addressComponent; - } - } - - return $addressComponents; - } - - /** - * Sets address components. - * - * @param array $addressComponents The address components. - */ - public function setAddressComponents(array $addressComponents) - { - $this->addressComponents = array(); - - foreach ($addressComponents as $addressComponent) { - $this->addAddressComponent($addressComponent); - } - } - - /** - * Adds an address component to the geocoder result. - * - * @param \Ivory\GoogleMapBundle\Model\Services\Result\GeocoderAddressComponent $addressComponent The address - * component to add. - */ - public function addAddressComponent(GeocoderAddressComponent $addressComponent) - { - $this->addressComponents[] = $addressComponent; - } - - /** - * Gets the formatted address. - * - * @return string The formatted address. - */ - public function getFormattedAddress() - { - return $this->formattedAddress; - } - - /** - * Sets the formatted address. - * - * @param string $formattedAddress The formatted address. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the formatted address is not valid. - */ - public function setFormattedAddress($formattedAddress) - { - if (!is_string($formattedAddress)) { - throw GeocodingException::invalidGeocoderResultFormattedAddress(); - } - - $this->formattedAddress = $formattedAddress; - } - - /** - * Gets the geocoder result geometry. - * - * @return \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry The geocoder result geometry. - */ - public function getGeometry() - { - return $this->geometry; - } - - /** - * Sets the geocoder result geometry. - * - * @param \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry $geometry The geocoder result geometry. - */ - public function setGeometry(GeocoderGeometry $geometry) - { - $this->geometry = $geometry; - } - - /** - * Checks if the geocoder result is a partial match. - * - * @return boolean TRUE if the geocoder result is a partial match else FALSE. - */ - public function isPartialMatch() - { - return $this->partialMatch; - } - - /** - * Sets the geocoder result partial match flag. - * - * @param boolean $partialMatch TRUE if the geocoder result is a partial match else FALSE. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the partial match flag is not valid. - */ - public function setPartialMatch($partialMatch = null) - { - if (!is_bool($partialMatch) && ($partialMatch !== null)) { - throw GeocodingException::invalidGeocoderResultPartialMatch(); - } - - $this->partialMatch = $partialMatch; - } - - /** - * Gets the geocoder result types. - * - * @return array The geocoder result types. - */ - public function getTypes() - { - return $this->types; - } - - /** - * Sets the geocoder result types. - * - * @param array $types The geocoder result types. - */ - public function setTypes(array $types) - { - $this->types = array(); - - foreach ($types as $type) { - $this->addType($type); - } - } - - /** - * Adds a type to the geocoder result. - * - * @param string $type The type to add. - * - * @throws \Ivory\GoogleMap\Exception\GeocodingException If the type is not valid. - */ - public function addType($type) - { - if (!is_string($type)) { - throw GeocodingException::invalidGeocoderResultType(); - } - - $this->types[] = $type; - } -} diff --git a/src/Services/Utils/XmlParser.php b/src/Services/Utils/XmlParser.php deleted file mode 100644 index 48e988b5..00000000 --- a/src/Services/Utils/XmlParser.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\GoogleMap\Services\Utils; - -/** - * Xml parser. - * - * @author GeLo - */ -class XmlParser -{ - /** - * Parses xml according to pluralization rules. - * - * @param string $xml The xml. - * @param array $pluralizationRules The pluralization rules. - * - * @return \stdClass The parsed & pluralized xml. - */ - public function parse($xml, array $pluralizationRules = array()) - { - $parsedXml = json_decode(json_encode(new \SimpleXMLElement($xml)), true); - - return $this->pluralize($parsedXml, $pluralizationRules); - } - - /** - * Pluralizes xml. - * - * @param array $xml The xml. - * @param array $rules The pluralization rules. - * - * @return \stdClass The pluralized xml. - */ - protected function pluralize(array $xml, array $rules) - { - foreach ($xml as $attribute => $value) { - if (isset($rules[$attribute])) { - $xml[$rules[$attribute]] = $value; - unset($xml[$attribute]); - - $attribute = $rules[$attribute]; - - if (!is_array($value) || is_string(key($value))) { - $xml[$attribute] = array($value); - } - } - - if (is_array($xml[$attribute])) { - $xml[$attribute] = $this->pluralize($xml[$attribute], $rules); - } - } - - return $this->normalize($xml); - } - - /** - * Normalizes xml. - * - * @param array $xml The xml. - * - * @return array|\stdClass The normalized xml. - */ - protected function normalize(array $xml) - { - if (is_string(key($xml))) { - return (object) $xml; - } - - return $xml; - } -} diff --git a/src/Utility/OptionsAwareInterface.php b/src/Utility/OptionsAwareInterface.php new file mode 100644 index 00000000..e8375c95 --- /dev/null +++ b/src/Utility/OptionsAwareInterface.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Utility; + +/** + * @author GeLo + */ +interface OptionsAwareInterface +{ + /** + * @return bool + */ + public function hasOptions(); + + /** + * @return mixed[] + */ + public function getOptions(); + + /** + * @param mixed[] $options + */ + public function setOptions(array $options); + + /** + * @param mixed[] $options + */ + public function addOptions(array $options); + + /** + * @param string $option + * + * @return bool + */ + public function hasOption($option); + + /** + * @param string $option + * + * @return mixed + */ + public function getOption($option); + + /** + * @param string $option + * @param mixed $value + */ + public function setOption($option, $value); + + /** + * @param string $option + */ + public function removeOption($option); +} diff --git a/src/Utility/OptionsAwareTrait.php b/src/Utility/OptionsAwareTrait.php new file mode 100644 index 00000000..ccf9dfe9 --- /dev/null +++ b/src/Utility/OptionsAwareTrait.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Utility; + +/** + * @author GeLo + */ +trait OptionsAwareTrait +{ + /** + * @var mixed[] + */ + private $options = []; + + /** + * @return bool + */ + public function hasOptions() + { + return !empty($this->options); + } + + /** + * @return mixed[] + */ + public function getOptions() + { + return $this->options; + } + + /** + * @param mixed[] $options + */ + public function setOptions(array $options) + { + $this->options = []; + $this->addOptions($options); + } + + /** + * @param mixed[] $options + */ + public function addOptions(array $options) + { + foreach ($options as $option => $value) { + $this->setOption($option, $value); + } + } + + /** + * @param string $option + * + * @return bool + */ + public function hasOption($option) + { + return isset($this->options[$option]); + } + + /** + * @param string $option + * + * @return mixed + */ + public function getOption($option) + { + return $this->hasOption($option) ? $this->options[$option] : null; + } + + /** + * @param string $option + * @param mixed $value + */ + public function setOption($option, $value) + { + $this->options[$option] = $value; + } + + /** + * @param string $option + */ + public function removeOption($option) + { + unset($this->options[$option]); + } +} diff --git a/src/Utility/VariableAwareInterface.php b/src/Utility/VariableAwareInterface.php new file mode 100644 index 00000000..3cfc5ac3 --- /dev/null +++ b/src/Utility/VariableAwareInterface.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Utility; + +/** + * @author GeLo + */ +interface VariableAwareInterface +{ + /** + * @return string + */ + public function getVariable(); + + /** + * @param string $variable + */ + public function setVariable($variable); +} diff --git a/src/Utility/VariableAwareTrait.php b/src/Utility/VariableAwareTrait.php new file mode 100644 index 00000000..1e390e71 --- /dev/null +++ b/src/Utility/VariableAwareTrait.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\GoogleMap\Utility; + +/** + * @author GeLo + */ +trait VariableAwareTrait +{ + /** + * @var string + */ + private $variable; + + /** + * @return string + */ + public function getVariable() + { + if ($this->variable === null) { + $this->variable = $this->generateVariable(); + } + + return $this->variable; + } + + /** + * @param string $variable + */ + public function setVariable($variable) + { + $this->variable = $variable; + } + + /** + * @param string $prefix + */ + private function setVariablePrefix($prefix) + { + $this->variable = $this->generateVariable($prefix); + } + + /** + * @param string $prefix + * + * @return string + */ + private function generateVariable($prefix = null) + { + return str_replace('.', '', uniqid($prefix, true)); + } +} diff --git a/tests/Assets/JavascriptVariableAssetTest.php b/tests/Assets/JavascriptVariableAssetTest.php deleted file mode 100644 index 65604611..00000000 --- a/tests/Assets/JavascriptVariableAssetTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Assets; - -/** - * Javascript variable asset test. - * - * @author GeLo - */ -class JavascriptVariableAssetTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset */ - protected $asset; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->asset = $this->getMockForAbstractClass('Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset'); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->asset); - } - - public function testDefaultState() - { - $this->assertInternalType('string', $this->asset->getJavascriptVariable()); - } - - public function testInitialState() - { - $this->asset = $this->getMockBuilder('Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset') - ->setConstructorArgs(array('foo')) - ->getMockForAbstractClass(); - - $this->assertSame('foo', $this->asset->getJavascriptVariable()); - } - - public function testjavascriptVariableWithValidVariable() - { - $this->asset->setJavascriptVariable('foo'); - - $this->assertSame('foo', $this->asset->getJavascriptVariable()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\AssetException - * @expectedExceptionMessage The javascript variable must be a string value. - */ - public function testJavascriptVariableWithInvalidVariable() - { - $this->asset->setJavascriptVariable(true); - } - - public function testPrefixJavascriptVariableWithValidPrefix() - { - $this->asset->setPrefixJavascriptVariable('foo'); - - $this->assertSame('foo', substr($this->asset->getJavascriptVariable(), 0, 3)); - $this->assertGreaterThan(3, strlen($this->asset->getJavascriptVariable())); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\AssetException - * @expectedExceptionMessage The prefix of a javascript variable must be a string value. - */ - public function testPrefixJavascriptVariableWithInvalidPrefix() - { - $this->asset->setPrefixJavascriptVariable(true); - } -} diff --git a/tests/Assets/OptionsAssetTest.php b/tests/Assets/OptionsAssetTest.php deleted file mode 100644 index 0c954dfb..00000000 --- a/tests/Assets/OptionsAssetTest.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Assets; - -/** - * Options asset test. - * - * @author GeLo - */ -class OptionsAssetTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Assets\AbstractOptionsAsset */ - protected $asset; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->asset = $this->getMockForAbstractClass('Ivory\GoogleMap\Assets\AbstractOptionsAsset'); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->asset); - } - - public function testDefaultState() - { - $this->assertInternalType('string', $this->asset->getJavascriptVariable()); - $this->assertEmpty($this->asset->getOptions()); - } - - public function testInitialState() - { - $this->asset = $this->getMockBuilder('Ivory\GoogleMap\Assets\AbstractOptionsAsset') - ->setConstructorArgs(array('foo', array('foo' => 'bar'))) - ->getMockForAbstractClass(); - - $this->assertSame('foo', $this->asset->getJavascriptVariable()); - $this->assertSame(array('foo' => 'bar'), $this->asset->getOptions()); - } - - public function testOptions() - { - $this->asset->setOptions(array('foo' => 'bar')); - - $this->assertTrue($this->asset->hasOptions()); - $this->assertSame(array('foo' => 'bar'), $this->asset->getOptions()); - - $this->assertTrue($this->asset->hasOption('foo')); - $this->assertSame('bar', $this->asset->getOption('foo')); - - $this->asset->removeOption('foo'); - - $this->assertFalse($this->asset->hasOption('foo')); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\AssetException - * @expectedExceptionMessage The option property must be a string value. - */ - public function testHasOptionWithInvalidOption() - { - $this->asset->hasOption(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\AssetException - * @expectedExceptionMessage The option "foo" does not exist. - */ - public function testGetOptionWithInvalidOption() - { - $this->asset->getOption('foo'); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\AssetException - * @expectedExceptionMessage The option property must be a string value. - */ - public function testSetOptionWithInvalidOption() - { - $this->asset->setOption(true, false); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\AssetException - * @expectedExceptionMessage The option "foo" does not exist. - */ - public function testRemoveOptionWithInvalidOption() - { - $this->asset->removeOption('foo'); - } -} diff --git a/tests/Base/BoundTest.php b/tests/Base/BoundTest.php index f3b58b6b..27cade97 100644 --- a/tests/Base/BoundTest.php +++ b/tests/Base/BoundTest.php @@ -12,16 +12,19 @@ namespace Ivory\Tests\GoogleMap\Base; use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; /** - * Bound test. - * * @author GeLo */ class BoundTest extends \PHPUnit_Framework_TestCase { - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; + /** + * @var Bound + */ + private $bound; /** * {@inheritdoc} @@ -31,122 +34,137 @@ protected function setUp() $this->bound = new Bound(); } - /** - * {@inheritdoc} - */ - protected function tearDown() + public function testInheritance() { - unset($this->bound); + $this->assertInstanceOf(VariableAwareInterface::class, $this->bound); } public function testDefaultState() { - $this->assertSame('bound_', substr($this->bound->getJavascriptVariable(), 0, 6)); + $this->assertStringStartsWith('bound', $this->bound->getVariable()); + $this->assertFalse($this->bound->hasSouthWest()); + $this->assertNull($this->bound->getSouthWest()); + $this->assertFalse($this->bound->hasNorthEast()); + $this->assertNull($this->bound->getNorthEast()); $this->assertFalse($this->bound->hasCoordinates()); - $this->assertFalse($this->bound->hasExtends()); + $this->assertFalse($this->bound->hasExtendables()); } public function testInitialState() { - $southWest = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $northEast = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $extends = array($this->getMock('Ivory\GoogleMap\Overlays\ExtendableInterface')); - - $this->bound = new Bound($southWest, $northEast, $extends); + $this->bound = new Bound( + $southWest = $this->createCoordinateMock(), + $northEast = $this->createCoordinateMock() + ); - $this->assertTrue($this->bound->hasCoordinates()); + $this->assertStringStartsWith('bound', $this->bound->getVariable()); + $this->assertTrue($this->bound->hasSouthWest()); $this->assertSame($southWest, $this->bound->getSouthWest()); + $this->assertTrue($this->bound->hasNorthEast()); $this->assertSame($northEast, $this->bound->getNorthEast()); - - $this->assertTrue($this->bound->hasExtends()); - $this->assertSame($extends, $this->bound->getExtends()); + $this->assertTrue($this->bound->hasCoordinates()); + $this->assertFalse($this->bound->hasExtendables()); } - public function testSouthWestWithCoordinate() + public function testSouthWest() { - $southWest = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->bound->setSouthWest($southWest); + $this->bound->setSouthWest($southWest = $this->createCoordinateMock()); + $this->assertFalse($this->bound->hasCoordinates()); + $this->assertFalse($this->bound->hasExtendables()); + $this->assertTrue($this->bound->hasSouthWest()); $this->assertSame($southWest, $this->bound->getSouthWest()); } - public function testSouthWestWithLatitudeAndLongitude() + public function testResetSouthWest() { - $this->bound->setSouthWest(1, 2, false); + $this->bound->setSouthWest($this->createCoordinateMock()); + $this->bound->setSouthWest(null); - $this->assertSame(1, $this->bound->getSouthWest()->getLatitude()); - $this->assertSame(2, $this->bound->getSouthWest()->getLongitude()); - $this->assertFalse($this->bound->getSouthWest()->isNoWrap()); + $this->assertFalse($this->bound->hasSouthWest()); + $this->assertNull($this->bound->getSouthWest()); } - public function testSouthWestWithNull() + public function testNorthEast() { - $this->bound->setSouthWest(1, 2, false); - $this->bound->setSouthWest(null); + $this->bound->setNorthEast($northEast = $this->createCoordinateMock()); - $this->assertNull($this->bound->getSouthWest()); + $this->assertFalse($this->bound->hasCoordinates()); + $this->assertFalse($this->bound->hasExtendables()); + $this->assertTrue($this->bound->hasNorthEast()); + $this->assertSame($northEast, $this->bound->getNorthEast()); } - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage - * The south west setter arguments is invalid. - * The available prototypes are : - * - function setSouthWest(Ivory\GoogleMap\Base\Coordinate $southWest) - * - function setSouthWest(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testSouthWestWithInvalidValue() + public function testResetNorthEast() { - $this->bound->setSouthWest('foo'); + $this->bound->setNorthEast($northEast = $this->createCoordinateMock()); + $this->bound->setNorthEast(null); + + $this->assertFalse($this->bound->hasNorthEast()); + $this->assertNull($this->bound->getNorthEast()); } - public function testNorthEastWithCoordinate() + public function testCoordinates() { - $northEast = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->bound->setNorthEast($northEast); + $this->bound->setSouthWest($this->createCoordinateMock()); + $this->bound->setNorthEast($this->createCoordinateMock()); - $this->assertSame($northEast, $this->bound->getNorthEast()); + $this->assertTrue($this->bound->hasCoordinates()); + $this->assertFalse($this->bound->hasExtendables()); } - public function testNorthEastWithLatitudeAndLongitude() + public function testSetExtendables() { - $this->bound->setNorthEast(1, 2, false); + $this->bound->setExtendables($extendables = [$extendable = $this->createExtendableMock()]); + $this->bound->setExtendables($extendables); - $this->assertSame(1, $this->bound->getNorthEast()->getLatitude()); - $this->assertSame(2, $this->bound->getNorthEast()->getLongitude()); - $this->assertFalse($this->bound->getNorthEast()->isNoWrap()); + $this->assertFalse($this->bound->hasCoordinates()); + $this->assertTrue($this->bound->hasExtendables()); + $this->assertTrue($this->bound->hasExtendable($extendable)); + $this->assertSame($extendables, $this->bound->getExtendables()); } - public function testNorthEastWithNull() + public function testAddExtendables() { - $this->bound->setNorthEast(1, 2, false); - $this->bound->setNorthEast(null); + $this->bound->setExtendables($firstExtendables = [$this->createExtendableMock()]); + $this->bound->addExtendables($secondExtendables = [$this->createExtendableMock()]); - $this->assertNull($this->bound->getNorthEast()); + $this->assertTrue($this->bound->hasExtendables()); + $this->assertSame(array_merge($firstExtendables, $secondExtendables), $this->bound->getExtendables()); } - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage - * The north east setter arguments is invalid. - * The available prototypes are : - * - function setNorthEast(Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setNorthEast(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testNorthEastWithInvalidValue() + public function testAddExtendable() { - $this->bound->setNorthEast('foo'); + $this->bound->addExtendable($extendable = $this->createExtendableMock()); + + $this->assertFalse($this->bound->hasCoordinates()); + $this->assertTrue($this->bound->hasExtendables()); + $this->assertTrue($this->bound->hasExtendable($extendable)); + $this->assertSame([$extendable], $this->bound->getExtendables()); } - public function testCenter() + public function testRemoveExtendable() { - $this->bound->setSouthWest(-1, 0, false); - $this->bound->setNorthEast(1, 2, false); + $this->bound->addExtendable($extendable = $this->createExtendableMock()); + $this->bound->removeExtendable($extendable); + + $this->assertFalse($this->bound->hasExtendables()); + $this->assertFalse($this->bound->hasExtendable($extendable)); + } - $center = $this->bound->getCenter(); + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } - $this->assertSame(0, $center->getLatitude()); - $this->assertSame(1, $center->getLongitude()); - $this->assertTrue($center->isNoWrap()); + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ExtendableInterface + */ + private function createExtendableMock() + { + return $this->createMock(ExtendableInterface::class); } } diff --git a/tests/Base/CoordinateTest.php b/tests/Base/CoordinateTest.php index 04b76bc8..28dff16e 100644 --- a/tests/Base/CoordinateTest.php +++ b/tests/Base/CoordinateTest.php @@ -12,16 +12,17 @@ namespace Ivory\Tests\GoogleMap\Base; use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Utility\VariableAwareInterface; /** - * Coordinate test. - * * @author GeLo */ class CoordinateTest extends \PHPUnit_Framework_TestCase { - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $coordinate; + /** + * @var Coordinate + */ + private $coordinate; /** * {@inheritdoc} @@ -31,85 +32,47 @@ protected function setUp() $this->coordinate = new Coordinate(); } - /** - * {@inheritdoc} - */ - protected function tearDown() + public function testInheritance() { - unset($this->coordinate); + $this->assertInstanceOf(VariableAwareInterface::class, $this->coordinate); } public function testDefaultState() { - $this->assertSame('coordinate_', substr($this->coordinate->getJavascriptVariable(), 0, 11)); - $this->assertSame(0, $this->coordinate->getLatitude()); - $this->assertSame(0, $this->coordinate->getLongitude()); + $this->assertStringStartsWith('coordinate', $this->coordinate->getVariable()); + $this->assertSame(0.0, $this->coordinate->getLatitude()); + $this->assertSame(0.0, $this->coordinate->getLongitude()); $this->assertTrue($this->coordinate->isNoWrap()); } public function testInitialState() { - $this->coordinate = new Coordinate(1, 2, false); + $this->coordinate = new Coordinate($latitude = 1.2, $longitude = 2.3, false); - $this->assertSame(1, $this->coordinate->getLatitude()); - $this->assertSame(2, $this->coordinate->getLongitude()); + $this->assertStringStartsWith('coordinate', $this->coordinate->getVariable()); + $this->assertSame($latitude, $this->coordinate->getLatitude()); + $this->assertSame($longitude, $this->coordinate->getLongitude()); $this->assertFalse($this->coordinate->isNoWrap()); } - public function testLatitudeWithValidLatitude() - { - $this->coordinate->setLatitude(1); - $this->assertSame(1, $this->coordinate->getLatitude()); - } - - public function testLatitudeWithNull() - { - $this->coordinate->setLatitude(null); - $this->assertNull($this->coordinate->getLatitude()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The latitude of a coordinate must be a numeric value. - */ - public function testLatitudeWithInvalidLatitude() + public function testLatitude() { - $this->coordinate->setLatitude(true); - } + $this->coordinate->setLatitude($latitude = 1.2); - public function testLongitudeWithValidLongitude() - { - $this->coordinate->setLongitude(1); - $this->assertSame(1, $this->coordinate->getLongitude()); + $this->assertSame($latitude, $this->coordinate->getLatitude()); } - public function testLongitudeWithNull() + public function testLongitude() { - $this->coordinate->setLongitude(null); - $this->assertNull($this->coordinate->getLongitude()); - } + $this->coordinate->setLongitude($longitude = 1.2); - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The longitude of a coordinate must be a numeric value. - */ - public function testLongitudeWithInvalidLongitude() - { - $this->coordinate->setLongitude(true); + $this->assertSame($longitude, $this->coordinate->getLongitude()); } - public function testNoWrapWithValidNoWrap() + public function testNoWrap() { $this->coordinate->setNoWrap(false); - $this->assertFalse($this->coordinate->isNoWrap()); - } - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The no wrap coordinate property must be a boolean value. - */ - public function testNoWrapWithInvalidNoWrap() - { - $this->coordinate->setNoWrap('foo'); + $this->assertFalse($this->coordinate->isNoWrap()); } } diff --git a/tests/Base/PointTest.php b/tests/Base/PointTest.php index 53ff1b0c..364375f6 100644 --- a/tests/Base/PointTest.php +++ b/tests/Base/PointTest.php @@ -12,16 +12,17 @@ namespace Ivory\Tests\GoogleMap\Base; use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Utility\VariableAwareInterface; /** - * Point test. - * * @author GeLo */ class PointTest extends \PHPUnit_Framework_TestCase { - /** @var \Ivory\GoogleMap\Base\Point */ - protected $point; + /** + * @var Point + */ + private $point; /** * {@inheritdoc} @@ -31,58 +32,38 @@ protected function setUp() $this->point = new Point(); } - /** - * {@inheritdoc} - */ - protected function tearDown() + public function testInheritance() { - unset($this->point); + $this->assertInstanceOf(VariableAwareInterface::class, $this->point); } public function testDefaultState() { - $this->assertSame('point_', substr($this->point->getJavascriptVariable(), 0, 6)); - $this->assertSame(0, $this->point->getX()); - $this->assertSame(0, $this->point->getY()); + $this->assertStringStartsWith('point', $this->point->getVariable()); + $this->assertSame(0.0, $this->point->getX()); + $this->assertSame(0.0, $this->point->getY()); } public function testInitialState() { - $this->point = new Point(1, 2); + $this->point = new Point($x = 1.2, $y = 2.3); - $this->assertSame(1, $this->point->getX()); - $this->assertSame(2, $this->point->getY()); + $this->assertStringStartsWith('point', $this->point->getVariable()); + $this->assertSame($x, $this->point->getX()); + $this->assertSame($y, $this->point->getY()); } - public function testXWithValidValue() + public function testX() { - $this->point->setX(1); - - $this->assertSame(1, $this->point->getX()); - } + $this->point->setX($x = 1.2); - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The x coordinate of a point must be a numeric value. - */ - public function testXWithInvalidValue() - { - $this->point->setX(true); + $this->assertSame($x, $this->point->getX()); } - public function testYWithValidValue() + public function testY() { - $this->point->setY(1); - - $this->assertSame(1, $this->point->getY()); - } + $this->point->setY($y = 1.2); - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The y coordinate of a point must be a numeric value. - */ - public function testYWithInvalidValue() - { - $this->point->setY(true); + $this->assertSame($y, $this->point->getY()); } } diff --git a/tests/Base/SizeTest.php b/tests/Base/SizeTest.php index cc669876..1f8ab810 100644 --- a/tests/Base/SizeTest.php +++ b/tests/Base/SizeTest.php @@ -12,16 +12,17 @@ namespace Ivory\Tests\GoogleMap\Base; use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Utility\VariableAwareInterface; /** - * Size test. - * * @author GeLo */ class SizeTest extends \PHPUnit_Framework_TestCase { - /** @var \Ivory\GoogleMap\Base\Size */ - protected $size; + /** + * @var Size + */ + private $size; /** * {@inheritdoc} @@ -31,99 +32,73 @@ protected function setUp() $this->size = new Size(); } - /** - * {@inheritdoc} - */ - protected function tearDown() + public function testInheritance() { - unset($this->size); + $this->assertInstanceOf(VariableAwareInterface::class, $this->size); } public function testDefaultState() { - $this->assertSame('size_', substr($this->size->getJavascriptVariable(), 0, 5)); - - $this->assertSame(1, $this->size->getWidth()); - $this->assertSame(1, $this->size->getHeight()); - + $this->assertStringStartsWith('size', $this->size->getVariable()); + $this->assertSame(1.0, $this->size->getWidth()); + $this->assertSame(1.0, $this->size->getHeight()); $this->assertFalse($this->size->hasUnits()); + $this->assertFalse($this->size->hasWidthUnit()); + $this->assertFalse($this->size->hasHeightUnit()); $this->assertNull($this->size->getWidthUnit()); $this->assertNull($this->size->getHeightUnit()); } public function testInitialState() { - $this->size = new Size(2, 3, 'px', '%'); - - $this->assertSame(2, $this->size->getWidth()); - $this->assertSame(3, $this->size->getHeight()); + $this->size = new Size($width = 1.2, $height = 2.3, $widthUnit = 'px', $heightUnit = '%'); + $this->assertSame($width, $this->size->getWidth()); + $this->assertSame($height, $this->size->getHeight()); $this->assertTrue($this->size->hasUnits()); - $this->assertSame('px', $this->size->getWidthUnit()); - $this->assertSame('%', $this->size->getHeightUnit()); + $this->assertTrue($this->size->hasWidthUnit()); + $this->assertTrue($this->size->hasHeightUnit()); + $this->assertSame($widthUnit, $this->size->getWidthUnit()); + $this->assertSame($heightUnit, $this->size->getHeightUnit()); } - public function testWidthWithValidValue() + public function testWidth() { - $this->size->setWidth(2); - - $this->assertSame(2, $this->size->getWidth()); - } + $this->size->setWidth($width = 1.2); - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The width of a size must be a numeric value. - */ - public function testWidthWithInvalidValue() - { - $this->size->setWidth(true); + $this->assertSame($width, $this->size->getWidth()); } - public function testHeightWithValidValue() + public function testHeight() { - $this->size->setHeight(2); - - $this->assertSame(2, $this->size->getHeight()); - } + $this->size->setHeight($height = 1.2); - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The height of a size must be a numeric value. - */ - public function testHeightWithInvalidValue() - { - $this->size->setHeight(true); + $this->assertSame($height, $this->size->getHeight()); } - public function testWidthUnitWithValidValue() + public function testWidthUnit() { - $this->size->setWidthUnit('px'); + $this->size->setWidthUnit($widthUnit = 'px'); - $this->assertSame('px', $this->size->getWidthUnit()); + $this->assertFalse($this->size->hasUnits()); + $this->assertTrue($this->size->hasWidthUnit()); + $this->assertSame($widthUnit, $this->size->getWidthUnit()); } - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The width unit of a size must be a string value. - */ - public function testWidthUnitWithInvalidValue() + public function testHeightUnit() { - $this->size->setWidthUnit(true); + $this->size->setHeightUnit($heightUnit = 'px'); + + $this->assertFalse($this->size->hasUnits()); + $this->assertTrue($this->size->hasHeightUnit()); + $this->assertSame($heightUnit, $this->size->getHeightUnit()); } - public function testHeightUnitWithValidValue() + public function testUnits() { + $this->size->setWidthUnit('px'); $this->size->setHeightUnit('px'); - $this->assertSame('px', $this->size->getHeightUnit()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\BaseException - * @expectedExceptionMessage The height unit of a size must be a string value. - */ - public function testHeightUnitWithInvalidValue() - { - $this->size->setHeightUnit(true); + $this->assertTrue($this->size->hasUnits()); } } diff --git a/tests/Control/ControlManagerTest.php b/tests/Control/ControlManagerTest.php new file mode 100644 index 00000000..d6437691 --- /dev/null +++ b/tests/Control/ControlManagerTest.php @@ -0,0 +1,207 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Control; + +use Ivory\GoogleMap\Control\ControlManager; +use Ivory\GoogleMap\Control\MapTypeControl; +use Ivory\GoogleMap\Control\RotateControl; +use Ivory\GoogleMap\Control\ScaleControl; +use Ivory\GoogleMap\Control\StreetViewControl; +use Ivory\GoogleMap\Control\ZoomControl; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class ControlManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ControlManager + */ + private $controlManager; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->controlManager = new ControlManager(); + } + + public function testDefaultState() + { + $this->assertFalse($this->controlManager->hasMap()); + $this->assertNull($this->controlManager->getMap()); + $this->assertFalse($this->controlManager->hasMapTypeControl()); + $this->assertNull($this->controlManager->getMapTypeControl()); + $this->assertFalse($this->controlManager->hasRotateControl()); + $this->assertNull($this->controlManager->getRotateControl()); + $this->assertFalse($this->controlManager->hasScaleControl()); + $this->assertNull($this->controlManager->getScaleControl()); + $this->assertFalse($this->controlManager->hasStreetViewControl()); + $this->assertNull($this->controlManager->getStreetViewControl()); + $this->assertFalse($this->controlManager->hasZoomControl()); + $this->assertNull($this->controlManager->getZoomControl()); + } + + public function testMap() + { + $map = $this->createMapMock(); + $map + ->expects($this->once()) + ->method('getControlManager') + ->will($this->returnValue(null)); + + $map + ->expects($this->once()) + ->method('setControlManager') + ->with($this->identicalTo($this->controlManager)); + + $this->controlManager->setMap($map); + + $this->assertTrue($this->controlManager->hasMap()); + $this->assertSame($map, $this->controlManager->getMap()); + } + + public function testMapTypeControl() + { + $this->controlManager->setMapTypeControl($mapTypeControl = $this->createMapTypeControlMock()); + + $this->assertTrue($this->controlManager->hasMapTypeControl()); + $this->assertSame($mapTypeControl, $this->controlManager->getMapTypeControl()); + } + + public function testResetMapTypeControl() + { + $this->controlManager->setMapTypeControl($this->createMapTypeControlMock()); + $this->controlManager->setMapTypeControl(null); + + $this->assertFalse($this->controlManager->hasMapTypeControl()); + $this->assertNull($this->controlManager->getMapTypeControl()); + } + + public function testRotateControl() + { + $this->controlManager->setRotateControl($rotateControl = $this->createRotateControlMock()); + + $this->assertTrue($this->controlManager->hasRotateControl()); + $this->assertSame($rotateControl, $this->controlManager->getRotateControl()); + } + + public function testResetRotateControl() + { + $this->controlManager->setRotateControl($this->createRotateControlMock()); + $this->controlManager->setRotateControl(null); + + $this->assertFalse($this->controlManager->hasRotateControl()); + $this->assertNull($this->controlManager->getRotateControl()); + } + + public function testScaleControl() + { + $this->controlManager->setScaleControl($scaleControl = $this->createScaleControlMock()); + + $this->assertTrue($this->controlManager->hasScaleControl()); + $this->assertSame($scaleControl, $this->controlManager->getScaleControl()); + } + + public function testResetScaleControl() + { + $this->controlManager->setScaleControl($this->createScaleControlMock()); + $this->controlManager->setScaleControl(null); + + $this->assertFalse($this->controlManager->hasScaleControl()); + $this->assertNull($this->controlManager->getScaleControl()); + } + + public function testStreetViewControl() + { + $this->controlManager->setStreetViewControl($streetViewControl = $this->createStreetViewControlMock()); + + $this->assertTrue($this->controlManager->hasStreetViewControl()); + $this->assertSame($streetViewControl, $this->controlManager->getStreetViewControl()); + } + + public function testResetStreetViewControl() + { + $this->controlManager->setStreetViewControl($this->createStreetViewControlMock()); + $this->controlManager->setStreetViewControl(null); + + $this->assertFalse($this->controlManager->hasStreetViewControl()); + $this->assertNull($this->controlManager->getStreetViewControl()); + } + + public function testZoomControl() + { + $this->controlManager->setZoomControl($zoomControl = $this->createZoomControlMock()); + + $this->assertTrue($this->controlManager->hasZoomControl()); + $this->assertSame($zoomControl, $this->controlManager->getZoomControl()); + } + + public function testResetZoomControl() + { + $this->controlManager->setZoomControl($this->createZoomControlMock()); + $this->controlManager->setZoomControl(null); + + $this->assertFalse($this->controlManager->hasZoomControl()); + $this->assertNull($this->controlManager->getZoomControl()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Map + */ + private function createMapMock() + { + return $this->createMock(Map::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MapTypeControl + */ + private function createMapTypeControlMock() + { + return $this->createMock(MapTypeControl::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RotateControl + */ + private function createRotateControlMock() + { + return $this->createMock(RotateControl::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ScaleControl + */ + private function createScaleControlMock() + { + return $this->createMock(ScaleControl::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|StreetViewControl + */ + private function createStreetViewControlMock() + { + return $this->createMock(StreetViewControl::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ZoomControl + */ + private function createZoomControlMock() + { + return $this->createMock(ZoomControl::class); + } +} diff --git a/tests/Control/MapTypeControlTest.php b/tests/Control/MapTypeControlTest.php new file mode 100644 index 00000000..2357c966 --- /dev/null +++ b/tests/Control/MapTypeControlTest.php @@ -0,0 +1,107 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\MapTypeControl; +use Ivory\GoogleMap\Control\MapTypeControlStyle; +use Ivory\GoogleMap\MapTypeId; + +/** + * @author GeLo + */ +class MapTypeControlTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapTypeControl + */ + private $mapTypeControl; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapTypeControl = new MapTypeControl(); + } + + public function testDefaultState() + { + $this->assertTrue($this->mapTypeControl->hasIds()); + $this->assertSame([MapTypeId::ROADMAP, MapTypeId::SATELLITE], $this->mapTypeControl->getIds()); + $this->assertSame(ControlPosition::TOP_RIGHT, $this->mapTypeControl->getPosition()); + $this->assertSame(MapTypeControlStyle::DEFAULT_, $this->mapTypeControl->getStyle()); + } + + public function testInitialState() + { + $this->mapTypeControl = new MapTypeControl( + [], + $position = ControlPosition::LEFT_TOP, + $style = MapTypeControlStyle::HORIZONTAL_BAR + ); + + $this->assertFalse($this->mapTypeControl->hasIds()); + $this->assertEmpty($this->mapTypeControl->getIds()); + $this->assertSame($position, $this->mapTypeControl->getPosition()); + $this->assertSame($style, $this->mapTypeControl->getStyle()); + } + + public function testSetIds() + { + $this->mapTypeControl->setIds($ids = [$id = MapTypeId::HYBRID]); + $this->mapTypeControl->setIds($ids); + + $this->assertTrue($this->mapTypeControl->hasIds()); + $this->assertTrue($this->mapTypeControl->hasId($id)); + $this->assertSame($ids, $this->mapTypeControl->getIds()); + } + + public function testAddIds() + { + $this->mapTypeControl->setIds($firstIds = [MapTypeId::HYBRID]); + $this->mapTypeControl->addIds($secondIds = [MapTypeId::SATELLITE]); + + $this->assertTrue($this->mapTypeControl->hasIds()); + $this->assertSame(array_merge($firstIds, $secondIds), $this->mapTypeControl->getIds()); + } + + public function testAddId() + { + $this->mapTypeControl->addId($id = MapTypeId::HYBRID); + + $this->assertTrue($this->mapTypeControl->hasIds()); + $this->assertTrue($this->mapTypeControl->hasId($id)); + } + + public function testRemoveId() + { + $this->mapTypeControl->addId($id = MapTypeId::HYBRID); + $this->mapTypeControl->removeId($id); + + $this->assertFalse($this->mapTypeControl->hasId($id)); + } + + public function testPosition() + { + $this->mapTypeControl->setPosition($position = ControlPosition::BOTTOM_CENTER); + + $this->assertSame($position, $this->mapTypeControl->getPosition()); + } + + public function testStyle() + { + $this->mapTypeControl->setStyle($style = MapTypeControlStyle::DROPDOWN_MENU); + + $this->assertSame($style, $this->mapTypeControl->getStyle()); + } +} diff --git a/tests/Control/RotateControlTest.php b/tests/Control/RotateControlTest.php new file mode 100644 index 00000000..ba470507 --- /dev/null +++ b/tests/Control/RotateControlTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\RotateControl; + +/** + * @author GeLo + */ +class RotateControlTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var RotateControl + */ + private $rotateControl; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->rotateControl = new RotateControl(); + } + + public function testDefaultState() + { + $this->assertSame(ControlPosition::TOP_LEFT, $this->rotateControl->getPosition()); + } + + public function testInitialState() + { + $this->rotateControl = new RotateControl($position = ControlPosition::LEFT_CENTER); + + $this->assertSame($position, $this->rotateControl->getPosition()); + } + + public function testPosition() + { + $this->rotateControl->setPosition($position = ControlPosition::BOTTOM_CENTER); + + $this->assertSame($position, $this->rotateControl->getPosition()); + } +} diff --git a/tests/Control/ScaleControlTest.php b/tests/Control/ScaleControlTest.php new file mode 100644 index 00000000..ea6aa2ec --- /dev/null +++ b/tests/Control/ScaleControlTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\ScaleControl; +use Ivory\GoogleMap\Control\ScaleControlStyle; + +/** + * @author GeLo + */ +class ScaleControlTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ScaleControl + */ + private $scaleControl; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->scaleControl = new ScaleControl(); + } + + public function testDefaultState() + { + $this->assertSame(ControlPosition::BOTTOM_LEFT, $this->scaleControl->getPosition()); + $this->assertSame(ScaleControlStyle::DEFAULT_, $this->scaleControl->getStyle()); + } + + public function testInitialState() + { + $this->scaleControl = new ScaleControl( + $position = ControlPosition::BOTTOM_CENTER, + $style = ScaleControlStyle::DEFAULT_ + ); + + $this->assertSame($position, $this->scaleControl->getPosition()); + $this->assertSame($style, $this->scaleControl->getStyle()); + } + + public function testPosition() + { + $this->scaleControl->setPosition($position = ControlPosition::BOTTOM_CENTER); + + $this->assertSame($position, $this->scaleControl->getPosition()); + } + + public function testStyle() + { + $this->scaleControl->setStyle($style = ScaleControlStyle::DEFAULT_); + + $this->assertSame($style, $this->scaleControl->getStyle()); + } +} diff --git a/tests/Control/StreetViewControlTest.php b/tests/Control/StreetViewControlTest.php new file mode 100644 index 00000000..9ed85e25 --- /dev/null +++ b/tests/Control/StreetViewControlTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\StreetViewControl; + +/** + * @author GeLo + */ +class StreetViewControlTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var StreetViewControl + */ + private $streetViewControl; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->streetViewControl = new StreetViewControl(); + } + + public function testDefaultState() + { + $this->assertSame(ControlPosition::TOP_LEFT, $this->streetViewControl->getPosition()); + } + + public function testInitialState() + { + $this->streetViewControl = new StreetViewControl($position = ControlPosition::BOTTOM_CENTER); + + $this->assertSame($position, $this->streetViewControl->getPosition()); + } + + public function testPosition() + { + $this->streetViewControl->setPosition($position = ControlPosition::BOTTOM_CENTER); + + $this->assertSame($position, $this->streetViewControl->getPosition()); + } +} diff --git a/tests/Control/ZoomControlTest.php b/tests/Control/ZoomControlTest.php new file mode 100644 index 00000000..78f011b6 --- /dev/null +++ b/tests/Control/ZoomControlTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\ZoomControl; +use Ivory\GoogleMap\Control\ZoomControlStyle; + +/** + * @author GeLo + */ +class ZoomControlTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ZoomControl + */ + private $zoomControl; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->zoomControl = new ZoomControl(); + } + + public function testDefaultState() + { + $this->assertSame(ControlPosition::TOP_LEFT, $this->zoomControl->getPosition()); + $this->assertSame(ZoomControlStyle::DEFAULT_, $this->zoomControl->getStyle()); + } + + public function testInitialState() + { + $this->zoomControl = new ZoomControl( + $position = ControlPosition::BOTTOM_CENTER, + $style = ZoomControlStyle::LARGE + ); + + $this->assertSame($position, $this->zoomControl->getPosition()); + $this->assertSame($style, $this->zoomControl->getStyle()); + } + + public function testPosition() + { + $this->zoomControl->setPosition($position = ControlPosition::BOTTOM_CENTER); + + $this->assertSame($position, $this->zoomControl->getPosition()); + } + + public function testStyle() + { + $this->zoomControl->setStyle($style = ZoomControlStyle::LARGE); + + $this->assertSame($style, $this->zoomControl->getStyle()); + } +} diff --git a/tests/Controls/ControlPositionTest.php b/tests/Controls/ControlPositionTest.php deleted file mode 100644 index 502a530e..00000000 --- a/tests/Controls/ControlPositionTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; - -/** - * Control position test. - * - * @author GeLo - */ -class ControlPositionTest extends \PHPUnit_Framework_TestCase -{ - public function testControlPositions() - { - $expected = array( - ControlPosition::BOTTOM_CENTER, - ControlPosition::BOTTOM_LEFT, - ControlPosition::BOTTOM_RIGHT, - ControlPosition::LEFT_BOTTOM, - ControlPosition::LEFT_CENTER, - ControlPosition::LEFT_TOP, - ControlPosition::RIGHT_BOTTOM, - ControlPosition::RIGHT_CENTER, - ControlPosition::RIGHT_TOP, - ControlPosition::TOP_CENTER, - ControlPosition::TOP_LEFT, - ControlPosition::TOP_RIGHT - ); - - $this->assertSame($expected, ControlPosition::getControlPositions()); - } -} diff --git a/tests/Controls/MapTypeControlStyleTest.php b/tests/Controls/MapTypeControlStyleTest.php deleted file mode 100644 index 5d86ede4..00000000 --- a/tests/Controls/MapTypeControlStyleTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\MapTypeControlStyle; - -/** - * Map type control style test. - * - * @author GeLo - */ -class MapTypeControlStyleTest extends \PHPUnit_Framework_TestCase -{ - public function testMapTypeControlStyles() - { - $expected = array( - MapTypeControlStyle::DEFAULT_, - MapTypeControlStyle::DROPDOWN_MENU, - MapTypeControlStyle::HORIZONTAL_BAR - ); - - $this->assertSame($expected, MapTypeControlStyle::getMapTypeControlStyles()); - } -} diff --git a/tests/Controls/MapTypeControlTest.php b/tests/Controls/MapTypeControlTest.php deleted file mode 100644 index 5ba75bc6..00000000 --- a/tests/Controls/MapTypeControlTest.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControl; -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\MapTypeId; - -/** - * Map type control test. - * - * @author GeLo - */ -class MapTypeControlTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Controls\MapTypeControl */ - protected $mapTypeControl; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->mapTypeControl = new MapTypeControl(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->mapTypeControl); - } - - public function testDefaultState() - { - $this->assertSame(array(MapTypeId::ROADMAP, MapTypeId::SATELLITE), $this->mapTypeControl->getMapTypeIds()); - $this->assertSame(ControlPosition::TOP_RIGHT, $this->mapTypeControl->getControlPosition()); - $this->assertSame(MapTypeControlStyle::DEFAULT_, $this->mapTypeControl->getMapTypeControlStyle()); - } - - public function testInitialState() - { - $mapTypeIds = array(MapTypeId::HYBRID); - $controlPosition = ControlPosition::LEFT_TOP; - $mapTypeControlStyle = MapTypeControlStyle::HORIZONTAL_BAR; - - $this->mapTypeControl = new MapTypeControl($mapTypeIds, $controlPosition, $mapTypeControlStyle); - - $this->assertSame($mapTypeIds, $this->mapTypeControl->getMapTypeIds()); - $this->assertSame($controlPosition, $this->mapTypeControl->getControlPosition()); - $this->assertSame($mapTypeControlStyle, $this->mapTypeControl->getMapTypeControlStyle()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - * @expectedExceptionMessage The map type id can only be : hybrid, roadmap, satellite, terrain. - */ - public function testMapTypeIdWithInvalidValue() - { - $this->mapTypeControl->addMapTypeId('foo'); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - * @expectedExceptionMessage The control position can only be : bottom_center, bottom_left, bottom_right, - * left_bottom, left_center, left_top, right_bottom, right_center, right_top, top_center, top_left, top_right. - */ - public function testControlPositionWithInvalidValue() - { - $this->mapTypeControl->setControlPosition('foo'); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - * @expectedExceptionMessage The map type control style can only be : default, dropdown_menu, horizontal_bar. - */ - public function testMapTypeControlStyleWithInvalidValue() - { - $this->mapTypeControl->setMapTypeControlStyle('foo'); - } -} diff --git a/tests/Controls/OverviewMapControlTest.php b/tests/Controls/OverviewMapControlTest.php deleted file mode 100644 index bab1ef5e..00000000 --- a/tests/Controls/OverviewMapControlTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\OverviewMapControl; - -/** - * Overview map control test. - * - * @author GeLo - */ -class OverviewMapControlTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Controls\OverviewMapControl */ - protected $overviewMapControl; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->overviewMapControl = new OverviewMapControl(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->overviewMapControl); - } - - public function testDefaultState() - { - $this->assertFalse($this->overviewMapControl->isOpened()); - } - - public function testInitialState() - { - $this->overviewMapControl = new OverviewMapControl(true); - - $this->assertTrue($this->overviewMapControl->isOpened()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - * @expectedExceptionMessage The opened property of an overview map control must be a boolean value. - */ - public function testOpenedWithInvalidValue() - { - $this->overviewMapControl->setOpened('foo'); - } -} diff --git a/tests/Controls/PanControlTest.php b/tests/Controls/PanControlTest.php deleted file mode 100644 index bed10d3d..00000000 --- a/tests/Controls/PanControlTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\PanControl; - -/** - * Pan control test. - * - * @author GeLo - */ -class PanControlTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Controls\PanControl */ - protected $panControl; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->panControl = new PanControl(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->panControl); - } - - public function testDefaultState() - { - $this->assertSame(ControlPosition::TOP_LEFT, $this->panControl->getControlPosition()); - } - - public function testInitialState() - { - $this->panControl = new PanControl(ControlPosition::LEFT_CENTER); - - $this->assertSame(ControlPosition::LEFT_CENTER, $this->panControl->getControlPosition()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - */ - public function testControlPositionWithInvalidValue() - { - $this->panControl->setControlPosition('foo'); - } -} diff --git a/tests/Controls/RotateControlTest.php b/tests/Controls/RotateControlTest.php deleted file mode 100644 index 77c3d677..00000000 --- a/tests/Controls/RotateControlTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\RotateControl; - -/** - * Rotate control test. - * - * @author GeLo - */ -class RotateControlTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Controls\RotateControl */ - protected $rotateControl; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->rotateControl = new RotateControl(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->rotateControl); - } - - public function testDefaultState() - { - $this->assertSame(ControlPosition::TOP_LEFT, $this->rotateControl->getControlPosition()); - } - - public function testInitialState() - { - $this->rotateControl = new RotateControl(ControlPosition::LEFT_CENTER); - - $this->assertSame(ControlPosition::LEFT_CENTER, $this->rotateControl->getControlPosition()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - */ - public function testControlPositionWithInvalidValue() - { - $this->rotateControl->setControlPosition('foo'); - } -} diff --git a/tests/Controls/ScaleControlTest.php b/tests/Controls/ScaleControlTest.php deleted file mode 100644 index e81c1ad4..00000000 --- a/tests/Controls/ScaleControlTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ScaleControl; -use Ivory\GoogleMap\Controls\ScaleControlStyle; - -/** - * Scale control test. - * - * @author GeLo - */ -class ScaleControlTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Controls\ScaleControl */ - protected $scaleControl; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->scaleControl = new ScaleControl(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->scaleControl); - } - - public function testDefaultState() - { - $this->assertSame(ControlPosition::BOTTOM_LEFT, $this->scaleControl->getControlPosition()); - $this->assertSame(ScaleControlStyle::DEFAULT_, $this->scaleControl->getScaleControlStyle()); - } - - public function testInitialState() - { - $this->scaleControl = new ScaleControl(ControlPosition::BOTTOM_CENTER, ScaleControlStyle::DEFAULT_); - - $this->assertSame(ControlPosition::BOTTOM_CENTER, $this->scaleControl->getControlPosition()); - $this->assertSame(ScaleControlStyle::DEFAULT_, $this->scaleControl->getScaleControlStyle()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - */ - public function testControlPositionWithInvalidValue() - { - $this->scaleControl->setControlPosition('foo'); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - * @expectedExceptionMessage The scale control style of a scale control can only be : default. - */ - public function testScaleControlStyleWithInvalidValue() - { - $this->scaleControl->setScaleControlStyle('foo'); - } -} diff --git a/tests/Controls/StreetViewControlTest.php b/tests/Controls/StreetViewControlTest.php deleted file mode 100644 index b2b244e4..00000000 --- a/tests/Controls/StreetViewControlTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\StreetViewControl; - -/** - * Street view control test. - * - * @author GeLo - */ -class StreetViewControlTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Controls\StreetViewControl */ - protected $streetViewControl; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->streetViewControl = new StreetViewControl(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->streetViewControl); - } - - public function testDefaultState() - { - $this->assertSame(ControlPosition::TOP_LEFT, $this->streetViewControl->getControlPosition()); - } - - public function testInitialState() - { - $this->streetViewControl = new StreetViewControl(ControlPosition::BOTTOM_CENTER); - - $this->assertSame(ControlPosition::BOTTOM_CENTER, $this->streetViewControl->getControlPosition()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - */ - public function testControlPositionWithInvalidValue() - { - $this->streetViewControl->setControlPosition('foo'); - } -} diff --git a/tests/Controls/ZoomControlStyleTest.php b/tests/Controls/ZoomControlStyleTest.php deleted file mode 100644 index 085ec748..00000000 --- a/tests/Controls/ZoomControlStyleTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\ZoomControlStyle; - -/** - * Zoom control style test. - * - * @author GeLo - */ -class ZoomControlStyleTest extends \PHPUnit_Framework_TestCase -{ - public function testZoomControlStyles() - { - $expected = array( - ZoomControlStyle::DEFAULT_, - ZoomControlStyle::LARGE, - ZoomControlStyle::SMALL, - ); - - $this->assertSame($expected, ZoomControlStyle::getZoomControlStyles()); - } -} diff --git a/tests/Controls/ZoomControlTest.php b/tests/Controls/ZoomControlTest.php deleted file mode 100644 index 7aa8dd55..00000000 --- a/tests/Controls/ZoomControlTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ZoomControl; -use Ivory\GoogleMap\Controls\ZoomControlStyle; - -/** - * Zoom control test. - * - * @author GeLo - */ -class ZoomControlTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Controls\ZoomControl */ - protected $zoomControl; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->zoomControl = new ZoomControl(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->zoomControl); - } - - public function testDefaultState() - { - $this->assertSame(ControlPosition::TOP_LEFT, $this->zoomControl->getControlPosition()); - $this->assertSame(ZoomControlStyle::DEFAULT_, $this->zoomControl->getZoomControlStyle()); - } - - public function testInitialState() - { - $this->zoomControl = new ZoomControl(ControlPosition::BOTTOM_CENTER, ZoomControlStyle::LARGE); - - $this->assertSame(ControlPosition::BOTTOM_CENTER, $this->zoomControl->getControlPosition()); - $this->assertSame(ZoomControlStyle::LARGE, $this->zoomControl->getZoomControlStyle()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - */ - public function testControlPositionWithInvalidValue() - { - $this->zoomControl->setControlPosition('foo'); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ControlException - * @expectedExceptionMessage The zoom control style of a zoom control can only be : default, large, small. - */ - public function testZoomControlStyleWithInvalidValue() - { - $this->zoomControl->setZoomControlStyle('foo'); - } -} diff --git a/tests/Event/EventManagerTest.php b/tests/Event/EventManagerTest.php new file mode 100644 index 00000000..b8a44717 --- /dev/null +++ b/tests/Event/EventManagerTest.php @@ -0,0 +1,242 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Event\EventManager; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class EventManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EventManager + */ + private $eventManager; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->eventManager = new EventManager(); + } + + public function testDefaultState() + { + $this->assertFalse($this->eventManager->hasMap()); + $this->assertNull($this->eventManager->getMap()); + $this->assertFalse($this->eventManager->hasDomEvents()); + $this->assertEmpty($this->eventManager->getDomEvents()); + $this->assertFalse($this->eventManager->hasDomEventsOnce()); + $this->assertEmpty($this->eventManager->getDomEventsOnce()); + $this->assertFalse($this->eventManager->hasEvents()); + $this->assertEmpty($this->eventManager->getEvents()); + $this->assertFalse($this->eventManager->hasEventsOnce()); + $this->assertEmpty($this->eventManager->getEventsOnce()); + } + + public function testMap() + { + $map = $this->createMapMock(); + $map + ->expects($this->once()) + ->method('getEventManager') + ->will($this->returnValue(null)); + + $map + ->expects($this->once()) + ->method('setEventManager') + ->with($this->identicalTo($this->eventManager)); + + $this->eventManager->setMap($map); + + $this->assertTrue($this->eventManager->hasMap()); + $this->assertSame($map, $this->eventManager->getMap()); + } + + public function testSetDomEvents() + { + $this->eventManager->setDomEvents($domEvents = [$domEvent = $this->createEventMock()]); + $this->eventManager->setDomEvents($domEvents); + + $this->assertTrue($this->eventManager->hasDomEvents()); + $this->assertTrue($this->eventManager->hasDomEvent($domEvent)); + $this->assertSame($domEvents, $this->eventManager->getDomEvents()); + } + + public function testAddDomEvents() + { + $this->eventManager->setDomEvents($firstDomEvents = [$this->createEventMock()]); + $this->eventManager->addDomEvents($secondDomEvents = [$this->createEventMock()]); + + $this->assertTrue($this->eventManager->hasDomEvents()); + $this->assertSame(array_merge($firstDomEvents, $secondDomEvents), $this->eventManager->getDomEvents()); + } + + public function testAddDomEvent() + { + $this->eventManager->addDomEvent($domEvent = $this->createEventMock()); + + $this->assertTrue($this->eventManager->hasDomEvents()); + $this->assertTrue($this->eventManager->hasDomEvent($domEvent)); + $this->assertSame([$domEvent], $this->eventManager->getDomEvents()); + } + + public function testRemoveDomEvent() + { + $this->eventManager->addDomEvent($domEvent = $this->createEventMock()); + $this->eventManager->removeDomEvent($domEvent); + + $this->assertFalse($this->eventManager->hasDomEvents()); + $this->assertFalse($this->eventManager->hasDomEvent($domEvent)); + $this->assertEmpty($this->eventManager->getDomEvents()); + } + + public function testSetDomEventsOnce() + { + $this->eventManager->setDomEventsOnce($domEventsOnce = [$domEventOnce = $this->createEventMock()]); + $this->eventManager->setDomEventsOnce($domEventsOnce); + + $this->assertTrue($this->eventManager->hasDomEventsOnce()); + $this->assertTrue($this->eventManager->hasDomEventOnce($domEventOnce)); + $this->assertSame($domEventsOnce, $this->eventManager->getDomEventsOnce()); + } + + public function testAddDomEventsOnce() + { + $this->eventManager->setDomEventsOnce($firstDomEventsOnce = [$this->createEventMock()]); + $this->eventManager->addDomEventsOnce($secondDomEventsOnce = [$this->createEventMock()]); + + $this->assertTrue($this->eventManager->hasDomEventsOnce()); + $this->assertSame( + array_merge($firstDomEventsOnce, $secondDomEventsOnce), + $this->eventManager->getDomEventsOnce() + ); + } + + public function testAddDomEventOnce() + { + $this->eventManager->addDomEventOnce($domEventOnce = $this->createEventMock()); + + $this->assertTrue($this->eventManager->hasDomEventsOnce()); + $this->assertTrue($this->eventManager->hasDomEventOnce($domEventOnce)); + $this->assertSame([$domEventOnce], $this->eventManager->getDomEventsOnce()); + } + + public function testRemoveDomEventOnce() + { + $this->eventManager->addDomEventOnce($domEventOnce = $this->createEventMock()); + $this->eventManager->removeDomEventOnce($domEventOnce); + + $this->assertFalse($this->eventManager->hasDomEventsOnce()); + $this->assertFalse($this->eventManager->hasDomEventOnce($domEventOnce)); + $this->assertEmpty($this->eventManager->getDomEventsOnce()); + } + + public function testSetEvents() + { + $this->eventManager->setEvents($events = [$event = $this->createEventMock()]); + $this->eventManager->setEvents($events); + + $this->assertTrue($this->eventManager->hasEvents()); + $this->assertTrue($this->eventManager->hasEvent($event)); + $this->assertSame($events, $this->eventManager->getEvents()); + } + + public function testAddEvents() + { + $this->eventManager->setEvents($firstEvents = [$this->createEventMock()]); + $this->eventManager->addEvents($secondEvents = [$this->createEventMock()]); + + $this->assertTrue($this->eventManager->hasEvents()); + $this->assertSame(array_merge($firstEvents, $secondEvents), $this->eventManager->getEvents()); + } + + public function testAddEvent() + { + $this->eventManager->addEvent($event = $this->createEventMock()); + + $this->assertTrue($this->eventManager->hasEvents()); + $this->assertTrue($this->eventManager->hasEvent($event)); + $this->assertSame([$event], $this->eventManager->getEvents()); + } + + public function testRemoveEvent() + { + $this->eventManager->addEvent($event = $this->createEventMock()); + $this->eventManager->removeEvent($event); + + $this->assertFalse($this->eventManager->hasEvents()); + $this->assertFalse($this->eventManager->hasEvent($event)); + $this->assertEmpty($this->eventManager->getEvents()); + } + + public function testSetEventsOnce() + { + $this->eventManager->setEventsOnce($eventsOnce = [$eventOnce = $this->createEventMock()]); + $this->eventManager->setEventsOnce($eventsOnce); + + $this->assertTrue($this->eventManager->hasEventsOnce()); + $this->assertTrue($this->eventManager->hasEventOnce($eventOnce)); + $this->assertSame($eventsOnce, $this->eventManager->getEventsOnce()); + } + + public function testAddEventsOnce() + { + $this->eventManager->setEventsOnce($firstEventsOnce = [$this->createEventMock()]); + $this->eventManager->addEventsOnce($secondEventsOnce = [$this->createEventMock()]); + + $this->assertTrue($this->eventManager->hasEventsOnce()); + $this->assertSame( + array_merge($firstEventsOnce, $secondEventsOnce), + $this->eventManager->getEventsOnce() + ); + } + + public function testAddEventOnce() + { + $this->eventManager->addEventOnce($eventOnce = $this->createEventMock()); + + $this->assertTrue($this->eventManager->hasEventsOnce()); + $this->assertTrue($this->eventManager->hasEventOnce($eventOnce)); + $this->assertSame([$eventOnce], $this->eventManager->getEventsOnce()); + } + + public function testRemoveEventOnce() + { + $this->eventManager->addEventOnce($eventOnce = $this->createEventMock()); + $this->eventManager->removeEventOnce($eventOnce); + + $this->assertFalse($this->eventManager->hasEventsOnce()); + $this->assertFalse($this->eventManager->hasEventOnce($eventOnce)); + $this->assertEmpty($this->eventManager->getEventsOnce()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Map + */ + private function createMapMock() + { + return $this->createMock(Map::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Event + */ + private function createEventMock() + { + return $this->createMock(Event::class); + } +} diff --git a/tests/Event/EventTest.php b/tests/Event/EventTest.php new file mode 100644 index 00000000..2cdb51b5 --- /dev/null +++ b/tests/Event/EventTest.php @@ -0,0 +1,107 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Event\MouseEvent; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class EventTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Event + */ + private $event; + + /** + * @var string + */ + private $instance; + + /** + * @var string + */ + private $trigger; + + /** + * @var string + */ + private $handle; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->event = new Event( + $this->instance = 'instance', + $this->trigger = MouseEvent::CLICK, + $this->handle = 'function () {}' + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(VariableAwareInterface::class, $this->event); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('event', $this->event->getVariable()); + $this->assertSame($this->instance, $this->event->getInstance()); + $this->assertSame($this->trigger, $this->event->getTrigger()); + $this->assertSame($this->handle, $this->event->getHandle()); + $this->assertFalse($this->event->isCapture()); + } + + public function testInitialState() + { + $this->event = new Event($this->instance, $this->trigger, $this->handle, true); + + $this->assertStringStartsWith('event', $this->event->getVariable()); + $this->assertSame($this->instance, $this->event->getInstance()); + $this->assertSame($this->trigger, $this->event->getTrigger()); + $this->assertSame($this->handle, $this->event->getHandle()); + $this->assertTrue($this->event->isCapture()); + } + + public function testInstance() + { + $this->event->setInstance($instance = 'foo'); + + $this->assertSame($instance, $this->event->getInstance()); + } + + public function testTrigger() + { + $this->event->setTrigger($trigger = MouseEvent::DBLCLICK); + + $this->assertSame($trigger, $this->event->getTrigger()); + } + + public function testHandle() + { + $this->event->setHandle($handle = 'function () { alert("handle"); }'); + + $this->assertSame($handle, $this->event->getHandle()); + } + + public function testCaptureWithValidValue() + { + $this->event->setCapture(true); + + $this->assertTrue($this->event->isCapture()); + } +} diff --git a/tests/Events/EventManagerTest.php b/tests/Events/EventManagerTest.php deleted file mode 100644 index a59a16fa..00000000 --- a/tests/Events/EventManagerTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Events; - -use Ivory\GoogleMap\Events\EventManager; - -/** - * Event manager test. - * - * @author GeLo - */ -class EventManagerTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Events\EventManager */ - protected $eventManager; - - /** @var \Ivory\GoogleMap\Events\Event */ - protected $eventMock; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->eventManager = new EventManager(); - $this->eventMock = $this->getMock('Ivory\GoogleMap\Events\Event'); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->eventManager); - unset($this->eventMock); - } - - public function testDefaultState() - { - $this->assertEmpty($this->eventManager->getDomEvents()); - $this->assertEmpty($this->eventManager->getDomEventsOnce()); - $this->assertEmpty($this->eventManager->getEvents()); - $this->assertEmpty($this->eventManager->getEventsOnce()); - } - - public function testInitialState() - { - $domEvents = array($this->getMock('Ivory\GoogleMap\Events\Event')); - $domEventsOnce = array($this->getMock('Ivory\GoogleMap\Events\Event')); - $events = array($this->getMock('Ivory\GoogleMap\Events\Event')); - $eventsOnce = array($this->getMock('Ivory\GoogleMap\Events\Event')); - - $this->eventManager = new EventManager($domEvents, $domEventsOnce, $events, $eventsOnce); - - $this->assertSame($domEvents, $this->eventManager->getDomEvents()); - $this->assertSame($domEventsOnce, $this->eventManager->getDomEventsOnce()); - $this->assertSame($events, $this->eventManager->getEvents()); - $this->assertSame($eventsOnce, $this->eventManager->getEventsOnce()); - } - - public function testDomEvent() - { - $this->eventManager->addDomEvent($this->eventMock); - - $this->assertSame(array($this->eventMock), $this->eventManager->getDomEvents()); - } - - public function testDomEventOnce() - { - $this->eventManager->addDomEventOnce($this->eventMock); - - $this->assertSame(array($this->eventMock), $this->eventManager->getDomEventsOnce()); - } - - public function testEvent() - { - $this->eventManager->addEvent($this->eventMock); - - $this->assertSame(array($this->eventMock), $this->eventManager->getEvents()); - } - - public function testEventOnce() - { - $this->eventManager->addEventOnce($this->eventMock); - - $this->assertSame(array($this->eventMock), $this->eventManager->getEventsOnce()); - } -} diff --git a/tests/Events/EventTest.php b/tests/Events/EventTest.php deleted file mode 100644 index da57662b..00000000 --- a/tests/Events/EventTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Events; - -use Ivory\GoogleMap\Events\Event; - -/** - * Event test. - * - * @author GeLo - */ -class EventTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Events\Event */ - protected $event; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->event = new Event(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->event); - } - - public function testDefaultState() - { - $this->assertNull($this->event->getInstance()); - $this->assertNull($this->event->getEventName()); - $this->assertNull($this->event->getHandle()); - $this->assertFalse($this->event->isCapture()); - } - - public function testInitialState() - { - $this->event = new Event('foo', 'bar', 'baz', true); - - $this->assertSame('foo', $this->event->getInstance()); - $this->assertSame('bar', $this->event->getEventName()); - $this->assertSame('baz', $this->event->getHandle()); - $this->assertTrue($this->event->isCapture()); - } - - public function testInstanceWithValidValue() - { - $this->event->setInstance('foo'); - - $this->assertSame('foo', $this->event->getInstance()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\EventException - * @expectedExceptionMessage The instance of an event must be a string value. - */ - public function testInstanceWithInvalidValue() - { - $this->event->setInstance(true); - } - - public function testEventNameWithValidValue() - { - $this->event->setEventName('foo'); - - $this->assertSame('foo', $this->event->getEventName()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\EventException - * @expectedExceptionMessage The event name of an event must be a string value. - */ - public function testEventNameWithInvalidValue() - { - $this->event->setEventName(true); - } - - public function testHandleWithValidValue() - { - $this->event->setHandle('foo'); - - $this->assertSame('foo', $this->event->getHandle()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\EventException - * @expectedExceptionMessage The handle of an event must be a string value. - */ - public function testHandleWithInvalidValue() - { - $this->event->setHandle(true); - } - - public function testCaptureWithValidValue() - { - $this->event->setCapture(true); - - $this->assertTrue($this->event->isCapture()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\EventException - * @expectedExceptionMessage The capture property of an event must be a boolean value. - */ - public function testCaptureWithInvalidValue() - { - $this->event->setCapture('foo'); - } -} diff --git a/tests/Events/MouseEventTest.php b/tests/Events/MouseEventTest.php deleted file mode 100644 index 53c49be0..00000000 --- a/tests/Events/MouseEventTest.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Events; - -use Ivory\GoogleMap\Events\MouseEvent; - -/** - * Mouse event test. - * - * @author GeLo - */ -class MouseEventTest extends \PHPUnit_Framework_TestCase -{ - public function testMouseEvents() - { - $expected = array( - MouseEvent::CLICK, - MouseEvent::DBLCLICK, - MouseEvent::MOUSEUP, - MouseEvent::MOUSEDOWN, - MouseEvent::MOUSEOVER, - MouseEvent::MOUSEOUT, - ); - - $this->assertSame($expected, MouseEvent::getMouseEvents()); - } -} diff --git a/tests/Helper/AbstractHelperTest.php b/tests/Helper/AbstractHelperTest.php deleted file mode 100644 index e319115a..00000000 --- a/tests/Helper/AbstractHelperTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper; - -/** - * Abstract helper test. - * - * @author GeLo - */ -class AbstractHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\AbstractHelper */ - protected $helper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->helper = $this->getMockForAbstractClass('Ivory\GoogleMap\Helper\AbstractHelper'); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->helper); - } - - public function testInitialState() - { - $this->assertInstanceOf('Ivory\JsonBuilder\JsonBuilder', $this->helper->getJsonBuilder()); - } - - public function testJsContainerName() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('foo')); - - $method = new \ReflectionMethod($this->helper, 'getJsContainerName'); - $method->setAccessible(true); - - $this->assertSame('foo_container', $method->invoke($this->helper, $map)); - } -} diff --git a/tests/Helper/ApiHelperTest.php b/tests/Helper/ApiHelperTest.php deleted file mode 100644 index e49a9255..00000000 --- a/tests/Helper/ApiHelperTest.php +++ /dev/null @@ -1,135 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper; - -use Ivory\GoogleMap\Helper\ApiHelper; - -/** - * Api helper test. - * - * @author GeLo - */ -class ApiHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\ApiHelper */ - protected $apiHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->apiHelper = new ApiHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->apiHelper); - } - - public function testDefaultState() - { - $this->assertFalse($this->apiHelper->isLoaded()); - } - - public function testLoaded() - { - $this->apiHelper->render(); - - $this->assertTrue($this->apiHelper->isLoaded()); - - $this->apiHelper->isLoaded(false); - - $this->assertFalse($this->apiHelper->isLoaded()); - } - - public function testRenderWithDefaultValues() - { - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - -EOF; - - $this->assertSame($expected, $this->apiHelper->render()); - } - - public function testRenderWithLanguage() - { - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=fr&sensor=false"}); }; - - - -EOF; - - $this->assertSame($expected, $this->apiHelper->render('fr')); - } - - public function testRenderWithoutLibraries() - { - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - -EOF; - - $this->assertSame($expected, $this->apiHelper->render('en', array())); - } - - public function testRenderWithLibraries() - { - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"libraries=geometry,places&language=en&sensor=false"}); }; - - - -EOF; - - $this->assertSame($expected, $this->apiHelper->render('en', array('geometry', 'places'))); - } - - public function testRenderWithCallback() - { - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false","callback":callback}); }; - - - -EOF; - - $this->assertSame($expected, $this->apiHelper->render('en', array(), 'callback')); - } - - public function testRenderWithSensor() - { - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=true"}); }; - - - -EOF; - - $this->assertSame($expected, $this->apiHelper->render('en', array(), null, true)); - } -} diff --git a/tests/Helper/Base/BoundHelperTest.php b/tests/Helper/Base/BoundHelperTest.php deleted file mode 100644 index 1f976edc..00000000 --- a/tests/Helper/Base/BoundHelperTest.php +++ /dev/null @@ -1,146 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Base; - -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Helper\Base\BoundHelper; - -/** - * Bound helper test - * - * @author GeLo - */ -class BoundHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Base\BoundHelper */ - protected $boundHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->boundHelper = new BoundHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->boundHelper); - } - - public function testRenderWithEmptyBound() - { - $bound = new Bound(); - $bound->setJavascriptVariable('foo'); - - $this->assertSame('foo = new google.maps.LatLngBounds();'.PHP_EOL, $this->boundHelper->render($bound)); - } - - public function testRenderWithBound() - { - $coordinate1 = new Coordinate(-1.1, -2.1, false); - $coordinate1->setJavascriptVariable('foo'); - - $coordinate2 = new Coordinate(1.1, 2.1, true); - $coordinate2->setJavascriptVariable('bar'); - - $bound = new Bound($coordinate1, $coordinate2); - $bound->setJavascriptVariable('baz'); - - $this->assertSame('baz = new google.maps.LatLngBounds(foo, bar);'.PHP_EOL, $this->boundHelper->render($bound)); - } - - public function testRenderExtends() - { - $bound = new Bound(); - $bound->setJavascriptVariable('bound'); - - $circle = $this->getMock('Ivory\GoogleMap\Overlays\Circle'); - $circle - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('circle')); - - $groundOverlayBound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $groundOverlayBound - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('groundOverlayBound')); - - $groundOverlay = $this->getMock('Ivory\GoogleMap\Overlays\GroundOverlay'); - $groundOverlay - ->expects($this->once()) - ->method('getBound') - ->will($this->returnValue($groundOverlayBound)); - - $infoWindow = $this->getMock('Ivory\GoogleMap\Overlays\InfoWindow'); - $infoWindow - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('infoWindow')); - - $marker = $this->getMock('Ivory\GoogleMap\Overlays\Marker'); - $marker - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('marker')); - - $polygon = $this->getMock('Ivory\GoogleMap\Overlays\Polygon'); - $polygon - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('polygon')); - - $polyline = $this->getMock('Ivory\GoogleMap\Overlays\Polyline'); - $polyline - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('polyline')); - - $rectangleBound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $rectangleBound - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('rectangleBound')); - - $rectangle = $this->getMock('Ivory\GoogleMap\Overlays\Rectangle'); - $rectangle - ->expects($this->once()) - ->method('getBound') - ->will($this->returnValue($rectangleBound)); - - $bound->extend($circle); - $bound->extend($groundOverlay); - $bound->extend($infoWindow); - $bound->extend($marker); - $bound->extend($polygon); - $bound->extend($polyline); - $bound->extend($rectangle); - - $expected = <<assertSame($expected, $this->boundHelper->renderExtends($bound)); - } -} diff --git a/tests/Helper/Base/CoordinateHelperTest.php b/tests/Helper/Base/CoordinateHelperTest.php deleted file mode 100644 index cd146cdc..00000000 --- a/tests/Helper/Base/CoordinateHelperTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Base; - -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Helper\Base\CoordinateHelper; - -/** - * Coordinate helper test - * - * @author GeLo - */ -class CoordinateHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Base\CoordinateHelper */ - protected $coordinateHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->coordinateHelper = new CoordinateHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->coordinateHelper); - } - - public function testRender() - { - $coordinate = new Coordinate(1.1, 2.1, true); - $coordinate->setJavascriptVariable('foo'); - - $this->assertSame( - 'foo = new google.maps.LatLng(1.1, 2.1, true);'.PHP_EOL, - $this->coordinateHelper->render($coordinate) - ); - } -} diff --git a/tests/Helper/Base/PointHelperTest.php b/tests/Helper/Base/PointHelperTest.php deleted file mode 100644 index 5311443d..00000000 --- a/tests/Helper/Base/PointHelperTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Base; - -use Ivory\GoogleMap\Base\Point; -use Ivory\GoogleMap\Helper\Base\PointHelper; - -/** - * Point helper test. - * - * @author GeLo - */ -class PointHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Base\PointHelper */ - protected $pointHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->pointHelper = new PointHelper(); - } - - public function testRender() - { - $point = new Point(1.1, 2.1); - $point->setJavascriptVariable('foo'); - - $this->assertSame('foo = new google.maps.Point(1.1, 2.1);'.PHP_EOL, $this->pointHelper->render($point)); - } -} diff --git a/tests/Helper/Base/SizeHelperTest.php b/tests/Helper/Base/SizeHelperTest.php deleted file mode 100644 index 9c1b7df8..00000000 --- a/tests/Helper/Base/SizeHelperTest.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Base; - -use Ivory\GoogleMap\Base\Size; -use Ivory\GoogleMap\Helper\Base\SizeHelper; - -/** - * Size helper test. - * - * @author GeLo - */ -class SizeHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Base\SizeHelper */ - protected $sizeHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->sizeHelper = new SizeHelper(); - } - - public function testRenderWithoutUnits() - { - $size = new Size(1.1, 2.1); - $size->setJavascriptVariable('foo'); - - $this->assertSame('foo = new google.maps.Size(1.1, 2.1);'.PHP_EOL, $this->sizeHelper->render($size)); - } - - public function testRenderWithUnits() - { - $size = new Size(1.1, 2.1, 'px', '%'); - $size->setJavascriptVariable('foo'); - - $this->assertSame('foo = new google.maps.Size(1.1, 2.1, "px", "%");'.PHP_EOL, $this->sizeHelper->render($size)); - } -} diff --git a/tests/Helper/Builder/ApiHelperBuilderTest.php b/tests/Helper/Builder/ApiHelperBuilderTest.php new file mode 100644 index 00000000..8521d7d4 --- /dev/null +++ b/tests/Helper/Builder/ApiHelperBuilderTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Builder; + +use Ivory\GoogleMap\Helper\ApiHelper; +use Ivory\GoogleMap\Helper\Builder\AbstractHelperBuilder; +use Ivory\GoogleMap\Helper\Builder\ApiHelperBuilder; + +/** + * @author GeLo + */ +class ApiHelperBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ApiHelperBuilder + */ + private $apiHelperBuilder; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->apiHelperBuilder = ApiHelperBuilder::create(); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractHelperBuilder::class, $this->apiHelperBuilder); + } + + public function testBuild() + { + $this->assertInstanceOf(ApiHelper::class, $this->apiHelperBuilder->build()); + } +} diff --git a/tests/Helper/Builder/HelperBuilderTest.php b/tests/Helper/Builder/HelperBuilderTest.php new file mode 100644 index 00000000..472faf6f --- /dev/null +++ b/tests/Helper/Builder/HelperBuilderTest.php @@ -0,0 +1,146 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Builder; + +use Ivory\GoogleMap\Helper\Builder\AbstractHelperBuilder; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\JsonBuilder\JsonBuilder; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * @author GeLo + */ +class HelperBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AbstractHelperBuilder + */ + private $helperBuilder; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->helperBuilder = $this->createAbstractHelperBuilder(); + } + + public function testDefaultState() + { + $this->assertInstanceOf(Formatter::class, $this->helperBuilder->getFormatter()); + $this->assertInstanceOf(JsonBuilder::class, $this->helperBuilder->getJsonBuilder()); + $this->assertFalse($this->helperBuilder->hasSubscribers()); + $this->assertEmpty($this->helperBuilder->getSubscribers()); + } + + public function testInitialState() + { + $this->helperBuilder = $this->createAbstractHelperBuilder( + $formatter = $this->createFormatterMock(), + $jsonBuilder = $this->createJsonBuilderMock() + ); + + $this->assertSame($formatter, $this->helperBuilder->getFormatter()); + $this->assertSame($jsonBuilder, $this->helperBuilder->getJsonBuilder()); + $this->assertFalse($this->helperBuilder->hasSubscribers()); + $this->assertEmpty($this->helperBuilder->getSubscribers()); + } + + public function testFormatter() + { + $this->helperBuilder->setFormatter($formatter = $this->createFormatterMock()); + + $this->assertSame($formatter, $this->helperBuilder->getFormatter()); + } + + public function testJsonBuilder() + { + $this->helperBuilder->setJsonBuilder($jsonBuilder = $this->createJsonBuilderMock()); + + $this->assertSame($jsonBuilder, $this->helperBuilder->getJsonBuilder()); + } + + public function testSetSubscribers() + { + $this->helperBuilder->setSubscribers($subscribers = [$subscriber = $this->createEventSubscriberMock()]); + $this->helperBuilder->setSubscribers($subscribers); + + $this->assertTrue($this->helperBuilder->hasSubscribers()); + $this->assertTrue($this->helperBuilder->hasSubscriber($subscriber)); + $this->assertSame($subscribers, $this->helperBuilder->getSubscribers()); + } + + public function testAddSubscribers() + { + $this->helperBuilder->setSubscribers($firstSubscribers = [$this->createEventSubscriberMock()]); + $this->helperBuilder->addSubscribers($secondSubscribers = [$this->createEventSubscriberMock()]); + + $this->assertTrue($this->helperBuilder->hasSubscribers()); + $this->assertSame(array_merge($firstSubscribers, $secondSubscribers), $this->helperBuilder->getSubscribers()); + } + + public function testAddSubscriber() + { + $this->helperBuilder->addSubscriber($subscriber = $this->createEventSubscriberMock()); + + $this->assertTrue($this->helperBuilder->hasSubscribers()); + $this->assertTrue($this->helperBuilder->hasSubscriber($subscriber)); + $this->assertSame([$subscriber], $this->helperBuilder->getSubscribers()); + } + + public function testRemoveSubscriber() + { + $this->helperBuilder->addSubscriber($subscriber = $this->createEventSubscriberMock()); + $this->helperBuilder->removeSubscriber($subscriber); + + $this->assertFalse($this->helperBuilder->hasSubscribers()); + $this->assertFalse($this->helperBuilder->hasSubscriber($subscriber)); + $this->assertEmpty($this->helperBuilder->getSubscribers()); + } + + /** + * @param Formatter|null $formatter + * @param JsonBuilder|null $jsonBuilder + * + * @return \PHPUnit_Framework_MockObject_MockObject|AbstractHelperBuilder + */ + private function createAbstractHelperBuilder(Formatter $formatter = null, JsonBuilder $jsonBuilder = null) + { + return $this->getMockBuilder(AbstractHelperBuilder::class) + ->setConstructorArgs([$formatter, $jsonBuilder]) + ->getMockForAbstractClass(); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Formatter + */ + private function createFormatterMock() + { + return $this->createMock(Formatter::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|JsonBuilder + */ + private function createJsonBuilderMock() + { + return $this->createMock(JsonBuilder::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|EventSubscriberInterface + */ + private function createEventSubscriberMock() + { + return $this->createMock(EventSubscriberInterface::class); + } +} diff --git a/tests/Helper/Builder/MapHelperBuilderTest.php b/tests/Helper/Builder/MapHelperBuilderTest.php new file mode 100644 index 00000000..a2127e42 --- /dev/null +++ b/tests/Helper/Builder/MapHelperBuilderTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Builder; + +use Ivory\GoogleMap\Helper\Builder\AbstractHelperBuilder; +use Ivory\GoogleMap\Helper\Builder\MapHelperBuilder; +use Ivory\GoogleMap\Helper\MapHelper; + +/** + * @author GeLo + */ +class MapHelperBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapHelperBuilder + */ + private $mapHelperBuilder; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapHelperBuilder = MapHelperBuilder::create(); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractHelperBuilder::class, $this->mapHelperBuilder); + } + + public function testBuild() + { + $this->assertInstanceOf(MapHelper::class, $this->mapHelperBuilder->build()); + } +} diff --git a/tests/Helper/Builder/PlaceAutocompleteHelperBuilderTest.php b/tests/Helper/Builder/PlaceAutocompleteHelperBuilderTest.php new file mode 100644 index 00000000..21776170 --- /dev/null +++ b/tests/Helper/Builder/PlaceAutocompleteHelperBuilderTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Builder; + +use Ivory\GoogleMap\Helper\Builder\AbstractHelperBuilder; +use Ivory\GoogleMap\Helper\Builder\PlaceAutocompleteHelperBuilder; +use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper; + +/** + * @author GeLo + */ +class PlaceAutocompleteHelperBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PlaceAutocompleteHelperBuilder + */ + private $placeAutocompleteHelperBuilder; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->placeAutocompleteHelperBuilder = PlaceAutocompleteHelperBuilder::create(); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractHelperBuilder::class, $this->placeAutocompleteHelperBuilder); + } + + public function testBuild() + { + $this->assertInstanceOf(PlaceAutocompleteHelper::class, $this->placeAutocompleteHelperBuilder->build()); + } +} diff --git a/tests/Helper/Collector/Base/BoundCollectorTest.php b/tests/Helper/Collector/Base/BoundCollectorTest.php new file mode 100644 index 00000000..8d126fcd --- /dev/null +++ b/tests/Helper/Collector/Base/BoundCollectorTest.php @@ -0,0 +1,100 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Base; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Collector\Base\BoundCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\GroundOverlayCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\RectangleCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\GroundOverlay; +use Ivory\GoogleMap\Overlay\Rectangle; + +/** + * @author GeLo + */ +class BoundCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var BoundCollector + */ + private $boundCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->boundCollector = new BoundCollector(new GroundOverlayCollector(), new RectangleCollector()); + } + + public function testGroundOverlayCollector() + { + $groundOverlayCollector = $this->createGroundOverlayCollectorMock(); + $this->boundCollector->setGroundOverlayCollector($groundOverlayCollector); + + $this->assertSame($groundOverlayCollector, $this->boundCollector->getGroundOverlayCollector()); + } + + public function testRectangleCollector() + { + $rectangleCollector = $this->createRectangleCollectorMock(); + $this->boundCollector->setRectangleCollector($rectangleCollector); + + $this->assertSame($rectangleCollector, $this->boundCollector->getRectangleCollector()); + } + + public function testCollect() + { + $this->assertEmpty($this->boundCollector->collect(new Map())); + } + + public function testCollectAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + + $this->assertSame([$map->getBound()], $this->boundCollector->collect($map)); + } + + public function testCollectGroundOverlay() + { + $map = new Map(); + $map->getOverlayManager()->addGroundOverlay(new GroundOverlay('url', $bound = new Bound())); + + $this->assertSame([$bound], $this->boundCollector->collect($map)); + } + + public function testCollectRectangle() + { + $map = new Map(); + $map->getOverlayManager()->addRectangle(new Rectangle($bound = new Bound())); + + $this->assertSame([$bound], $this->boundCollector->collect($map)); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|GroundOverlayCollector + */ + private function createGroundOverlayCollectorMock() + { + return $this->createMock(GroundOverlayCollector::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RectangleCollector + */ + private function createRectangleCollectorMock() + { + return $this->createMock(RectangleCollector::class); + } +} diff --git a/tests/Helper/Collector/Base/CoordinateCollectorTest.php b/tests/Helper/Collector/Base/CoordinateCollectorTest.php new file mode 100644 index 00000000..4919b69d --- /dev/null +++ b/tests/Helper/Collector/Base/CoordinateCollectorTest.php @@ -0,0 +1,219 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Base; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Collector\Base\BoundCollector; +use Ivory\GoogleMap\Helper\Collector\Base\CoordinateCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\CircleCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\GroundOverlayCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\PolygonCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\PolylineCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\RectangleCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Circle; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\Polygon; +use Ivory\GoogleMap\Overlay\Polyline; +use Ivory\GoogleMap\Overlay\Rectangle; + +/** + * @author GeLo + */ +class CoordinateCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CoordinateCollector + */ + private $coordinateCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->coordinateCollector = new CoordinateCollector( + new BoundCollector(new GroundOverlayCollector(), new RectangleCollector()), + new CircleCollector(), + new InfoWindowCollector($markerCollector = new MarkerCollector()), + $markerCollector, + new PolygonCollector(), + new PolylineCollector() + ); + } + + public function testBoundCollector() + { + $this->coordinateCollector->setBoundCollector($boundCollector = $this->createBoundCollectorMock()); + + $this->assertSame($boundCollector, $this->coordinateCollector->getBoundCollector()); + } + + public function testCircleCollector() + { + $this->coordinateCollector->setCircleCollector($circleCollector = $this->createCircleCollectorMock()); + + $this->assertSame($circleCollector, $this->coordinateCollector->getCircleCollector()); + } + + public function testInfoWindowCollector() + { + $infoWindowCollector = $this->createInfoWindowCollectorMock(); + $this->coordinateCollector->setInfoWindowCollector($infoWindowCollector); + + $this->assertSame($infoWindowCollector, $this->coordinateCollector->getInfoWindowCollector()); + } + + public function testMarkerCollector() + { + $this->coordinateCollector->setMarkerCollector($markerCollector = $this->createMarkerCollectorMock()); + + $this->assertSame($markerCollector, $this->coordinateCollector->getMarkerCollector()); + } + + public function testPolygonCollector() + { + $this->coordinateCollector->setPolygonCollector($polygonCollector = $this->createPolygonCollectorMock()); + + $this->assertSame($polygonCollector, $this->coordinateCollector->getPolygonCollector()); + } + + public function testPolylineCollector() + { + $this->coordinateCollector->setPolylineCollector($polylineCollector = $this->createPolylineCollectorMock()); + + $this->assertSame($polylineCollector, $this->coordinateCollector->getPolylineCollector()); + } + + public function testCollect() + { + $map = new Map(); + + $this->assertSame([$map->getCenter()], $this->coordinateCollector->collect($map)); + } + + public function testCollectAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + + $this->assertEmpty($this->coordinateCollector->collect($map)); + } + + public function testCollectBound() + { + $map = new Map(); + $map->getOverlayManager()->addRectangle(new Rectangle(new Bound( + $southWest = new Coordinate(), + $northEast = new Coordinate() + ))); + + $this->assertSame([$map->getCenter(), $southWest, $northEast], $this->coordinateCollector->collect($map)); + } + + public function testCollectCircle() + { + $map = new Map(); + $map->getOverlayManager()->addCircle(new Circle($center = new Coordinate())); + + $this->assertSame([$map->getCenter(), $center], $this->coordinateCollector->collect($map)); + } + + public function testCollectInfoWindow() + { + $map = new Map(); + $map->getOverlayManager()->addInfoWindow(new InfoWindow( + 'content', + InfoWindowType::DEFAULT_, + $position = new Coordinate() + )); + + $this->assertSame([$map->getCenter(), $position], $this->coordinateCollector->collect($map)); + } + + public function testCollectMarker() + { + $map = new Map(); + $map->getOverlayManager()->addMarker($marker = new Marker($position = new Coordinate())); + + $this->assertSame([$map->getCenter(), $position], $this->coordinateCollector->collect($map)); + } + + public function testPolygon() + { + $map = new Map(); + $map->getOverlayManager()->addPolygon(new Polygon($coordinates = [new Coordinate()])); + + $this->assertSame(array_merge([$map->getCenter()], $coordinates), $this->coordinateCollector->collect($map)); + } + + public function testPolyline() + { + $map = new Map(); + $map->getOverlayManager()->addPolyline(new Polyline($coordinates = [new Coordinate()])); + + $this->assertSame(array_merge([$map->getCenter()], $coordinates), $this->coordinateCollector->collect($map)); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|BoundCollector + */ + private function createBoundCollectorMock() + { + return $this->createMock(BoundCollector::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|CircleCollector + */ + private function createCircleCollectorMock() + { + return $this->createMock(CircleCollector::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|InfoWindowCollector + */ + private function createInfoWindowCollectorMock() + { + return $this->createMock(InfoWindowCollector::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MarkerCollector + */ + private function createMarkerCollectorMock() + { + return $this->createMock(MarkerCollector::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|PolygonCollector + */ + private function createPolygonCollectorMock() + { + return $this->createMock(PolygonCollector::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|PolylineCollector + */ + private function createPolylineCollectorMock() + { + return $this->createMock(PolylineCollector::class); + } +} diff --git a/tests/Helper/Collector/Base/PointCollectorTest.php b/tests/Helper/Collector/Base/PointCollectorTest.php new file mode 100644 index 00000000..b745b20a --- /dev/null +++ b/tests/Helper/Collector/Base/PointCollectorTest.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Base; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Helper\Collector\Base\PointCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class PointCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PointCollector + */ + private $pointCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->pointCollector = new PointCollector(new MarkerCollector()); + } + + public function testMarkerCollector() + { + $this->pointCollector->setMarkerCollector($markerCollector = $this->createMarkerCollectorMock()); + + $this->assertSame($markerCollector, $this->pointCollector->getMarkerCollector()); + } + + public function testRender() + { + $this->assertEmpty($this->pointCollector->collect(new Map())); + } + + public function testCollectMarker() + { + $marker = new Marker(new Coordinate()); + $marker->setIcon($icon = $this->createIcon()); + + $map = new Map(); + $map->getOverlayManager()->addMarker($marker); + + $this->assertSame( + [$icon->getAnchor(), $icon->getOrigin()], + $this->pointCollector->collect($map) + ); + } + + /** + * @return Icon + */ + private function createIcon() + { + $icon = new Icon(); + $icon->setAnchor(new Point()); + $icon->setOrigin(new Point()); + + return $icon; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MarkerCollector + */ + private function createMarkerCollectorMock() + { + return $this->createMock(MarkerCollector::class); + } +} diff --git a/tests/Helper/Collector/Base/SizeCollectorTest.php b/tests/Helper/Collector/Base/SizeCollectorTest.php new file mode 100644 index 00000000..e3904a98 --- /dev/null +++ b/tests/Helper/Collector/Base/SizeCollectorTest.php @@ -0,0 +1,106 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Base; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\Collector\Base\SizeCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\IconCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class SizeCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var SizeCollector + */ + private $sizeCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->sizeCollector = new SizeCollector( + new InfoWindowCollector($markerCollector = new MarkerCollector()), + new IconCollector($markerCollector) + ); + } + + public function testInfoWindowCollector() + { + $this->sizeCollector->setInfoWindowCollector($infoWindowCollector = $this->createInfoWindowCollectorMock()); + + $this->assertSame($infoWindowCollector, $this->sizeCollector->getInfoWindowCollector()); + } + + public function testIconCollector() + { + $this->sizeCollector->setIconCollector($iconCollector = $this->createIconCollectorMock()); + + $this->assertSame($iconCollector, $this->sizeCollector->getIconCollector()); + } + + public function testCollect() + { + $this->assertEmpty($this->sizeCollector->collect(new Map())); + } + + public function testCollectInfoWindow() + { + $infoWindow = new InfoWindow('content'); + $infoWindow->setPixelOffset($pixelOffset = new Size()); + + $map = new Map(); + $map->getOverlayManager()->addInfoWindow($infoWindow); + + $this->assertSame([$pixelOffset], $this->sizeCollector->collect($map)); + } + + public function testCollectMarker() + { + $icon = new Icon(); + $icon->setSize($size = new Size()); + $icon->setScaledSize($scaledSize = new Size()); + + $marker = new Marker(new Coordinate()); + $marker->setIcon($icon); + + $map = new Map(); + $map->getOverlayManager()->addMarker($marker); + + $this->assertSame([$size, $scaledSize], $this->sizeCollector->collect($map)); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|InfoWindowCollector + */ + private function createInfoWindowCollectorMock() + { + return $this->createMock(InfoWindowCollector::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|IconCollector + */ + private function createIconCollectorMock() + { + return $this->createMock(IconCollector::class); + } +} diff --git a/tests/Helper/Collector/Event/DomEventCollectorTest.php b/tests/Helper/Collector/Event/DomEventCollectorTest.php new file mode 100644 index 00000000..0fe4bf7e --- /dev/null +++ b/tests/Helper/Collector/Event/DomEventCollectorTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\Event\DomEventCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class DomEventCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DomEventCollector + */ + private $domEventCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->domEventCollector = new DomEventCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getEventManager()->addDomEvent($event = new Event('handle', 'trigger', 'handle')); + + $this->assertSame([$event], $this->domEventCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Event/DomEventOnceCollectorTest.php b/tests/Helper/Collector/Event/DomEventOnceCollectorTest.php new file mode 100644 index 00000000..ca22e600 --- /dev/null +++ b/tests/Helper/Collector/Event/DomEventOnceCollectorTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\Event\DomEventOnceCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class DomEventOnceCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DomEventOnceCollector + */ + private $domEventOnceCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->domEventOnceCollector = new DomEventOnceCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getEventManager()->addDomEventOnce($event = new Event('handle', 'trigger', 'handle')); + + $this->assertSame([$event], $this->domEventOnceCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Event/EventCollectorTest.php b/tests/Helper/Collector/Event/EventCollectorTest.php new file mode 100644 index 00000000..0aabbbb3 --- /dev/null +++ b/tests/Helper/Collector/Event/EventCollectorTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\Event\EventCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class EventCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EventCollector + */ + private $eventCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->eventCollector = new EventCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getEventManager()->addEvent($event = new Event('handle', 'trigger', 'handle')); + + $this->assertSame([$event], $this->eventCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Event/EventOnceCollectorTest.php b/tests/Helper/Collector/Event/EventOnceCollectorTest.php new file mode 100644 index 00000000..56428e12 --- /dev/null +++ b/tests/Helper/Collector/Event/EventOnceCollectorTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Collector\Event\EventOnceCollector; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class EventOnceCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EventOnceCollector + */ + private $eventOnceCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->eventOnceCollector = new EventOnceCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getEventManager()->addEventOnce($event = new Event('handle', 'trigger', 'handle')); + + $this->assertSame([$event], $this->eventOnceCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Layer/KmlLayerCollectorTest.php b/tests/Helper/Collector/Layer/KmlLayerCollectorTest.php new file mode 100644 index 00000000..326ee1dc --- /dev/null +++ b/tests/Helper/Collector/Layer/KmlLayerCollectorTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Layer; + +use Ivory\GoogleMap\Helper\Collector\Layer\KmlLayerCollector; +use Ivory\GoogleMap\Layer\KmlLayer; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class KmlLayerCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var KmlLayerCollector + */ + private $kmlLayerCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->kmlLayerCollector = new KmlLayerCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getLayerManager()->addKmlLayer($kmlLayer = new KmlLayer('url')); + + $this->assertSame([$kmlLayer], $this->kmlLayerCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/CircleCollectorTest.php b/tests/Helper/Collector/Overlay/CircleCollectorTest.php new file mode 100644 index 00000000..ec449eaa --- /dev/null +++ b/tests/Helper/Collector/Overlay/CircleCollectorTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Collector\Overlay\CircleCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Circle; + +/** + * @author GeLo + */ +class CircleCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CircleCollector + */ + private $circleCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->circleCollector = new CircleCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getOverlayManager()->addCircle($circle = new Circle(new Coordinate())); + + $this->assertSame([$circle], $this->circleCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/DefaultInfoWindowCollectorTest.php b/tests/Helper/Collector/Overlay/DefaultInfoWindowCollectorTest.php new file mode 100644 index 00000000..58b71eb4 --- /dev/null +++ b/tests/Helper/Collector/Overlay/DefaultInfoWindowCollectorTest.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\DefaultInfoWindowCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; + +/** + * @author GeLo + */ +class DefaultInfoWindowCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DefaultInfoWindowCollector + */ + private $defaultInfoWindowCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->defaultInfoWindowCollector = new DefaultInfoWindowCollector(new MarkerCollector()); + } + + public function testCollect() + { + $defaultInfoWindow = new InfoWindow('content', InfoWindowType::DEFAULT_); + $infoBox = new InfoWindow('content', InfoWindowType::INFO_BOX); + + $map = new Map(); + $map->getOverlayManager()->addInfoWindows([$defaultInfoWindow, $infoBox]); + + $this->assertSame([$defaultInfoWindow], $this->defaultInfoWindowCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/EncodedPolylineCollectorTest.php b/tests/Helper/Collector/Overlay/EncodedPolylineCollectorTest.php new file mode 100644 index 00000000..82074420 --- /dev/null +++ b/tests/Helper/Collector/Overlay/EncodedPolylineCollectorTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\EncodedPolylineCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\EncodedPolyline; + +/** + * @author GeLo + */ +class EncodedPolylineCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EncodedPolylineCollector + */ + private $encodedPolylineCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->encodedPolylineCollector = new EncodedPolylineCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getOverlayManager()->addEncodedPolyline($encodedPolyline = new EncodedPolyline('value')); + + $this->assertSame([$encodedPolyline], $this->encodedPolylineCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/ExtendableCollectorTest.php b/tests/Helper/Collector/Overlay/ExtendableCollectorTest.php new file mode 100644 index 00000000..7448ccb0 --- /dev/null +++ b/tests/Helper/Collector/Overlay/ExtendableCollectorTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\ExtendableCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class ExtendableCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ExtendableCollector + */ + private $extendableCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->extendableCollector = new ExtendableCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getBound()->addExtendable($extendable = $this->createExtendableMock()); + + $this->assertSame([$extendable], $this->extendableCollector->collect($map)); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ExtendableInterface + */ + private function createExtendableMock() + { + return $this->createMock(ExtendableInterface::class); + } +} diff --git a/tests/Helper/Collector/Overlay/GroundOverlayCollectorTest.php b/tests/Helper/Collector/Overlay/GroundOverlayCollectorTest.php new file mode 100644 index 00000000..8fbab5e8 --- /dev/null +++ b/tests/Helper/Collector/Overlay/GroundOverlayCollectorTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Collector\Overlay\GroundOverlayCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\GroundOverlay; + +/** + * @author GeLo + */ +class GroundOverlayCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var GroundOverlayCollector + */ + private $groundOverlayCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->groundOverlayCollector = new GroundOverlayCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getOverlayManager()->addGroundOverlay($groundOverlay = new GroundOverlay('url', new Bound())); + + $this->assertSame([$groundOverlay], $this->groundOverlayCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/IconCollectorTest.php b/tests/Helper/Collector/Overlay/IconCollectorTest.php new file mode 100644 index 00000000..a6bee1fc --- /dev/null +++ b/tests/Helper/Collector/Overlay/IconCollectorTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Collector\Overlay\IconCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class IconCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var IconCollector + */ + private $iconCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->iconCollector = new IconCollector(new MarkerCollector()); + } + + public function testMarkerCollector() + { + $this->iconCollector->setMarkerCollector($markerCollector = $this->createMarkerCollectorMock()); + + $this->assertSame($markerCollector, $this->iconCollector->getMarkerCollector()); + } + + public function testCollect() + { + $marker = new Marker(new Coordinate()); + $marker->setIcon($icon = new Icon()); + + $map = new Map(); + $map->getOverlayManager()->addMarker($marker); + + $this->assertSame([$icon], $this->iconCollector->collect($map)); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MarkerCollector + */ + private function createMarkerCollectorMock() + { + return $this->createMock(MarkerCollector::class); + } +} diff --git a/tests/Helper/Collector/Overlay/InfoBoxCollectorTest.php b/tests/Helper/Collector/Overlay/InfoBoxCollectorTest.php new file mode 100644 index 00000000..a0212d0b --- /dev/null +++ b/tests/Helper/Collector/Overlay/InfoBoxCollectorTest.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoBoxCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; + +/** + * @author GeLo + */ +class InfoBoxCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var InfoBoxCollector + */ + private $infoBoxCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->infoBoxCollector = new InfoBoxCollector(new MarkerCollector()); + } + + public function testCollect() + { + $infoBox = new InfoWindow('content', InfoWindowType::INFO_BOX); + $defaultInfoWindow = new InfoWindow('content', InfoWindowType::DEFAULT_); + + $map = new Map(); + $map->getOverlayManager()->addInfoWindows([$infoBox, $defaultInfoWindow]); + + $this->assertSame([$infoBox], $this->infoBoxCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/InfoWindowCollectorTest.php b/tests/Helper/Collector/Overlay/InfoWindowCollectorTest.php new file mode 100644 index 00000000..10a82712 --- /dev/null +++ b/tests/Helper/Collector/Overlay/InfoWindowCollectorTest.php @@ -0,0 +1,107 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class InfoWindowCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var InfoWindowCollector + */ + private $infoWindowCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->infoWindowCollector = new InfoWindowCollector(new MarkerCollector()); + } + + public function testMarkerCollector() + { + $this->infoWindowCollector->setMarkerCollector($markerCollector = $this->createMarkerCollectorMock()); + + $this->assertSame($markerCollector, $this->infoWindowCollector->getMarkerCollector()); + } + + public function testType() + { + $this->infoWindowCollector->setType($type = InfoWindowType::DEFAULT_); + + $this->assertSame($type, $this->infoWindowCollector->getType()); + } + + public function testCollect() + { + $defaultInfoWindow = new InfoWindow('content', InfoWindowType::DEFAULT_); + $infoBox = new InfoWindow('content', InfoWindowType::INFO_BOX); + + $map = new Map(); + $map->getOverlayManager()->addInfoWindows([$defaultInfoWindow, $infoBox]); + + $this->assertSame([$defaultInfoWindow, $infoBox], $this->infoWindowCollector->collect($map)); + } + + public function testCollectMarker() + { + $marker = new Marker(new Coordinate()); + $marker->setInfoWindow(new InfoWindow('content')); + + $map = new Map(); + $map->getOverlayManager()->addMarker($marker); + + $this->assertEmpty($this->infoWindowCollector->collect($map)); + } + + public function testCollectMarkerWithoutPosition() + { + $marker = new Marker(new Coordinate()); + $marker->setInfoWindow($infoWindow = new InfoWindow('content')); + + $map = new Map(); + $map->getOverlayManager()->addMarker($marker); + + $this->assertSame([$infoWindow], $this->infoWindowCollector->collect($map, [], false)); + } + + public function testCollectWithType() + { + $this->infoWindowCollector->setType(InfoWindowType::DEFAULT_); + + $defaultInfoWindow = new InfoWindow('content', InfoWindowType::DEFAULT_); + $infoBox = new InfoWindow('content', InfoWindowType::INFO_BOX); + + $map = new Map(); + $map->getOverlayManager()->addInfoWindows([$defaultInfoWindow, $infoBox]); + + $this->assertSame([$defaultInfoWindow], $this->infoWindowCollector->collect($map)); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MarkerCollector + */ + private function createMarkerCollectorMock() + { + return $this->createMock(MarkerCollector::class); + } +} diff --git a/tests/Helper/Collector/Overlay/MarkerCollectorTest.php b/tests/Helper/Collector/Overlay/MarkerCollectorTest.php new file mode 100644 index 00000000..c40b618b --- /dev/null +++ b/tests/Helper/Collector/Overlay/MarkerCollectorTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Collector\Overlay\MarkerCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class MarkerCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MarkerCollector + */ + private $markerCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->markerCollector = new MarkerCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getOverlayManager()->addMarker($marker = new Marker(new Coordinate())); + + $this->assertSame([$marker], $this->markerCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/PolygonCollectorTest.php b/tests/Helper/Collector/Overlay/PolygonCollectorTest.php new file mode 100644 index 00000000..2e172179 --- /dev/null +++ b/tests/Helper/Collector/Overlay/PolygonCollectorTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\PolygonCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polygon; + +/** + * @author GeLo + */ +class PolygonCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PolygonCollector + */ + private $polygonCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->polygonCollector = new PolygonCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getOverlayManager()->addPolygon($polygon = new Polygon()); + + $this->assertSame([$polygon], $this->polygonCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/PolylineCollectorTest.php b/tests/Helper/Collector/Overlay/PolylineCollectorTest.php new file mode 100644 index 00000000..c59456dc --- /dev/null +++ b/tests/Helper/Collector/Overlay/PolylineCollectorTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Helper\Collector\Overlay\PolylineCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polyline; + +/** + * @author GeLo + */ +class PolylineCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PolylineCollector + */ + private $polylineCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->polylineCollector = new PolylineCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getOverlayManager()->addPolyline($polyline = new Polyline()); + + $this->assertSame([$polyline], $this->polylineCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Overlay/RectangleCollectorTest.php b/tests/Helper/Collector/Overlay/RectangleCollectorTest.php new file mode 100644 index 00000000..019419f3 --- /dev/null +++ b/tests/Helper/Collector/Overlay/RectangleCollectorTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Collector\Overlay\RectangleCollector; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Rectangle; + +/** + * @author GeLo + */ +class RectangleCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var RectangleCollector + */ + private $rectangleCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->rectangleCollector = new RectangleCollector(); + } + + public function testCollect() + { + $map = new Map(); + $map->getOverlayManager()->addRectangle($rectangle = new Rectangle(new Bound())); + + $this->assertSame([$rectangle], $this->rectangleCollector->collect($map)); + } +} diff --git a/tests/Helper/Collector/Place/AutocompleteBoundCollectorTest.php b/tests/Helper/Collector/Place/AutocompleteBoundCollectorTest.php new file mode 100644 index 00000000..8e554b9a --- /dev/null +++ b/tests/Helper/Collector/Place/AutocompleteBoundCollectorTest.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Place; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Collector\Place\AutocompleteBoundCollector; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class AutocompleteBoundCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AutocompleteBoundCollector + */ + private $autocompleteBoundCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->autocompleteBoundCollector = new AutocompleteBoundCollector(); + } + + public function testCollect() + { + $this->assertEmpty($this->autocompleteBoundCollector->collect(new Autocomplete())); + } + + public function testCollectBound() + { + $autocomplete = new Autocomplete(); + $autocomplete->setBound($bound = new Bound()); + + $this->assertSame([$bound], $this->autocompleteBoundCollector->collect($autocomplete)); + } +} diff --git a/tests/Helper/Collector/Place/AutocompleteCoordinateCollectorTest.php b/tests/Helper/Collector/Place/AutocompleteCoordinateCollectorTest.php new file mode 100644 index 00000000..40ebeee6 --- /dev/null +++ b/tests/Helper/Collector/Place/AutocompleteCoordinateCollectorTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Collector\Place; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Collector\Place\AutocompleteBoundCollector; +use Ivory\GoogleMap\Helper\Collector\Place\AutocompleteCoordinateCollector; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class AutocompleteCoordinateCollectorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AutocompleteCoordinateCollector + */ + private $autocompleteCoordinateCollector; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->autocompleteCoordinateCollector = new AutocompleteCoordinateCollector(new AutocompleteBoundCollector()); + } + + public function testAutocompleteBoundCollector() + { + $autocompleteBoundCollector = $this->createAutocompleteBoundCollectorMock(); + $this->autocompleteCoordinateCollector->setBoundCollector($autocompleteBoundCollector); + + $this->assertSame($autocompleteBoundCollector, $this->autocompleteCoordinateCollector->getBoundCollector()); + } + + public function testCollect() + { + $this->assertEmpty($this->autocompleteCoordinateCollector->collect(new Autocomplete())); + } + + public function testCollectBound() + { + $autocomplete = new Autocomplete(); + $autocomplete->setBound(new Bound( + $southWest = new Coordinate(), + $northEast = new Coordinate() + )); + + $this->assertSame([$southWest, $northEast], $this->autocompleteCoordinateCollector->collect($autocomplete)); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|AutocompleteBoundCollector + */ + private function createAutocompleteBoundCollectorMock() + { + return $this->createMock(AutocompleteBoundCollector::class); + } +} diff --git a/tests/Helper/Controls/ControlPositionHelperTest.php b/tests/Helper/Controls/ControlPositionHelperTest.php deleted file mode 100644 index ed4d7a8b..00000000 --- a/tests/Helper/Controls/ControlPositionHelperTest.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Helper\Controls\ControlPositionHelper; - -/** - * Control position helper test. - * - * @author GeLo - */ -class ControlPositionHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ControlPositionHelper */ - protected $controlPositionHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->controlPositionHelper = new ControlPositionHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->controlPositionHelper); - } - - public function testRenderWithValidValue() - { - $this->assertSame( - 'google.maps.ControlPosition.BOTTOM_CENTER', - $this->controlPositionHelper->render(ControlPosition::BOTTOM_CENTER) - ); - - $this->assertSame( - 'google.maps.ControlPosition.BOTTOM_LEFT', - $this->controlPositionHelper->render(ControlPosition::BOTTOM_LEFT) - ); - - $this->assertSame( - 'google.maps.ControlPosition.BOTTOM_RIGHT', - $this->controlPositionHelper->render(ControlPosition::BOTTOM_RIGHT) - ); - - $this->assertSame( - 'google.maps.ControlPosition.LEFT_BOTTOM', - $this->controlPositionHelper->render(ControlPosition::LEFT_BOTTOM) - ); - - $this->assertSame( - 'google.maps.ControlPosition.LEFT_CENTER', - $this->controlPositionHelper->render(ControlPosition::LEFT_CENTER) - ); - - $this->assertSame( - 'google.maps.ControlPosition.LEFT_TOP', - $this->controlPositionHelper->render(ControlPosition::LEFT_TOP) - ); - - $this->assertSame( - 'google.maps.ControlPosition.RIGHT_BOTTOM', - $this->controlPositionHelper->render(ControlPosition::RIGHT_BOTTOM) - ); - - $this->assertSame( - 'google.maps.ControlPosition.RIGHT_CENTER', - $this->controlPositionHelper->render(ControlPosition::RIGHT_CENTER) - ); - - $this->assertSame( - 'google.maps.ControlPosition.RIGHT_TOP', - $this->controlPositionHelper->render(ControlPosition::RIGHT_TOP) - ); - - $this->assertSame( - 'google.maps.ControlPosition.TOP_CENTER', - $this->controlPositionHelper->render(ControlPosition::TOP_CENTER) - ); - - $this->assertSame( - 'google.maps.ControlPosition.TOP_LEFT', - $this->controlPositionHelper->render(ControlPosition::TOP_LEFT) - ); - - $this->assertSame( - 'google.maps.ControlPosition.TOP_RIGHT', - $this->controlPositionHelper->render(ControlPosition::TOP_RIGHT) - ); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The control position can only be : bottom_center, bottom_left, bottom_right, - * left_bottom, left_center, left_top, right_bottom, right_center, right_top, top_center, top_left, top_right. - */ - public function testRenderWithInvalidValue() - { - $this->controlPositionHelper->render('foo'); - } -} diff --git a/tests/Helper/Controls/MapTypeControlHelperTest.php b/tests/Helper/Controls/MapTypeControlHelperTest.php deleted file mode 100644 index 6161bf04..00000000 --- a/tests/Helper/Controls/MapTypeControlHelperTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControl; -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\MapTypeId; -use Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper; - -/** - * Map type control helper test. - * - * @author GeLo - */ -class MapTypeControlHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper */ - protected $mapTypeControlHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->mapTypeControlHelper = new MapTypeControlHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->mapTypeControlHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\MapTypeIdHelper', - $this->mapTypeControlHelper->getMapTypeIdHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ControlPositionHelper', - $this->mapTypeControlHelper->getControlPositionHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\MapTypeControlStyleHelper', - $this->mapTypeControlHelper->getMapTypeControlStyleHelper() - ); - } - - public function testInitialState() - { - $mapTypeIdHelper = $this->getMock('Ivory\GoogleMap\Helper\MapTypeIdHelper'); - $controlPositionHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ControlPositionHelper'); - $mapTypeControlStyleHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\MapTypeControlStyleHelper'); - - $this->mapTypeControlHelper = new MapTypeControlHelper( - $mapTypeIdHelper, - $controlPositionHelper, - $mapTypeControlStyleHelper - ); - - $this->assertSame($mapTypeIdHelper, $this->mapTypeControlHelper->getMapTypeIdHelper()); - $this->assertSame($controlPositionHelper, $this->mapTypeControlHelper->getControlPositionHelper()); - $this->assertSame($mapTypeControlStyleHelper, $this->mapTypeControlHelper->getMapTypeControlStyleHelper()); - } - - public function testRender() - { - $mapTypeControl = new MapTypeControl( - array(MapTypeId::ROADMAP), - ControlPosition::BOTTOM_CENTER, - MapTypeControlStyle::DROPDOWN_MENU - ); - - $expected = '{'. - '"mapTypeIds":[google.maps.MapTypeId.ROADMAP],'. - '"position":google.maps.ControlPosition.BOTTOM_CENTER,'. - '"style":google.maps.MapTypeControlStyle.DROPDOWN_MENU'. - '}'; - - $this->assertSame($expected, $this->mapTypeControlHelper->render($mapTypeControl)); - } -} diff --git a/tests/Helper/Controls/MapTypeControlStyleHelperTest.php b/tests/Helper/Controls/MapTypeControlStyleHelperTest.php deleted file mode 100644 index dd5150a9..00000000 --- a/tests/Helper/Controls/MapTypeControlStyleHelperTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\Helper\Controls\MapTypeControlStyleHelper; - -/** - * Map type control style helper test. - * - * @author GeLo - */ -class MapTypeControlStyleHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\MapTypeControlStyleHelper */ - protected $mapTypeControlStyleHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->mapTypeControlStyleHelper = new MapTypeControlStyleHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->mapTypeControlStyleHelper); - } - - public function testRenderWithValidValue() - { - $this->assertSame( - 'google.maps.MapTypeControlStyle.DEFAULT', - $this->mapTypeControlStyleHelper->render(MapTypeControlStyle::DEFAULT_) - ); - - $this->assertSame( - 'google.maps.MapTypeControlStyle.DROPDOWN_MENU', - $this->mapTypeControlStyleHelper->render(MapTypeControlStyle::DROPDOWN_MENU) - ); - - $this->assertSame( - 'google.maps.MapTypeControlStyle.HORIZONTAL_BAR', - $this->mapTypeControlStyleHelper->render(MapTypeControlStyle::HORIZONTAL_BAR) - ); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The map type control style can only be : default, dropdown_menu, horizontal_bar. - */ - public function testRenderWithInvalidValue() - { - $this->mapTypeControlStyleHelper->render('foo'); - } -} diff --git a/tests/Helper/Controls/OverviewMapControlHelperTest.php b/tests/Helper/Controls/OverviewMapControlHelperTest.php deleted file mode 100644 index 57080d23..00000000 --- a/tests/Helper/Controls/OverviewMapControlHelperTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\OverviewMapControl; -use Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper; - -/** - * Overview map control helper test. - * - * @author GeLo - */ -class OverviewMapControlHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper */ - protected $overviewMapControlHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->overviewMapControlHelper = new OverviewMapControlHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->overviewMapControlHelper); - } - - public function testRender() - { - $overviewMapControl = new OverviewMapControl(true); - - $this->assertSame('{"opened":true}', $this->overviewMapControlHelper->render($overviewMapControl)); - } -} diff --git a/tests/Helper/Controls/PanControlHelperTest.php b/tests/Helper/Controls/PanControlHelperTest.php deleted file mode 100644 index 13ccffc0..00000000 --- a/tests/Helper/Controls/PanControlHelperTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\PanControl; -use Ivory\GoogleMap\Helper\Controls\PanControlHelper; - -/** - * Overview map control helper test. - * - * @author GeLo - */ -class PanControlHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\PanControlHelper */ - protected $panControlHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->panControlHelper = new PanControlHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->panControlHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ControlPositionHelper', - $this->panControlHelper->getControlPositionHelper() - ); - } - - public function testInitialState() - { - $controlPositionHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ControlPositionHelper'); - - $this->panControlHelper = new PanControlHelper($controlPositionHelper); - - $this->assertSame($controlPositionHelper, $this->panControlHelper->getControlPositionHelper()); - } - - public function testRender() - { - $panControl = new PanControl(ControlPosition::BOTTOM_CENTER); - - $this->assertSame( - '{"position":google.maps.ControlPosition.BOTTOM_CENTER}', - $this->panControlHelper->render($panControl) - ); - } -} diff --git a/tests/Helper/Controls/RotateControlHelperTest.php b/tests/Helper/Controls/RotateControlHelperTest.php deleted file mode 100644 index 005e6da2..00000000 --- a/tests/Helper/Controls/RotateControlHelperTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\RotateControl; -use Ivory\GoogleMap\Helper\Controls\RotateControlHelper; - -/** - * Rotate control helper test. - * - * @author GeLo - */ -class RotateControlHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\RotateControlHelper */ - protected $rotateControlHelper; - - /**p - * {@inheritdoc} - */ - protected function setUp() - { - $this->rotateControlHelper = new RotateControlHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->rotateControlHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ControlPositionHelper', - $this->rotateControlHelper->getControlPositionHelper() - ); - } - - public function testInitialState() - { - $controlPositionHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ControlPositionHelper'); - - $this->rotateControlHelper = new RotateControlHelper($controlPositionHelper); - - $this->assertSame($controlPositionHelper, $this->rotateControlHelper->getControlPositionHelper()); - } - - public function testRender() - { - $rotateControl = new RotateControl(ControlPosition::BOTTOM_CENTER); - - $this->assertSame( - '{"position":google.maps.ControlPosition.BOTTOM_CENTER}', - $this->rotateControlHelper->render($rotateControl) - ); - } -} diff --git a/tests/Helper/Controls/ScaleControlHelperTest.php b/tests/Helper/Controls/ScaleControlHelperTest.php deleted file mode 100644 index f274538f..00000000 --- a/tests/Helper/Controls/ScaleControlHelperTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ScaleControl; -use Ivory\GoogleMap\Controls\ScaleControlStyle; -use Ivory\GoogleMap\Helper\Controls\ScaleControlHelper; - -/** - * Scale control helper test. - * - * @author GeLo - */ -class ScaleControlHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ScaleControlHelper */ - protected $scaleControlHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->scaleControlHelper = new ScaleControlHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->scaleControlHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ControlPositionHelper', - $this->scaleControlHelper->getControlPositionHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ScaleControlStyleHelper', - $this->scaleControlHelper->getScaleControlStyleHelper() - ); - } - - public function testInitialState() - { - $controlPositionHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ControlPositionHelper'); - $scaleControlStyleHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ScaleControlStyleHelper'); - - $this->scaleControlHelper = new ScaleControlHelper($controlPositionHelper, $scaleControlStyleHelper); - - $this->assertSame($controlPositionHelper, $this->scaleControlHelper->getControlPositionHelper()); - $this->assertSame($scaleControlStyleHelper, $this->scaleControlHelper->getScaleControlStyleHelper()); - } - - public function testRender() - { - $scaleControl = new ScaleControl(ControlPosition::BOTTOM_CENTER, ScaleControlStyle::DEFAULT_); - - $this->assertSame( - '{"position":google.maps.ControlPosition.BOTTOM_CENTER,"style":google.maps.ScaleControlStyle.DEFAULT}', - $this->scaleControlHelper->render($scaleControl) - ); - } -} diff --git a/tests/Helper/Controls/ScaleControlStyleHelperTest.php b/tests/Helper/Controls/ScaleControlStyleHelperTest.php deleted file mode 100644 index 44e16c30..00000000 --- a/tests/Helper/Controls/ScaleControlStyleHelperTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ScaleControlStyle; -use Ivory\GoogleMap\Helper\Controls\ScaleControlStyleHelper; - -/** - * Scale control style helper test. - * - * @author GeLo - */ -class ScaleControlStyleHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var Ivory\GoogleMap\Helper\Controls\ScaleControlStyleHelper */ - protected $scaleControlStyleHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->scaleControlStyleHelper = new ScaleControlStyleHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->scaleControlStyleHelper); - } - - public function testRenderWithValidValue() - { - $this->assertSame( - 'google.maps.ScaleControlStyle.DEFAULT', - $this->scaleControlStyleHelper->render(ScaleControlStyle::DEFAULT_) - ); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The scale control style can only be : default. - */ - public function testRenderWithInvalidValue() - { - $this->scaleControlStyleHelper->render('foo'); - } -} diff --git a/tests/Helper/Controls/StreetViewControlHelperTest.php b/tests/Helper/Controls/StreetViewControlHelperTest.php deleted file mode 100644 index ed5b08a2..00000000 --- a/tests/Helper/Controls/StreetViewControlHelperTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\StreetViewControl; -use Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper; - -/** - * Street view control helper test. - * - * @author GeLo - */ -class StreetViewControlHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper */ - protected $streetViewControlHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->streetViewControlHelper = new StreetViewControlHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->streetViewControlHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ControlPositionHelper', - $this->streetViewControlHelper->getControlPositionHelper() - ); - } - - public function testInitialState() - { - $controlPositionHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ControlPositionHelper'); - - $this->streetViewControlHelper = new StreetViewControlHelper($controlPositionHelper); - - $this->assertSame($controlPositionHelper, $this->streetViewControlHelper->getControlPositionHelper()); - } - - public function testRender() - { - $streetViewControl = new StreetViewControl(ControlPosition::BOTTOM_CENTER); - - $this->assertSame( - '{"position":google.maps.ControlPosition.BOTTOM_CENTER}', - $this->streetViewControlHelper->render($streetViewControl) - ); - } -} diff --git a/tests/Helper/Controls/ZoomControlHelperTest.php b/tests/Helper/Controls/ZoomControlHelperTest.php deleted file mode 100644 index b4f0bfd1..00000000 --- a/tests/Helper/Controls/ZoomControlHelperTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\ZoomControl; -use Ivory\GoogleMap\Controls\ZoomControlStyle; -use Ivory\GoogleMap\Helper\Controls\ZoomControlHelper; - -/** - * Zoom control helper test. - * - * @author GeLo - */ -class ZoomControlHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ZoomControlHelper */ - protected $zoomControlHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->zoomControlHelper = new ZoomControlHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->zoomControlHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ControlPositionHelper', - $this->zoomControlHelper->getControlPositionHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ZoomControlStyleHelper', - $this->zoomControlHelper->getZoomControlStyleHelper() - ); - } - - public function testInitialState() - { - $controlPositionHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ControlPositionHelper'); - $zoomControlStyleHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ZoomControlStyleHelper'); - - $this->zoomControlHelper = new ZoomControlHelper($controlPositionHelper, $zoomControlStyleHelper); - - $this->assertSame($controlPositionHelper, $this->zoomControlHelper->getControlPositionHelper()); - $this->assertSame($zoomControlStyleHelper, $this->zoomControlHelper->getZoomControlStyleHelper()); - } - - public function testRender() - { - $zoomControlTest = new ZoomControl(ControlPosition::BOTTOM_CENTER, ZoomControlStyle::SMALL); - - $this->assertSame( - '{"position":google.maps.ControlPosition.BOTTOM_CENTER,"style":google.maps.ZoomControlStyle.SMALL}', - $this->zoomControlHelper->render($zoomControlTest) - ); - } -} diff --git a/tests/Helper/Controls/ZoomControlStyleHelperTest.php b/tests/Helper/Controls/ZoomControlStyleHelperTest.php deleted file mode 100644 index 4b8fb51b..00000000 --- a/tests/Helper/Controls/ZoomControlStyleHelperTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Controls\ZoomControlStyle; -use Ivory\GoogleMap\Helper\Controls\ZoomControlStyleHelper; - -/** - * Zoom control style helper test. - * - * @author GeLo - */ -class ZoomControlStyleHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Controls\ZoomControlStyleHelper */ - protected $zoomControlStyleHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->zoomControlStyleHelper = new ZoomControlStyleHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->zoomControlStyleHelper); - } - - public function testRenderWithValidValue() - { - $this->assertSame( - 'google.maps.ZoomControlStyle.DEFAULT', - $this->zoomControlStyleHelper->render(ZoomControlStyle::DEFAULT_) - ); - - $this->assertSame( - 'google.maps.ZoomControlStyle.LARGE', - $this->zoomControlStyleHelper->render(ZoomControlStyle::LARGE) - ); - - $this->assertSame( - 'google.maps.ZoomControlStyle.SMALL', - $this->zoomControlStyleHelper->render(ZoomControlStyle::SMALL) - ); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The zoom control style can only be : default, large, small. - */ - public function testRenderWithInvalidValue() - { - $this->zoomControlStyleHelper->render('foo'); - } -} diff --git a/tests/Helper/Event/ApiEventTest.php b/tests/Helper/Event/ApiEventTest.php new file mode 100644 index 00000000..4dd6603f --- /dev/null +++ b/tests/Helper/Event/ApiEventTest.php @@ -0,0 +1,240 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Event; + +use Ivory\GoogleMap\Helper\Event\AbstractEvent; +use Ivory\GoogleMap\Helper\Event\ApiEvent; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class ApiEventTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ApiEvent + */ + private $apiEvent; + + /** + * @var object[] + */ + private $objects; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->objects = [new \stdClass(), new \stdClass()]; + $this->apiEvent = new ApiEvent($this->objects); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractEvent::class, $this->apiEvent); + } + + public function testDefaultState() + { + $this->assertTrue($this->apiEvent->hasObjects()); + $this->assertSame($this->objects, $this->apiEvent->getObjects()); + $this->assertSame('en', $this->apiEvent->getLanguage()); + $this->assertFalse($this->apiEvent->hasSources()); + $this->assertEmpty($this->apiEvent->getSources()); + $this->assertFalse($this->apiEvent->hasLibraries()); + $this->assertEmpty($this->apiEvent->getLibraries()); + $this->assertFalse($this->apiEvent->hasCallbacks()); + $this->assertEmpty($this->apiEvent->getCallbacks()); + $this->assertFalse($this->apiEvent->hasRequirements()); + $this->assertEmpty($this->apiEvent->getRequirements()); + } + + public function testObjects() + { + $this->assertTrue($this->apiEvent->hasObjects(\stdClass::class)); + $this->assertSame($this->objects, $this->apiEvent->getObjects(\stdClass::class)); + + $this->assertFalse($this->apiEvent->hasObjects(Map::class)); + $this->assertEmpty($this->apiEvent->getObjects(Map::class)); + } + + public function testLanguage() + { + $this->apiEvent->setLanguage($language = 'fr'); + + $this->assertSame($language, $this->apiEvent->getLanguage()); + } + + public function testSetSources() + { + $this->apiEvent->setSources($sources = [$source = 'source']); + $this->apiEvent->setSources($sources); + + $this->assertTrue($this->apiEvent->hasSources()); + $this->assertTrue($this->apiEvent->hasSource($source)); + $this->assertSame($sources, $this->apiEvent->getSources()); + } + + public function testAddSources() + { + $this->apiEvent->setSources($firstSources = ['source1']); + $this->apiEvent->addSources($secondSources = ['source2']); + + $this->assertTrue($this->apiEvent->hasSources()); + $this->assertSame(array_merge($firstSources, $secondSources), $this->apiEvent->getSources()); + } + + public function testAddSource() + { + $this->apiEvent->addSource($source = 'source'); + + $this->assertTrue($this->apiEvent->hasSources()); + $this->assertTrue($this->apiEvent->hasSource($source)); + $this->assertSame([$source], $this->apiEvent->getSources()); + } + + public function testRemoveSource() + { + $this->apiEvent->addSource($source = 'source'); + $this->apiEvent->removeSource($source); + + $this->assertFalse($this->apiEvent->hasSources()); + $this->assertFalse($this->apiEvent->hasSource($source)); + $this->assertEmpty($this->apiEvent->getSources()); + } + + public function testSetLibraries() + { + $this->apiEvent->setLibraries($libraries = [$library = 'library']); + $this->apiEvent->setLibraries($libraries); + + $this->assertTrue($this->apiEvent->hasLibraries()); + $this->assertTrue($this->apiEvent->hasLibrary($library)); + $this->assertSame($libraries, $this->apiEvent->getLibraries()); + } + + public function testAddLibraries() + { + $this->apiEvent->setLibraries($firstLibraries = ['library1']); + $this->apiEvent->addLibraries($secondLibraries = ['library2']); + + $this->assertTrue($this->apiEvent->hasLibraries()); + $this->assertSame(array_merge($firstLibraries, $secondLibraries), $this->apiEvent->getLibraries()); + } + + public function testAddLibrary() + { + $this->apiEvent->addLibrary($library = 'library'); + + $this->assertTrue($this->apiEvent->hasLibraries()); + $this->assertTrue($this->apiEvent->hasLibrary($library)); + $this->assertSame([$library], $this->apiEvent->getLibraries()); + } + + public function testRemoveLibrary() + { + $this->apiEvent->addLibrary($library = 'library'); + $this->apiEvent->removeLibrary($library); + + $this->assertFalse($this->apiEvent->hasLibraries()); + $this->assertFalse($this->apiEvent->hasLibrary($library)); + $this->assertEmpty($this->apiEvent->getLibraries()); + } + + public function testAddCallback() + { + $this->apiEvent->addCallback(new \stdClass(), 'callback1'); + $this->apiEvent->addCallback($object = new \stdClass(), $callback = 'callback2'); + + $this->assertTrue($this->apiEvent->hasCallbacks()); + $this->assertTrue($this->apiEvent->hasCallback($callback)); + $this->assertTrue($this->apiEvent->hasCallback($callback, $object)); + $this->assertTrue($this->apiEvent->hasCallbackObject($object)); + $this->assertTrue($this->apiEvent->hasCallbackObject($object, $callback)); + $this->assertSame($callback, $this->apiEvent->getCallback($object)); + $this->assertSame($object, $this->apiEvent->getCallbackObject($callback)); + } + + public function testRemoveCallback() + { + $this->apiEvent->addCallback($object = new \stdClass(), $callback = 'callback'); + $this->apiEvent->removeCallback($callback); + + $this->assertFalse($this->apiEvent->hasCallbacks()); + $this->assertFalse($this->apiEvent->hasCallback($callback)); + $this->assertFalse($this->apiEvent->hasCallback($callback, $object)); + $this->assertFalse($this->apiEvent->hasCallbackObject($object)); + $this->assertFalse($this->apiEvent->hasCallbackObject($object, $callback)); + $this->assertNull($this->apiEvent->getCallback($object)); + $this->assertNull($this->apiEvent->getCallbackObject($callback)); + } + + public function testSetRequirements() + { + $this->apiEvent->setRequirements($object = new \stdClass(), $requirements = [$requirement = 'requirement']); + $this->apiEvent->setRequirements($object, $requirements); + + $this->assertTrue($this->apiEvent->hasRequirements()); + $this->assertTrue($this->apiEvent->hasRequirements($object)); + $this->assertTrue($this->apiEvent->hasRequirement($object)); + $this->assertTrue($this->apiEvent->hasRequirement($object, $requirement)); + $this->assertSame($requirements, $this->apiEvent->getRequirementsObject($object)); + } + + public function testAddRequirements() + { + $this->apiEvent->setRequirements($object = new \stdClass(), $firstRequirements = ['requirement1']); + $this->apiEvent->addRequirements($object, $secondRequirements = ['requirement2']); + + $this->assertTrue($this->apiEvent->hasRequirements()); + $this->assertTrue($this->apiEvent->hasRequirements($object)); + $this->assertTrue($this->apiEvent->hasRequirement($object)); + $this->assertSame( + array_merge($firstRequirements, $secondRequirements), + $this->apiEvent->getRequirementsObject($object) + ); + } + + public function testAddRequirement() + { + $this->apiEvent->addRequirement($object = new \stdClass(), $requirement = 'requirement'); + + $this->assertTrue($this->apiEvent->hasRequirements()); + $this->assertTrue($this->apiEvent->hasRequirements($object)); + $this->assertTrue($this->apiEvent->hasRequirement($object)); + $this->assertTrue($this->apiEvent->hasRequirement($object, $requirement)); + $this->assertSame([$requirement], $this->apiEvent->getRequirementsObject($object)); + } + + public function testRemoveRequirement() + { + $this->apiEvent->addRequirement($object = new \stdClass(), $requirement1 = 'requirement1'); + $this->apiEvent->addRequirement($object, $requirement2 = 'requirement2'); + $this->apiEvent->removeRequirement($object, $requirement2); + + $this->assertTrue($this->apiEvent->hasRequirements()); + $this->assertTrue($this->apiEvent->hasRequirements($object)); + $this->assertTrue($this->apiEvent->hasRequirement($object)); + $this->assertTrue($this->apiEvent->hasRequirement($object, $requirement1)); + $this->assertFalse($this->apiEvent->hasRequirement($object, $requirement2)); + $this->assertSame([$requirement1], $this->apiEvent->getRequirementsObject($object)); + + $this->apiEvent->removeRequirement($object, $requirement1); + + $this->assertFalse($this->apiEvent->hasRequirements()); + $this->assertFalse($this->apiEvent->hasRequirements($object)); + $this->assertFalse($this->apiEvent->hasRequirement($object)); + $this->assertFalse($this->apiEvent->hasRequirement($object, $requirement1)); + $this->assertEmpty($this->apiEvent->getRequirementsObject($object)); + } +} diff --git a/tests/Helper/Event/EventTest.php b/tests/Helper/Event/EventTest.php new file mode 100644 index 00000000..1f9dc772 --- /dev/null +++ b/tests/Helper/Event/EventTest.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Event; + +use Ivory\GoogleMap\Helper\Event\AbstractEvent; +use Symfony\Component\EventDispatcher\Event; + +/** + * @author GeLo + */ +class EventTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AbstractEvent + */ + private $event; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->event = $this->createAbstractEventMock(); + } + + public function testInheritance() + { + $this->assertInstanceOf(Event::class, $this->event); + } + + public function testDefaultState() + { + $this->assertFalse($this->event->hasCode()); + $this->assertSame('', $this->event->getCode()); + } + + public function testSetCode() + { + $this->event->setCode($code = 'code'); + $this->event->setCode($code); + + $this->assertTrue($this->event->hasCode()); + $this->assertSame($code, $this->event->getCode()); + } + + public function testAddCode() + { + $this->event->setCode($firstCode = 'code1'); + $this->event->addCode($secondCode = 'code2'); + + $this->assertTrue($this->event->hasCode()); + $this->assertSame($firstCode.$secondCode, $this->event->getCode()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|AbstractEvent + */ + private function createAbstractEventMock() + { + return $this->getMockForAbstractClass(AbstractEvent::class); + } +} diff --git a/tests/Helper/Event/MapEventTest.php b/tests/Helper/Event/MapEventTest.php new file mode 100644 index 00000000..99ebec63 --- /dev/null +++ b/tests/Helper/Event/MapEventTest.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Event; + +use Ivory\GoogleMap\Helper\Event\AbstractEvent; +use Ivory\GoogleMap\Helper\Event\MapEvent; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class MapEventTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapEvent + */ + private $mapEvent; + + /** + * @var Map|\PHPUnit_Framework_MockObject_MockObject + */ + private $map; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->map = $this->createMapMock(); + $this->mapEvent = new MapEvent($this->map); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractEvent::class, $this->mapEvent); + } + + public function testDefaultState() + { + $this->assertSame($this->map, $this->mapEvent->getMap()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Map + */ + private function createMapMock() + { + return $this->createMock(Map::class); + } +} diff --git a/tests/Helper/Event/PlaceAutocompleteEventTest.php b/tests/Helper/Event/PlaceAutocompleteEventTest.php new file mode 100644 index 00000000..41ae2995 --- /dev/null +++ b/tests/Helper/Event/PlaceAutocompleteEventTest.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Event; + +use Ivory\GoogleMap\Helper\Event\AbstractEvent; +use Ivory\GoogleMap\Helper\Event\PlaceAutocompleteEvent; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class PlaceAutocompleteEventTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PlaceAutocompleteEvent + */ + private $placeAutocompleteEvent; + + /** + * @var Autocomplete|\PHPUnit_Framework_MockObject_MockObject + */ + private $autocomplete; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->autocomplete = $this->createAutocompleteMock(); + $this->placeAutocompleteEvent = new PlaceAutocompleteEvent($this->autocomplete); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractEvent::class, $this->placeAutocompleteEvent); + } + + public function testDefaultState() + { + $this->assertSame($this->autocomplete, $this->placeAutocompleteEvent->getAutocomplete()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Autocomplete + */ + private function createAutocompleteMock() + { + return $this->createMock(Autocomplete::class); + } +} diff --git a/tests/Helper/Events/EventManagerHelperTest.php b/tests/Helper/Events/EventManagerHelperTest.php deleted file mode 100644 index 30953008..00000000 --- a/tests/Helper/Events/EventManagerHelperTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Controls; - -use Ivory\GoogleMap\Events\Event; -use Ivory\GoogleMap\Helper\Events\EventManagerHelper; - -/** - * Event manager helper test. - * - * @author GeLo - */ -class EventManagerHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Events\EventHelper */ - protected $eventManagerHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->eventManagerHelper = new EventManagerHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->eventManagerHelper); - } - - public function testRenderDomEvent() - { - $domEvent = new Event('instance', 'event_name', 'handle', true); - $domEvent->setJavascriptVariable('foo'); - - $this->assertSame( - 'foo = google.maps.event.addDomListener(instance, "event_name", handle, true);'.PHP_EOL, - $this->eventManagerHelper->renderDomEvent($domEvent) - ); - } - - public function testRenderDomEventOnce() - { - $domEventOnce = new Event('instance', 'event_name', 'handle', true); - $domEventOnce->setJavascriptVariable('foo'); - - $this->assertSame( - 'foo = google.maps.event.addDomListenerOnce(instance, "event_name", handle, true);'.PHP_EOL, - $this->eventManagerHelper->renderDomEventOnce($domEventOnce) - ); - } - - public function testRenderEvent() - { - $event = new Event('instance', 'event_name', 'handle', true); - $event->setJavascriptVariable('foo'); - - $this->assertSame( - 'foo = google.maps.event.addListener(instance, "event_name", handle);'.PHP_EOL, - $this->eventManagerHelper->renderEvent($event) - ); - } - - public function testRenderEventOnce() - { - $eventOnce = new Event('instance', 'event_name', 'handle'); - $eventOnce->setJavascriptVariable('foo'); - - $this->assertSame( - 'foo = google.maps.event.addListenerOnce(instance, "event_name", handle);'.PHP_EOL, - $this->eventManagerHelper->renderEventOnce($eventOnce) - ); - } -} diff --git a/tests/Helper/Extension/CoreExtensionHelperTest.php b/tests/Helper/Extension/CoreExtensionHelperTest.php deleted file mode 100644 index a5cc044f..00000000 --- a/tests/Helper/Extension/CoreExtensionHelperTest.php +++ /dev/null @@ -1,149 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Extension; - -use Ivory\GoogleMap\Helper\Extension\CoreExtensionHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\EncodedPolyline; - -/** - * Core extension helper test. - * - * @author GeLo - */ -class CoreExtensionHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Extension\CoreExtensionHelper */ - protected $coreExtensionHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->coreExtensionHelper = new CoreExtensionHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->coreExtensionHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf('Ivory\GoogleMap\Helper\ApiHelper', $this->coreExtensionHelper->getApiHelper()); - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper', - $this->coreExtensionHelper->getMarkerClusterHelper() - ); - } - - public function testInitialState() - { - $apiHelper = $this->getMock('Ivory\GoogleMap\Helper\ApiHelper'); - $markerClusterHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper'); - - $this->coreExtensionHelper = new CoreExtensionHelper($apiHelper, $markerClusterHelper); - - $this->assertSame($apiHelper, $this->coreExtensionHelper->getApiHelper()); - $this->assertSame($markerClusterHelper, $this->coreExtensionHelper->getMarkerClusterHelper()); - } - - public function testRenderLibrariesWithDefaultMap() - { - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - -EOF; - - $this->assertSame($expected, $this->coreExtensionHelper->renderLibraries(new Map())); - } - - public function testRenderLibrariesWithAsyncMap() - { - $map = new Map(); - $map->setAsync(true); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false","callback":load_ivory_google_map}); }; - - - -EOF; - - $this->assertSame($expected, $this->coreExtensionHelper->renderLibraries($map)); - } - - public function testRenderLibrariesWithMapLibrariesAndEncodedPolylines() - { - $map = new Map(); - $map->setLibraries(array('places')); - $map->addEncodedPolyline(new EncodedPolyline('foo')); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"libraries=places,geometry&language=en&sensor=false"}); }; - - - -EOF; - - $this->assertSame($expected, $this->coreExtensionHelper->renderLibraries($map)); - } - - public function testRenderLibrariesWithMultipleMaps() - { - $expected1 = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - -EOF; - - $this->assertSame($expected1, $this->coreExtensionHelper->renderLibraries(new Map())); - $this->assertNull($this->coreExtensionHelper->renderLibraries(new Map())); - } - - public function testRenderBeforeWithDefaultMap() - { - $this->assertNull($this->coreExtensionHelper->renderBefore(new Map())); - } - - public function testRenderBeforeWithAsyncMap() - { - $map = new Map(); - $map->setAsync(true); - - $this->assertSame('function load_ivory_google_map() {'.PHP_EOL, $this->coreExtensionHelper->renderBefore($map)); - } - - public function testRenderAfterWithDefaultMap() - { - $this->assertNull($this->coreExtensionHelper->renderAfter(new Map())); - } - - public function testRenderAfterWithAsyncMap() - { - $map = new Map(); - $map->setAsync(true); - - $this->assertSame('}'.PHP_EOL, $this->coreExtensionHelper->renderAfter($map)); - } -} diff --git a/tests/Helper/Extension/InfoBoxExtensionHelperTest.php b/tests/Helper/Extension/InfoBoxExtensionHelperTest.php deleted file mode 100644 index 188b797d..00000000 --- a/tests/Helper/Extension/InfoBoxExtensionHelperTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Extension; - -use Ivory\GoogleMap\Helper\Extension\InfoBoxExtensionHelper; - -/** - * InfoBox extension helper test. - * - * @author GeLo - */ -class InfoBoxExtensionHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Extension\InfoBoxExtensionHelper */ - protected $infoBoxExtensionHelper; - - /** - * {@ineritdoc} - */ - protected function setUp() - { - $this->infoBoxExtensionHelper = new InfoBoxExtensionHelper(); - } - - /** - * {@ineritdoc} - */ - protected function tearDown() - { - unset($this->infoBoxExtensionHelper); - } - - public function testDefaultState() - { - $this->assertSame( - '//google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox_packed.js', - $this->infoBoxExtensionHelper->getSource() - ); - - $this->assertSame('load_ivory_google_map_info_box', $this->infoBoxExtensionHelper->getCallback()); - } - - public function testInitialState() - { - $this->infoBoxExtensionHelper = new InfoBoxExtensionHelper('foo', 'bar'); - - $this->assertSame('foo', $this->infoBoxExtensionHelper->getSource()); - $this->assertSame('bar', $this->infoBoxExtensionHelper->getCallback()); - } - - public function testRenderLibrariesWithSyncMap() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - - $expected = << - -EOF; - - $this->assertSame($expected, $this->infoBoxExtensionHelper->renderLibraries($map)); - } - - public function testRenderBeforeWithSyncMap() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - - $this->assertNull($this->infoBoxExtensionHelper->renderBefore($map)); - } - - public function testRenderAfterWithSyncMap() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - - $this->assertNull($this->infoBoxExtensionHelper->renderAfter($map)); - } - - public function testRenderLibrariesWithAsyncMap() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('isAsync') - ->will($this->returnValue(true)); - - $this->assertNull($this->infoBoxExtensionHelper->renderLibraries($map)); - } - - public function testRenderBeforeWithAsyncMap() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('isAsync') - ->will($this->returnValue(true)); - - $expected = <<assertSame($expected, $this->infoBoxExtensionHelper->renderBefore($map)); - } - - public function testRenderAfterWithAsyncMap() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('isAsync') - ->will($this->returnValue(true)); - - $expected = <<assertSame($expected, $this->infoBoxExtensionHelper->renderAfter($map)); - } -} diff --git a/tests/Helper/Formatter/FormatterTest.php b/tests/Helper/Formatter/FormatterTest.php new file mode 100644 index 00000000..fc2c4ba6 --- /dev/null +++ b/tests/Helper/Formatter/FormatterTest.php @@ -0,0 +1,766 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Formatter; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class FormatterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Formatter + */ + private $formatter; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->formatter = new Formatter(); + } + + public function testDefaultState() + { + $this->assertSame(0, $this->formatter->getDefaultIndentation()); + $this->assertSame(4, $this->formatter->getIndentationStep()); + $this->assertFalse($this->formatter->isDebug()); + } + + /** + * @param string $expected + * @param string|null $name + * @param string|null $namespace + * + * @dataProvider classProvider + */ + public function testRenderClass($expected, $name = null, $namespace = null) + { + $this->assertSame($expected, $this->formatter->renderClass($name, $namespace)); + } + + /** + * @param string $expected + * @param string $class + * @param string $value + * @param string|null $namespace + * + * @dataProvider constantProvider + */ + public function testRenderConstant($expected, $class, $value, $namespace = null) + { + $this->assertSame($expected, $this->formatter->renderConstant($class, $value, $namespace)); + } + + /** + * @param string $expected + * @param string $class + * @param string[] $arguments + * @param string|null $namespace + * @param bool $semicolon + * @param bool $newLine + * @param bool $debug + * + * @dataProvider objectProvider + */ + public function testRenderObject( + $expected, + $class, + array $arguments = [], + $namespace = null, + $semicolon = false, + $newLine = false, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderObject( + $class, + $arguments, + $namespace, + $semicolon, + $newLine + )); + } + + /** + * @param string $expected + * @param string $object + * @param string|null $property + * + * @dataProvider propertyProvider + */ + public function testRenderProperty($expected, $object, $property = null) + { + $this->assertSame($expected, $this->formatter->renderProperty($object, $property)); + } + + /** + * @param string $expected + * @param VariableAwareInterface $object + * @param string $method + * @param string[] $arguments + * @param bool $semicolon + * @param bool $newLine + * @param bool $debug + * + * @dataProvider objectCallProvider + */ + public function testRenderObjectCall( + $expected, + VariableAwareInterface $object, + $method, + array $arguments = [], + $semicolon = false, + $newLine = false, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderObjectCall( + $object, + $method, + $arguments, + $semicolon, + $newLine + )); + } + + /** + * @param string $expected + * @param string $method + * @param string[] $arguments + * @param bool $semicolon + * @param bool $newLine + * @param bool $debug + * + * @dataProvider callProvider + */ + public function testRenderCall( + $expected, + $method, + array $arguments = [], + $semicolon = false, + $newLine = false, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderCall( + $method, + $arguments, + $semicolon, + $newLine + )); + } + + /** + * @param string $expected + * @param string|null $code + * @param string[] $arguments + * @param string|null $name + * @param bool $semicolon + * @param bool $newLine + * @param bool $debug + * + * @dataProvider closureProvider + */ + public function testRenderClosure( + $expected, + $code = null, + array $arguments = [], + $name = null, + $semicolon = false, + $newLine = false, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderClosure( + $code, + $arguments, + $name, + $semicolon, + $newLine + )); + } + + /** + * @param string $expected + * @param VariableAwareInterface $object + * @param string $declaration + * @param bool $semicolon + * @param bool $newLine + * @param bool $debug + * + * @dataProvider objectAssignmentProvider + */ + public function testRenderObjectAssignment( + $expected, + VariableAwareInterface $object, + $declaration, + $semicolon = false, + $newLine = false, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderObjectAssignment( + $object, + $declaration, + $semicolon, + $newLine + )); + } + + /** + * @param string $expected + * @param VariableAwareInterface $root + * @param string $declaration + * @param string|null $propertyPath + * @param VariableAwareInterface|null $object + * @param bool $semicolon + * @param bool $newLine + * @param bool $debug + * + * @dataProvider containerAssignmentProvider + */ + public function testRenderContainerAssignment( + $expected, + VariableAwareInterface $root, + $declaration, + $propertyPath = null, + VariableAwareInterface $object = null, + $semicolon = true, + $newLine = true, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderContainerAssignment( + $root, + $declaration, + $propertyPath, + $object, + $semicolon, + $newLine + )); + } + + /** + * @param string $expected + * @param VariableAwareInterface $root + * @param string|null $propertyPath + * @param VariableAwareInterface|null $object + * @param bool $debug + * + * @dataProvider containerVariableProvider + */ + public function testRenderContainerVariable( + $expected, + VariableAwareInterface $root, + $propertyPath = null, + VariableAwareInterface $object = null, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderContainerVariable($root, $propertyPath, $object)); + } + + /** + * @param string $expected + * @param string $variable + * @param string $declaration + * @param bool $semicolon + * @param bool $newLine + * @param bool $debug + * + * @dataProvider assignmentProvider + */ + public function testRenderAssignment( + $expected, + $variable, + $declaration, + $semicolon = false, + $newLine = false, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderAssignment( + $variable, + $declaration, + $semicolon, + $newLine + )); + } + + /** + * @param string $expected + * @param string $statement + * @param string $code + * @param string|null $condition + * @param string|null $next + * @param bool $newLine + * @param bool $debug + * + * @dataProvider statementProvider + */ + public function testRenderStatement( + $expected, + $statement, + $code, + $condition = null, + $next = null, + $newLine = true, + $debug = false + ) { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderStatement( + $statement, + $code, + $condition, + $next, + $newLine + )); + } + + /** + * @param string $expected + * @param string $code + * @param bool $semicolon + * @param bool $newLine + * @param bool $debug + * + * @dataProvider codeProvider + */ + public function testRenderCode($expected, $code, $semicolon = true, $newLine = true, $debug = false) + { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderCode($code, $semicolon, $newLine)); + } + + /** + * @param string $expected + * @param string|null $code + * @param bool $debug + * + * @dataProvider indentationProvider + */ + public function testRenderIndentation($expected, $code = null, $debug = false) + { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderIndentation($code)); + } + + /** + * @param string $expected + * @param string[] $codes + * @param bool $newLine + * @param bool $eolLine + * @param bool $debug + * + * @dataProvider linesProvider + */ + public function testRenderLines($expected, array $codes = [], $newLine = true, $eolLine = true, $debug = false) + { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderLines($codes, $newLine, $eolLine)); + } + + /** + * @param string $expected + * @param string|null $code + * @param bool $newLine + * @param bool $debug + * + * @dataProvider lineProvider + */ + public function testRenderLine($expected, $code = null, $newLine = true, $debug = false) + { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderLine($code, $newLine)); + } + + /** + * @param string $expected + * @param string $argument + * + * @dataProvider escapeProvider + */ + public function testRenderEscape($expected, $argument) + { + $this->assertSame($expected, $this->formatter->renderEscape($argument)); + } + + /** + * @param string $expected + * @param bool $debug + * + * @dataProvider separatorProvider + */ + public function testRenderSeparator($expected, $debug = false) + { + $this->formatter->setDebug($debug); + + $this->assertSame($expected, $this->formatter->renderSeparator()); + } + + /** + * @return mixed[][] + */ + public function classProvider() + { + return [ + ['google.maps'], + ['google.maps.name', 'name'], + ['namespace', null, 'namespace'], + ['name', 'name', false], + ['namespace.name', 'name', 'namespace'], + ]; + } + + /** + * @return string[][] + */ + public function constantProvider() + { + return [ + ['google.maps.class.VALUE', 'class', 'value'], + ['namespace.class.VALUE', 'class', 'value', 'namespace'], + ]; + } + + /** + * @return mixed[][] + */ + public function objectProvider() + { + return [ + // Debug disabled + ['new google.maps.class()', 'class'], + ['new google.maps.class(arg1,arg2)', 'class', ['arg1', 'arg2']], + ['new namespace.class()', 'class', [], 'namespace'], + ['new google.maps.class();', 'class', [], null, true], + ['new google.maps.class()', 'class', [], null, false, true], + ['new namespace.class(arg1,arg2);', 'class', ['arg1', 'arg2'], 'namespace', true, true], + + // Debug enabled + ['new google.maps.class()', 'class', [], null, false, false, true], + ['new google.maps.class(arg1, arg2)', 'class', ['arg1', 'arg2'], null, false, false, true], + ['new namespace.class()', 'class', [], 'namespace', false, false, true], + ['new google.maps.class();', 'class', [], null, true, false, true], + ['new google.maps.class()'.PHP_EOL, 'class', [], null, false, true, true], + ['new namespace.class(arg1, arg2);'.PHP_EOL, 'class', ['arg1', 'arg2'], 'namespace', true, true, true], + ]; + } + + /** + * @return string[][] + */ + public function propertyProvider() + { + return [ + ['object', 'object'], + ['object.property', 'object', 'property'], + ]; + } + + /** + * @return mixed[][] + */ + public function objectCallProvider() + { + return [ + // Debug disabled + ['variable.method()', $this->createVariableAwareMock(), 'method'], + ['variable.method(arg1,arg2)', $this->createVariableAwareMock(), 'method', ['arg1', 'arg2']], + ['variable.method();', $this->createVariableAwareMock(), 'method', [], true], + ['variable.method()', $this->createVariableAwareMock(), 'method', [], false, true], + ['variable.method(arg1,arg2);', $this->createVariableAwareMock(), 'method', ['arg1', 'arg2'], true, true], + + // Debug enabled + ['variable.method()', $this->createVariableAwareMock(), 'method', [], false, false, true], + ['variable.method(arg1, arg2)', $this->createVariableAwareMock(), 'method', ['arg1', 'arg2'], false, false, true], + ['variable.method();', $this->createVariableAwareMock(), 'method', [], true, false, true], + ['variable.method()'.PHP_EOL, $this->createVariableAwareMock(), 'method', [], false, true, true], + ['variable.method(arg1, arg2);'.PHP_EOL, $this->createVariableAwareMock(), 'method', ['arg1', 'arg2'], true, true, true], + ]; + } + + /** + * @return mixed[][] + */ + public function callProvider() + { + return [ + // Debug disabled + ['method()', 'method'], + ['method(arg1,arg2)', 'method', ['arg1', 'arg2']], + ['method();', 'method', [], true], + ['method()', 'method', [], false, true], + ['method(arg1,arg2);', 'method', ['arg1', 'arg2'], true, true], + + // Debug enabled + ['method()', 'method', [], false, false, true], + ['method(arg1, arg2)', 'method', ['arg1', 'arg2'], false, false, true], + ['method();', 'method', [], true, false, true], + ['method()'.PHP_EOL, 'method', [], false, true, true], + ['method(arg1, arg2);'.PHP_EOL, 'method', ['arg1', 'arg2'], true, true, true], + ]; + } + + /** + * @return mixed[][] + */ + public function closureProvider() + { + return [ + ['function(){}'], + ['function(){code}', 'code'], + ['function(arg1,arg2){}', null, ['arg1', 'arg2']], + ['function name(){}', null, [], 'name'], + ['function(){};', null, [], null, true], + ['function(){}', null, [], null, false, true], + ['function name(arg1,arg2){code};', 'code', ['arg1', 'arg2'], 'name', true, true], + + ['function () {}', null, [], null, false, false, true], + ['function () {'.PHP_EOL.' code'.PHP_EOL.'}', 'code', [], null, false, false, true], + ['function (arg1, arg2) {}', null, ['arg1', 'arg2'], null, false, false, true], + ['function name () {}', null, [], 'name', false, false, true], + ['function () {};', null, [], null, true, false, true], + ['function () {}'.PHP_EOL, null, [], null, false, true, true], + ['function name (arg1, arg2) {'.PHP_EOL.' code'.PHP_EOL.'};'.PHP_EOL, 'code', ['arg1', 'arg2'], 'name', true, true, true], + ]; + } + + /** + * @return mixed[][] + */ + public function objectAssignmentProvider() + { + return [ + // Debug disabled + ['variable=declaration', $this->createVariableAwareMock(), 'declaration'], + ['variable=declaration;', $this->createVariableAwareMock(), 'declaration', true], + ['variable=declaration', $this->createVariableAwareMock(), 'declaration', false, true], + ['variable=declaration;', $this->createVariableAwareMock(), 'declaration', true, true], + + // Debug enabled + ['variable = declaration', $this->createVariableAwareMock(), 'declaration', false, false, true], + ['variable = declaration;', $this->createVariableAwareMock(), 'declaration', true, false, true], + ['variable = declaration'.PHP_EOL, $this->createVariableAwareMock(), 'declaration', false, true, true], + ['variable = declaration;'.PHP_EOL, $this->createVariableAwareMock(), 'declaration', true, true, true], + ]; + } + + /** + * @return mixed[][] + */ + public function containerAssignmentProvider() + { + return [ + // Debug disabled + ['root_container=declaration;', $this->createVariableAwareMock('root'), 'declaration'], + ['root_container.path=declaration;', $this->createVariableAwareMock('root'), 'declaration', 'path'], + ['root_container.variable=declaration;', $this->createVariableAwareMock('root'), 'declaration', null, $this->createVariableAwareMock()], + ['root_container=declaration', $this->createVariableAwareMock('root'), 'declaration', null, null, false], + ['root_container=declaration;', $this->createVariableAwareMock('root'), 'declaration', null, null, true, false], + ['root_container.path.variable=declaration', $this->createVariableAwareMock('root'), 'declaration', 'path', $this->createVariableAwareMock(), false, false], + + // Debug enabled + ['root_container = declaration;'.PHP_EOL, $this->createVariableAwareMock('root'), 'declaration', null, null, true, true, true], + ['root_container.path = declaration;'.PHP_EOL, $this->createVariableAwareMock('root'), 'declaration', 'path', null, true, true, true], + ['root_container.variable = declaration;'.PHP_EOL, $this->createVariableAwareMock('root'), 'declaration', null, $this->createVariableAwareMock(), true, true, true], + ['root_container = declaration'.PHP_EOL, $this->createVariableAwareMock('root'), 'declaration', null, null, false, true, true], + ['root_container = declaration;', $this->createVariableAwareMock('root'), 'declaration', null, null, true, false, true], + ['root_container.path.variable = declaration', $this->createVariableAwareMock('root'), 'declaration', 'path', $this->createVariableAwareMock(), false, false, true], + ]; + } + + /** + * @return mixed[] + */ + public function containerVariableProvider() + { + return [ + ['root_container', $this->createVariableAwareMock('root')], + ['root_container.path', $this->createVariableAwareMock('root'), 'path'], + ['root_container.variable', $this->createVariableAwareMock('root'), null, $this->createVariableAwareMock()], + ['root_container.path.variable', $this->createVariableAwareMock('root'), 'path', $this->createVariableAwareMock()], + ]; + } + + /** + * @return mixed[] + */ + public function assignmentProvider() + { + return [ + // Debug disabled + ['variable=declaration', 'variable', 'declaration'], + ['variable=declaration;', 'variable', 'declaration', true], + ['variable=declaration', 'variable', 'declaration', false, true], + ['variable=declaration;', 'variable', 'declaration', true, true], + + // Debug enabled + ['variable = declaration', 'variable', 'declaration', false, false, true], + ['variable = declaration;', 'variable', 'declaration', true, false, true], + ['variable = declaration'.PHP_EOL, 'variable', 'declaration', false, true, true], + ['variable = declaration;'.PHP_EOL, 'variable', 'declaration', true, true, true], + ]; + } + + /** + * @return mixed[][] + */ + public function statementProvider() + { + return [ + // Debug disabled + ['else{code}', 'else', 'code'], + ['if(condition){code}', 'if', 'code', 'condition'], + ['if(condition){code}else{}', 'if', 'code', 'condition', 'else{}', false], + + // Debug enabled + ['else {'.PHP_EOL.' code'.PHP_EOL.'}'.PHP_EOL, 'else', 'code', null, null, true, true], + ['if (condition) {'.PHP_EOL.' code'.PHP_EOL.'}'.PHP_EOL, 'if', 'code', 'condition', null, true, true], + ['if (condition) {'.PHP_EOL.' code'.PHP_EOL.'} else {}', 'if', 'code', 'condition', 'else {}', false, true], + ]; + } + + /** + * @return mixed[] + */ + public function codeProvider() + { + return [ + // Debug disabled + ['code;', 'code'], + ['code', 'code', false], + ['code;', 'code', true, false], + + // Debug enabled + ['code;'.PHP_EOL, 'code', true, true, true], + ['code'.PHP_EOL, 'code', false, true, true], + ['code;', 'code', true, false, true], + ]; + } + + /** + * @return mixed[][] + */ + public function indentationProvider() + { + return [ + // Debug disabled + [''], + ['code', 'code'], + + // Debug enabled + ['', null, true], + [' code', 'code', true], + ]; + } + + /** + * @return mixed[][] + */ + public function linesProvider() + { + return [ + // Debug disabled + [''], + ['line1;line2;', ['line1;', 'line2;']], + ['line1;line2;', ['line1;', 'line2;'], false], + ['line1;line2;', ['line1;', 'line2;'], true, false], + ['line1;line2;', ['line1;', 'line2;'], false, false], + + // Debug enabled + ['', [], true, true, true], + ['line1;'.PHP_EOL.'line2;'.PHP_EOL, ['line1;', 'line2;'], true, true, true], + ['line1;line2;'.PHP_EOL, ['line1;', 'line2;'], false, true, true], + ['line1;'.PHP_EOL.'line2;', ['line1;', 'line2;'], true, false, true], + ['line1;line2;', ['line1;', 'line2;'], false, false, true], + ]; + } + + /** + * @return mixed[][] + */ + public function lineProvider() + { + return [ + // Debug disabled + [''], + ['line', 'line'], + ['line', 'line', false], + + // Debug enabled + ['', null, true, true], + ['line'.PHP_EOL, 'line', true, true], + ['line', 'line', false, true], + ]; + } + + /** + * @return mixed[][] + */ + public function escapeProvider() + { + return [ + ['null', null], + ['true', true], + ['false', false], + ['"foo"', 'foo'], + ['"/"', '/'], + ['"\'"', '\''], + ['"\\""', '"'], + ]; + } + + /** + * @return mixed[][] + */ + public function separatorProvider() + { + return [ + [''], + [' ', true], + ]; + } + + /** + * @param string $variable + * + * @return \PHPUnit_Framework_MockObject_MockObject|VariableAwareInterface + */ + private function createVariableAwareMock($variable = 'variable') + { + $variableAware = $this->createMock(VariableAwareInterface::class); + $variableAware + ->expects($this->once()) + ->method('getVariable') + ->will($this->returnValue($variable)); + + return $variableAware; + } +} diff --git a/tests/Helper/Functional/AbstractApiFunctionalTest.php b/tests/Helper/Functional/AbstractApiFunctionalTest.php new file mode 100644 index 00000000..9ac569c2 --- /dev/null +++ b/tests/Helper/Functional/AbstractApiFunctionalTest.php @@ -0,0 +1,215 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\ApiHelper; +use Ivory\GoogleMap\Helper\Builder\ApiHelperBuilder; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +abstract class AbstractApiFunctionalTest extends AbstractFunctionalTest +{ + /** + * @var ApiHelper + */ + private $apiHelper; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + parent::setUp(); + + $this->apiHelper = $this->createApiHelper(); + } + + /** + * @return ApiHelper + */ + protected function createApiHelper() + { + return ApiHelperBuilder::create()->build(); + } + + /** + * @param object[] $objects + * + * @return string + */ + protected function renderApi(array $objects) + { + return $this->apiHelper->render($objects); + } + + /** + * @param string[] $libraries + */ + protected function assertLibraries(array $libraries) + { + foreach ($libraries as $library) { + $this->assertVariableExists('google.maps.'.$library); + } + } + + /** + * @param VariableAwareInterface $object + * @param Bound $bound + * @param string|null $expected + */ + protected function assertBound(VariableAwareInterface $object, Bound $bound, $expected = null) + { + $this->assertSameContainerVariable( + $object, + 'base.bounds', + $bound, + $expected, + function ($expected, $variable) { + $formatter = function ($expected, $variable, $method) { + return $expected.'.contains('.$variable.'.'.$method.'())'; + }; + + return implode(' && ', [ + call_user_func($formatter, $expected, $variable, 'getSouthWest'), + call_user_func($formatter, $expected, $variable, 'getNorthEast'), + ]); + } + ); + + if (!empty($expected)) { + return; + } + + if ($bound->hasSouthWest()) { + $this->assertCoordinate($object, $bound->getSouthWest(), $bound->getVariable().'.getSouthWest()'); + } + + if ($bound->hasNorthEast()) { + $this->assertCoordinate($object, $bound->getNorthEast(), $bound->getVariable().'.getNorthEast()'); + } + } + + /** + * @param VariableAwareInterface $object + * @param Coordinate $coordinate + * @param string|null $expected + */ + protected function assertCoordinate(VariableAwareInterface $object, Coordinate $coordinate, $expected = null) + { + $this->assertSameContainerVariable($object, 'base.coordinates', $coordinate, $expected); + $this->assertSameVariable($coordinate->getVariable().'.lat()', $coordinate->getLatitude()); + $this->assertSameVariable($coordinate->getVariable().'.lng()', $coordinate->getLongitude()); + } + + /** + * @param VariableAwareInterface $object + * @param Point $point + * @param string|null $expected + */ + protected function assertPoint(VariableAwareInterface $object, Point $point, $expected = null) + { + $this->assertSameContainerVariable($object, 'base.points', $point, $expected); + $this->assertSameVariable($point->getVariable().'.x', $point->getX()); + $this->assertSameVariable($point->getVariable().'.y', $point->getY()); + } + + /** + * @param VariableAwareInterface $object + * @param Size $size + * @param string|null $expected + */ + protected function assertSize(VariableAwareInterface $object, Size $size, $expected = null) + { + $this->assertSameContainerVariable($object, 'base.sizes', $size, $expected); + $this->assertSameVariable($size->getVariable().'.width', $size->getWidth()); + $this->assertSameVariable($size->getVariable().'.height', $size->getHeight()); + } + + /** + * @param VariableAwareInterface $root + * @param string|null $propertyPath + */ + protected function assertContainerVariableExists(VariableAwareInterface $root, $propertyPath = null) + { + $this->assertVariableExists($this->getContainer($root, $propertyPath)); + } + + /** + * @param VariableAwareInterface $root + * @param string $propertyPath + * @param VariableAwareInterface|null $object + * @param string|null $expected + * @param callable|null $formatter + */ + protected function assertSameContainerVariable( + VariableAwareInterface $root, + $propertyPath, + VariableAwareInterface $object = null, + $expected = null, + $formatter = null + ) { + $this->assertSameObject($this->getContainer($root, $propertyPath, $object), $object ?: $root); + + if (!empty($expected)) { + $this->assertSameObject($expected, $object ?: $root, $formatter); + } + } + + /** + * @param VariableAwareInterface $object + */ + protected function assertObjectExists(VariableAwareInterface $object) + { + $this->assertVariableExists($object->getVariable()); + } + + /** + * @param string $expected + * @param VariableAwareInterface $object + * @param callable|null $formatter + */ + protected function assertSameObject($expected, VariableAwareInterface $object, $formatter = null) + { + $this->assertSameVariable($expected, $object->getVariable(), $formatter); + } + + /** + * @param VariableAwareInterface $root + * @param string|null $propertyPath + * @param VariableAwareInterface|null $object + * + * @return string + */ + private function getContainer( + VariableAwareInterface $root, + $propertyPath = null, + VariableAwareInterface $object = null + ) { + $variable = $root->getVariable().'_container'; + + if (!empty($propertyPath)) { + $variable .= '.'.$propertyPath; + } + + if ($object !== null) { + $variable .= '.'.$object->getVariable(); + } + + return $variable; + } +} diff --git a/tests/Helper/Functional/AbstractFunctionalTest.php b/tests/Helper/Functional/AbstractFunctionalTest.php new file mode 100644 index 00000000..59ade89a --- /dev/null +++ b/tests/Helper/Functional/AbstractFunctionalTest.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional; + +/** + * @author GeLo + */ +abstract class AbstractFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase +{ + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->setBrowser(isset($_SERVER['BROWSER_NAME']) ? $_SERVER['BROWSER_NAME'] : 'chrome'); + $this->setBrowserUrl('file://'.sys_get_temp_dir()); + } + + /** + * @param string|string[] $html + */ + protected function renderHtml($html) + { + $name = tempnam(sys_get_temp_dir(), uniqid()); + $file = fopen($name, 'w+'); + fwrite($file, ''.implode('', (array) $html).''); + fflush($file); + + $this->url(basename($name)); + + unlink($name); + fclose($file); + } + + /** + * @param string $variable + */ + protected function assertVariableExists($variable) + { + $this->assertTrue($this->executeJavascript($script = 'typeof '.$variable.' !== typeof undefined'), $script); + } + + /** + * @param string $expected + * @param string $variable + * @param callable|null $formatter + */ + protected function assertSameVariable($expected, $variable, $formatter = null) + { + $defaultFormatter = function ($expected, $variable) { + return $expected.' === '.$variable; + }; + + $formatter = $formatter ?: $defaultFormatter; + + $this->assertTrue($this->executeJavascript($script = call_user_func( + $formatter, + $expected, + $variable, + $defaultFormatter + )), $script); + } + + /** + * @param string $script + * @param mixed[] $args + * + * @return mixed + */ + private function executeJavascript($script, array $args = []) + { + return $this->execute(['script' => 'return ('.$script.')', 'args' => $args]); + } +} diff --git a/tests/Helper/Functional/AbstractMapFunctionalTest.php b/tests/Helper/Functional/AbstractMapFunctionalTest.php new file mode 100644 index 00000000..f4cd20e2 --- /dev/null +++ b/tests/Helper/Functional/AbstractMapFunctionalTest.php @@ -0,0 +1,420 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional; + +use Ivory\GoogleMap\Helper\Builder\MapHelperBuilder; +use Ivory\GoogleMap\Helper\MapHelper; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Circle; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\GoogleMap\Overlay\GroundOverlay; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\MarkerClusterType; +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Overlay\OverlayManager; +use Ivory\GoogleMap\Overlay\Polygon; +use Ivory\GoogleMap\Overlay\Polyline; +use Ivory\GoogleMap\Overlay\Rectangle; + +/** + * @author GeLo + */ +abstract class AbstractMapFunctionalTest extends AbstractApiFunctionalTest +{ + /** + * @var MapHelper + */ + private $mapHelper; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + parent::setUp(); + + $this->mapHelper = $this->createMapHelper(); + } + + /** + * @return MapHelper + */ + protected function createMapHelper() + { + return MapHelperBuilder::create()->build(); + } + + /** + * @param Map $map + */ + protected function renderMap(Map $map) + { + $this->renderHtml(implode('', [$this->mapHelper->render($map), $this->renderApi([$map])])); + + $this->waitUntil(function () use ($map) { + try { + $this->assertObjectExists($map); + + return true; + } catch (\Exception $e) { + } + }, 5000); + } + + /** + * @param Map $map + */ + protected function assertMap(Map $map) + { + $this->assertContainer($map); + $this->assertOverlayManager($map->getOverlayManager()); + + if ($map->getLayerManager()->hasKmlLayers()) { + return; + } + + if ($map->isAutoZoom()) { + $this->assertBound($map, $map->getBound(), $map->getVariable().'.getBounds()'); + } else { + $this->assertCoordinate($map, $map->getCenter(), $map->getVariable().'.getCenter()'); + } + } + + /** + * @param Map $map + */ + protected function assertMapHtml(Map $map) + { + $this->byId($map->getHtmlId()); + } + + /** + * @param OverlayManager $overlayManager + */ + protected function assertOverlayManager(OverlayManager $overlayManager) + { + $map = $overlayManager->getMap(); + + foreach ($overlayManager->getCircles() as $circle) { + $this->assertCircle($map, $circle); + } + + foreach ($overlayManager->getEncodedPolylines() as $encodedPolyline) { + $this->assertEncodedPolyline($map, $encodedPolyline); + } + + foreach ($overlayManager->getGroundOverlays() as $groundOverlay) { + $this->assertGroundOverlay($map, $groundOverlay); + } + + foreach ($overlayManager->getInfoWindows() as $infoWindow) { + $this->assertInfoWindow($map, $infoWindow); + } + + foreach ($overlayManager->getMarkers() as $marker) { + $this->assertMarker($map, $marker); + } + + foreach ($overlayManager->getPolygons() as $polygon) { + $this->assertPolygon($map, $polygon); + } + + foreach ($overlayManager->getPolylines() as $polyline) { + $this->assertPolyline($map, $polyline); + } + + foreach ($overlayManager->getRectangles() as $rectangle) { + $this->assertRectangle($map, $rectangle); + } + } + + /** + * @param Map $map + * @param Circle $circle + */ + protected function assertCircle(Map $map, Circle $circle) + { + $this->assertSameContainerVariable( + $map, + 'overlays.circles', + $circle, + $map->getVariable(), + $this->getFormatter() + ); + + $this->assertCoordinate($map, $circle->getCenter()); + $this->assertSameVariable($circle->getRadius(), $circle->getVariable().'.getRadius()'); + } + + /** + * @param Map $map + * @param EncodedPolyline $encodedPolyline + */ + protected function assertEncodedPolyline(Map $map, EncodedPolyline $encodedPolyline) + { + $this->assertSameContainerVariable( + $map, + 'overlays.encoded_polylines', + $encodedPolyline, + $map->getVariable(), + $this->getFormatter() + ); + } + + /** + * @param Map $map + * @param GroundOverlay $groundOverlay + */ + protected function assertGroundOverlay(Map $map, GroundOverlay $groundOverlay) + { + $this->assertSameContainerVariable( + $map, + 'overlays.ground_overlays', + $groundOverlay, + $map->getVariable(), + $this->getFormatter() + ); + + $this->assertSameVariable('"'.$groundOverlay->getUrl().'"', $groundOverlay->getVariable().'.getUrl()'); + $this->assertBound($map, $groundOverlay->getBound(), $groundOverlay->getVariable().'.getBounds()'); + } + + /** + * @param Map $map + * @param InfoWindow $infoWindow + */ + protected function assertInfoWindow(Map $map, InfoWindow $infoWindow) + { + $this->assertSameContainerVariable( + $map, + $infoWindow->getType() === InfoWindowType::INFO_BOX ? 'overlays.info_boxes' : 'overlays.info_windows', + $infoWindow, + $infoWindow->getPosition() !== null ? $map->getVariable() : null, + $this->getFormatter() + ); + + $this->assertSameVariable('"'.$infoWindow->getContent().'"', $infoWindow->getVariable().'.getContent()'); + + if ($infoWindow->hasPosition()) { + $this->assertCoordinate($map, $infoWindow->getPosition(), $infoWindow->getVariable().'.getPosition()'); + } + + if ($infoWindow->hasPixelOffset() && $infoWindow->getType() !== InfoWindowType::INFO_BOX) { + $this->assertSize($map, $infoWindow->getPixelOffset(), $infoWindow->getVariable().'.pixelOffset'); + } + + if ($infoWindow->isOpen()) { + $this->assertSameObject($map->getVariable(), $infoWindow, $this->getFormatter()); + } + } + + /** + * @param Map $map + * @param Marker $marker + */ + protected function assertMarker(Map $map, Marker $marker) + { + $variable = $map->getOverlayManager()->getMarkerCluster()->getType() !== MarkerClusterType::MARKER_CLUSTERER + ? $map->getVariable() + : null; + + $this->assertSameContainerVariable( + $map, + 'overlays.markers', + $marker, + $variable, + $this->getFormatter() + ); + + $this->assertCoordinate($map, $marker->getPosition(), $marker->getVariable().'.getPosition()'); + + if ($marker->hasAnimation()) { + $this->assertSameVariable( + 'google.maps.Animation.'.strtoupper($marker->getAnimation()), + $marker->getVariable().'.getAnimation()' + ); + } + + if ($marker->hasIcon()) { + $this->assertIcon($map, $marker, $marker->getIcon()); + } + + if ($marker->hasShape()) { + $this->assertMarkerShape($map, $marker, $marker->getShape()); + } + + if ($marker->hasInfoWindow()) { + $this->assertInfoWindow($map, $marker->getInfoWindow()); + } + } + + /** + * @param Map $map + * @param Marker $marker + * @param Icon $icon + */ + protected function assertIcon(Map $map, Marker $marker, Icon $icon) + { + $variable = $marker->getVariable().'.getIcon()'; + + $this->assertSameVariable('"'.$icon->getUrl().'"', $variable.'.url'); + + if ($icon->hasAnchor()) { + $this->assertPoint($map, $icon->getAnchor(), $variable.'.anchor'); + } + + if ($icon->hasOrigin()) { + $this->assertPoint($map, $icon->getOrigin(), $variable.'.origin'); + } + + if ($icon->hasScaledSize()) { + $this->assertSize($map, $icon->getScaledSize(), $variable.'.scaledSize'); + } + + if ($icon->hasSize()) { + $this->assertSize($map, $icon->getSize(), $variable.'.size'); + } + } + + /** + * @param Map $map + * @param Marker $marker + * @param MarkerShape $markerShape + */ + protected function assertMarkerShape(Map $map, Marker $marker, MarkerShape $markerShape) + { + $variable = $marker->getVariable().'.getShape()'; + + $this->assertSameVariable('"'.$markerShape->getType().'"', $variable.'.type'); + $this->assertSameVariable( + json_encode($markerShape->getCoordinates()).'.toString()', + $variable.'.coords.toString()' + ); + } + + /** + * @param Map $map + * @param Polygon $polygon + */ + protected function assertPolygon(Map $map, Polygon $polygon) + { + $this->assertSameContainerVariable( + $map, + 'overlays.polygons', + $polygon, + $map->getVariable(), + $this->getFormatter() + ); + + foreach ($polygon->getCoordinates() as $coordinate) { + $this->assertCoordinate($map, $coordinate); + } + } + + /** + * @param Map $map + * @param Polyline $polyline + */ + protected function assertPolyline(Map $map, Polyline $polyline) + { + $this->assertSameContainerVariable( + $map, + 'overlays.polylines', + $polyline, + $map->getVariable(), + $this->getFormatter() + ); + + foreach ($polyline->getCoordinates() as $coordinate) { + $this->assertCoordinate($map, $coordinate); + } + } + + /** + * @param Map $map + * @param Rectangle $rectangle + */ + protected function assertRectangle(Map $map, Rectangle $rectangle) + { + $this->assertSameContainerVariable( + $map, + 'overlays.rectangles', + $rectangle, + $map->getVariable(), + $this->getFormatter() + ); + + $this->assertBound($map, $rectangle->getBound(), $rectangle->getVariable().'.getBounds()'); + } + + /** + * @param Map $map + */ + protected function assertContainer(Map $map) + { + foreach ($this->getContainerPropertyPaths() as $propertyPath) { + $this->assertContainerVariableExists($map, $propertyPath); + } + + $this->assertSameContainerVariable($map, 'map'); + } + + /** + * @return callable + */ + private function getFormatter() + { + return function ($expected, $variable, $formatter) { + return call_user_func($formatter, $expected, $variable.'.getMap()', $formatter); + }; + } + + /** + * @return string[] + */ + private function getContainerPropertyPaths() + { + return [ + null, + $base = 'base', + $base.'.coordinates', + $base.'.bounds', + $base.'.points', + $base.'.sizes', + 'map', + $overlays = 'overlays', + $overlays.'.circles', + $overlays.'.encoded_polylines', + $overlays.'.ground_overlays', + $overlays.'.polygons', + $overlays.'.polylines', + $overlays.'.rectangles', + $overlays.'.info_windows', + $overlays.'.info_boxes', + $overlays.'.marker_images', + $overlays.'.marker_cluster', + $layers = 'layers', + $layers.'.kml_layers', + $events = 'events', + $events.'.dom_events', + $events.'.dom_events_once', + $events.'.events', + $events.'.events_once', + $functions = 'functions', + $functions.'.info_windows_close', + $functions.'.to_array', + ]; + } +} diff --git a/tests/Helper/Functional/CompoundFunctionalTest.php b/tests/Helper/Functional/CompoundFunctionalTest.php new file mode 100644 index 00000000..33fdedbd --- /dev/null +++ b/tests/Helper/Functional/CompoundFunctionalTest.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional; + +use Ivory\GoogleMap\Helper\Builder\MapHelperBuilder; +use Ivory\GoogleMap\Helper\Builder\PlaceAutocompleteHelperBuilder; +use Ivory\GoogleMap\Helper\MapHelper; +use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + * + * @group functional + */ +class CompoundFunctionalTest extends AbstractApiFunctionalTest +{ + /** + * @var PlaceAutocompleteHelper + */ + private $placeAutocompleteHelper; + + /** + * @var MapHelper + */ + private $mapHelper; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + parent::setUp(); + + $this->placeAutocompleteHelper = PlaceAutocompleteHelperBuilder::create()->build(); + $this->mapHelper = MapHelperBuilder::create()->build(); + } + + public function testRender() + { + $this->render(new Autocomplete(), new Map()); + } + + /** + * @param Autocomplete $autocomplete + * @param Map $map + */ + private function render(Autocomplete $autocomplete, Map $map) + { + $this->renderHtml(implode('', [ + $this->placeAutocompleteHelper->render($autocomplete), + $this->mapHelper->render($map), + $this->renderApi([$autocomplete, $map]), + ])); + + $this->waitUntil(function () use ($autocomplete, $map) { + try { + $this->assertObjectExists($autocomplete); + $this->assertObjectExists($map); + + return true; + } catch (\Exception $e) { + } + }, 5000); + } +} diff --git a/tests/Helper/Functional/Control/MapTypeControlFunctionalTest.php b/tests/Helper/Functional/Control/MapTypeControlFunctionalTest.php new file mode 100644 index 00000000..640d4ecb --- /dev/null +++ b/tests/Helper/Functional/Control/MapTypeControlFunctionalTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\MapTypeControl; +use Ivory\GoogleMap\Control\MapTypeControlStyle; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\MapTypeId; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class MapTypeControlFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->setMapOption('mapTypeId', MapTypeId::HYBRID); + $map->getControlManager()->setMapTypeControl($this->createMapTypeControl()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return MapTypeControl + */ + private function createMapTypeControl() + { + return new MapTypeControl( + [MapTypeId::HYBRID], + ControlPosition::TOP_CENTER, + MapTypeControlStyle::DROPDOWN_MENU + ); + } +} diff --git a/tests/Helper/Functional/Control/RotateControlFunctionalTest.php b/tests/Helper/Functional/Control/RotateControlFunctionalTest.php new file mode 100644 index 00000000..9fa7fc58 --- /dev/null +++ b/tests/Helper/Functional/Control/RotateControlFunctionalTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\RotateControl; +use Ivory\GoogleMap\Map; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class RotateControlFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getControlManager()->setRotateControl($this->createRotateControl()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return RotateControl + */ + private function createRotateControl() + { + return new RotateControl(ControlPosition::TOP_CENTER); + } +} diff --git a/tests/Helper/Functional/Control/ScaleControlFunctionalTest.php b/tests/Helper/Functional/Control/ScaleControlFunctionalTest.php new file mode 100644 index 00000000..8846a2d0 --- /dev/null +++ b/tests/Helper/Functional/Control/ScaleControlFunctionalTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\ScaleControl; +use Ivory\GoogleMap\Control\ScaleControlStyle; +use Ivory\GoogleMap\Map; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class ScaleControlFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getControlManager()->setScaleControl($this->createScaleControl()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return ScaleControl + */ + private function createScaleControl() + { + return new ScaleControl(ControlPosition::TOP_CENTER, ScaleControlStyle::DEFAULT_); + } +} diff --git a/tests/Helper/Functional/Control/StreetViewControlFunctionalTest.php b/tests/Helper/Functional/Control/StreetViewControlFunctionalTest.php new file mode 100644 index 00000000..c0232239 --- /dev/null +++ b/tests/Helper/Functional/Control/StreetViewControlFunctionalTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\StreetViewControl; +use Ivory\GoogleMap\Map; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class StreetViewControlFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getControlManager()->setStreetViewControl($this->createStreetViewControl()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return StreetViewControl + */ + private function createStreetViewControl() + { + return new StreetViewControl(ControlPosition::TOP_CENTER); + } +} diff --git a/tests/Helper/Functional/Control/ZoomControlFunctionalTest.php b/tests/Helper/Functional/Control/ZoomControlFunctionalTest.php new file mode 100644 index 00000000..54b91d28 --- /dev/null +++ b/tests/Helper/Functional/Control/ZoomControlFunctionalTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Control\ZoomControl; +use Ivory\GoogleMap\Control\ZoomControlStyle; +use Ivory\GoogleMap\Map; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class ZoomControlFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getControlManager()->setZoomControl($this->createZoomControl()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return ZoomControl + */ + private function createZoomControl() + { + return new ZoomControl(ControlPosition::TOP_CENTER, ZoomControlStyle::LARGE); + } +} diff --git a/tests/Helper/Functional/Layer/KmlLayerFunctionalTest.php b/tests/Helper/Functional/Layer/KmlLayerFunctionalTest.php new file mode 100644 index 00000000..941bbd08 --- /dev/null +++ b/tests/Helper/Functional/Layer/KmlLayerFunctionalTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Layer; + +use Ivory\GoogleMap\Layer\KmlLayer; +use Ivory\GoogleMap\Map; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class KmlLayerFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getLayerManager()->addKmlLayer($this->createKmlLayer()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getLayerManager()->addKmlLayer($this->createKmlLayer()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return KmlLayer + */ + private function createKmlLayer() + { + return new KmlLayer('https://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml'); + } +} diff --git a/tests/Helper/Functional/MapFunctionalTest.php b/tests/Helper/Functional/MapFunctionalTest.php new file mode 100644 index 00000000..954b25cb --- /dev/null +++ b/tests/Helper/Functional/MapFunctionalTest.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional; + +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + * + * @group functional + */ +class MapFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $this->renderMap($map = new Map()); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithLibraries() + { + $map = new Map(); + $map->addLibrary('drawing'); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithLanguage() + { + $map = new Map(); + $map->setLanguage('fr'); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithMapOptions() + { + $map = new Map(); + $map->setMapOption('disableDoubleClickZoom', true); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithStylesheetOptions() + { + $map = new Map(); + $map->setMapOption('position', 'absolute'); + + $this->renderMap($map); + $this->assertMap($map); + } +} diff --git a/tests/Helper/Functional/Overlay/CircleFunctionalTest.php b/tests/Helper/Functional/Overlay/CircleFunctionalTest.php new file mode 100644 index 00000000..4ebd6305 --- /dev/null +++ b/tests/Helper/Functional/Overlay/CircleFunctionalTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Circle; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class CircleFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addCircle($this->createCircle()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addCircle($this->createCircle()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return Circle + */ + private function createCircle() + { + return new Circle(new Coordinate()); + } +} diff --git a/tests/Helper/Functional/Overlay/EncodedPolylineFunctionalTest.php b/tests/Helper/Functional/Overlay/EncodedPolylineFunctionalTest.php new file mode 100644 index 00000000..c6194724 --- /dev/null +++ b/tests/Helper/Functional/Overlay/EncodedPolylineFunctionalTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class EncodedPolylineFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addEncodedPolyline($this->createEncodedPolyline()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addEncodedPolyline($this->createEncodedPolyline()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return EncodedPolyline + */ + private function createEncodedPolyline() + { + return new EncodedPolyline('yv_tHizrQiGsR`HcP'); + } +} diff --git a/tests/Helper/Functional/Overlay/GroundOverlayFunctionalTest.php b/tests/Helper/Functional/Overlay/GroundOverlayFunctionalTest.php new file mode 100644 index 00000000..e34fcfd3 --- /dev/null +++ b/tests/Helper/Functional/Overlay/GroundOverlayFunctionalTest.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\GroundOverlay; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class GroundOverlayFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addGroundOverlay($this->createGroundOverlay()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addGroundOverlay($this->createGroundOverlay()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return GroundOverlay + */ + private function createGroundOverlay() + { + return new GroundOverlay( + 'https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', + new Bound(new Coordinate(40.712216, -74.22655), new Coordinate(40.773941, -74.12544)) + ); + } +} diff --git a/tests/Helper/Functional/Overlay/InfoBoxFunctionalTest.php b/tests/Helper/Functional/Overlay/InfoBoxFunctionalTest.php new file mode 100644 index 00000000..0145c98c --- /dev/null +++ b/tests/Helper/Functional/Overlay/InfoBoxFunctionalTest.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class InfoBoxFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addInfoWindow($this->createInfoBox()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addInfoWindow($this->createInfoBox()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithPixelOffset() + { + $infoBox = $this->createInfoBox(); + $infoBox->setPixelOffset(new Size(5, 10)); + + $map = new Map(); + $map->getOverlayManager()->addInfoWindow($infoBox); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return InfoWindow + */ + private function createInfoBox() + { + $infoBox = new InfoWindow('content'); + $infoBox->setType(InfoWindowType::INFO_BOX); + $infoBox->setPosition(new Coordinate()); + $infoBox->setOpen(true); + + return $infoBox; + } +} diff --git a/tests/Helper/Functional/Overlay/InfoWindowFunctionalTest.php b/tests/Helper/Functional/Overlay/InfoWindowFunctionalTest.php new file mode 100644 index 00000000..d2eec397 --- /dev/null +++ b/tests/Helper/Functional/Overlay/InfoWindowFunctionalTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class InfoWindowFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addInfoWindow($this->createInfoWindow()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addInfoWindow($this->createInfoWindow()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithPixelOffset() + { + $infoWindow = $this->createInfoWindow(); + $infoWindow->setPixelOffset(new Size(5, 10)); + + $map = new Map(); + $map->getOverlayManager()->addInfoWindow($infoWindow); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return InfoWindow + */ + private function createInfoWindow() + { + $infoWindow = new InfoWindow('content'); + $infoWindow->setPosition(new Coordinate()); + $infoWindow->setOpen(true); + + return $infoWindow; + } +} diff --git a/tests/Helper/Functional/Overlay/MarkerClustererFunctionalTest.php b/tests/Helper/Functional/Overlay/MarkerClustererFunctionalTest.php new file mode 100644 index 00000000..9c6eca3d --- /dev/null +++ b/tests/Helper/Functional/Overlay/MarkerClustererFunctionalTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\MarkerClusterType; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class MarkerClustererFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->getMarkerCluster()->setType(MarkerClusterType::MARKER_CLUSTERER); + $map->getOverlayManager()->addMarker($this->createMarker()); + $map->getOverlayManager()->addMarker($this->createMarker(new Coordinate(1, 1))); + $map->getOverlayManager()->addMarker($this->createMarker(new Coordinate(2, 2))); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->getMarkerCluster()->setType(MarkerClusterType::MARKER_CLUSTERER); + $map->getOverlayManager()->addMarker($this->createMarker()); + $map->getOverlayManager()->addMarker($this->createMarker(new Coordinate(1, 1))); + $map->getOverlayManager()->addMarker($this->createMarker(new Coordinate(2, 2))); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @param Coordinate|null $position + * + * @return Marker + */ + private function createMarker(Coordinate $position = null) + { + return new Marker($position ?: new Coordinate()); + } +} diff --git a/tests/Helper/Functional/Overlay/MarkerFunctionalTest.php b/tests/Helper/Functional/Overlay/MarkerFunctionalTest.php new file mode 100644 index 00000000..a20cbc9d --- /dev/null +++ b/tests/Helper/Functional/Overlay/MarkerFunctionalTest.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Animation; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Overlay\MarkerShapeType; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class MarkerFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addMarker($this->createMarker()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addMarker($this->createMarker()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAnimation() + { + $marker = $this->createMarker(); + $marker->setAnimation(Animation::BOUNCE); + + $map = new Map(); + $map->getOverlayManager()->addMarker($marker); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithIcon() + { + $marker = $this->createMarker(); + $marker->setIcon(new Icon()); + + $map = new Map(); + $map->getOverlayManager()->addMarker($marker); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithShape() + { + $marker = $this->createMarker(); + $marker->setIcon(new Icon()); + $marker->setShape(new MarkerShape(MarkerShapeType::POLY, [1, 1, 1, 20, 18, 20, 18, 1])); + + $map = new Map(); + $map->getOverlayManager()->addMarker($marker); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return Marker + */ + private function createMarker() + { + return new Marker(new Coordinate()); + } +} diff --git a/tests/Helper/Functional/Overlay/MarkerInfoWindowFunctionalTest.php b/tests/Helper/Functional/Overlay/MarkerInfoWindowFunctionalTest.php new file mode 100644 index 00000000..dc21b39c --- /dev/null +++ b/tests/Helper/Functional/Overlay/MarkerInfoWindowFunctionalTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class MarkerInfoWindowFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addMarker($this->createMarker()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addMarker($this->createMarker()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return Marker + */ + private function createMarker() + { + $marker = new Marker(new Coordinate()); + $marker->setInfoWindow($this->createInfoWindowMarker()); + + return $marker; + } + + /** + * @return InfoWindow + */ + private function createInfoWindowMarker() + { + return new InfoWindow('content'); + } +} diff --git a/tests/Helper/Functional/Overlay/MixedInfoWindowFunctionalTest.php b/tests/Helper/Functional/Overlay/MixedInfoWindowFunctionalTest.php new file mode 100644 index 00000000..aef32a73 --- /dev/null +++ b/tests/Helper/Functional/Overlay/MixedInfoWindowFunctionalTest.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class MixedInfoWindowFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addInfoWindow($this->createInfoWindow()); + $map->getOverlayManager()->addInfoWindow($this->createInfoBox()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addInfoWindow($this->createInfoWindow()); + $map->getOverlayManager()->addInfoWindow($this->createInfoBox()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return InfoWindow + */ + private function createInfoWindow() + { + $infoWindow = new InfoWindow('content'); + $infoWindow->setPosition(new Coordinate()); + $infoWindow->setOpen(true); + + return $infoWindow; + } + + /** + * @return InfoWindow + */ + private function createInfoBox() + { + $infoBox = $this->createInfoWindow(); + $infoBox->setType(InfoWindowType::INFO_BOX); + $infoBox->setPosition(new Coordinate(1, 1)); + + return $infoBox; + } +} diff --git a/tests/Helper/Functional/Overlay/PolygonFunctionalTest.php b/tests/Helper/Functional/Overlay/PolygonFunctionalTest.php new file mode 100644 index 00000000..9fcbee78 --- /dev/null +++ b/tests/Helper/Functional/Overlay/PolygonFunctionalTest.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polygon; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class PolygonFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addPolygon($this->createPolygon()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addPolygon($this->createPolygon()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return Polygon + */ + private function createPolygon() + { + return new Polygon([ + new Coordinate(25.774, -80.190), + new Coordinate(18.466, -66.118), + new Coordinate(32.321, -64.757), + new Coordinate(25.774, -80.190), + ]); + } +} diff --git a/tests/Helper/Functional/Overlay/PolylineFunctionalTest.php b/tests/Helper/Functional/Overlay/PolylineFunctionalTest.php new file mode 100644 index 00000000..c685ebad --- /dev/null +++ b/tests/Helper/Functional/Overlay/PolylineFunctionalTest.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polyline; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class PolylineFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addPolyline($this->createPolyline()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addPolyline($this->createPolyline()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return Polyline + */ + private function createPolyline() + { + return new Polyline([ + new Coordinate(25.774, -80.190), + new Coordinate(18.466, -66.118), + new Coordinate(32.321, -64.757), + new Coordinate(25.774, -80.190), + ]); + } +} diff --git a/tests/Helper/Functional/Overlay/RectangleFunctionalTest.php b/tests/Helper/Functional/Overlay/RectangleFunctionalTest.php new file mode 100644 index 00000000..cab1a5b0 --- /dev/null +++ b/tests/Helper/Functional/Overlay/RectangleFunctionalTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Rectangle; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractMapFunctionalTest; + +/** + * @author GeLo + * + * @group functional + */ +class RectangleFunctionalTest extends AbstractMapFunctionalTest +{ + public function testRender() + { + $map = new Map(); + $map->getOverlayManager()->addRectangle($this->createRectangle()); + + $this->renderMap($map); + $this->assertMap($map); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setAutoZoom(true); + $map->getOverlayManager()->addRectangle($this->createRectangle()); + + $this->renderMap($map); + $this->assertMap($map); + } + + /** + * @return Rectangle + */ + private function createRectangle() + { + return new Rectangle(new Bound(new Coordinate(-1, -2), new Coordinate(1, 2))); + } +} diff --git a/tests/Helper/Functional/Place/AbstractAutocompleteFunctionalTest.php b/tests/Helper/Functional/Place/AbstractAutocompleteFunctionalTest.php new file mode 100644 index 00000000..9c02c558 --- /dev/null +++ b/tests/Helper/Functional/Place/AbstractAutocompleteFunctionalTest.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Place; + +use Ivory\GoogleMap\Helper\Builder\PlaceAutocompleteHelperBuilder; +use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper; +use Ivory\GoogleMap\Place\Autocomplete; +use Ivory\Tests\GoogleMap\Helper\Functional\AbstractApiFunctionalTest; + +/** + * @author GeLo + */ +abstract class AbstractAutocompleteFunctionalTest extends AbstractApiFunctionalTest +{ + /** + * @var PlaceAutocompleteHelper + */ + private $placeAutocompleteHelper; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + parent::setUp(); + + $this->placeAutocompleteHelper = $this->createPlaceAutocompleteHelper(); + } + + /** + * @return PlaceAutocompleteHelper + */ + protected function createPlaceAutocompleteHelper() + { + return PlaceAutocompleteHelperBuilder::create()->build(); + } + + /** + * @param Autocomplete $autocomplete + */ + protected function renderAutocomplete(Autocomplete $autocomplete) + { + $this->renderHtml(implode('', [ + $this->placeAutocompleteHelper->render($autocomplete), + $this->renderApi([$autocomplete]), + ])); + + $this->waitUntil(function () use ($autocomplete) { + try { + $this->assertObjectExists($autocomplete); + + return true; + } catch (\Exception $e) { + } + }, 5000); + } + + /** + * @param Autocomplete $autocomplete + */ + protected function assertAutocomplete(Autocomplete $autocomplete) + { + $this->assertContainer($autocomplete); + $this->assertAutocompleteHtml($autocomplete); + + if ($autocomplete->hasBound()) { + $this->assertBound($autocomplete, $autocomplete->getBound(), $autocomplete->getVariable().'.getBounds()'); + } + + if ($autocomplete->hasLibraries()) { + $this->assertLibraries($autocomplete->getLibraries()); + } + } + + /** + * @param Autocomplete $autocomplete + */ + protected function assertAutocompleteHtml(Autocomplete $autocomplete) + { + $html = $this->byId($autocomplete->getHtmlId()); + + foreach ($autocomplete->getInputAttributes() as $attribute => $value) { + $this->assertSame($value, $html->attribute($attribute)); + } + + $this->assertSame((string) $autocomplete->getValue(), $html->value()); + } + + /** + * @param Autocomplete $autocomplete + */ + protected function assertContainer(Autocomplete $autocomplete) + { + foreach ($this->getContainerPropertyPaths() as $propertyPath) { + $this->assertContainerVariableExists($autocomplete, $propertyPath); + } + + $this->assertSameContainerVariable($autocomplete, 'autocomplete'); + } + + /** + * @return string[] + */ + private function getContainerPropertyPaths() + { + return [ + null, + $base = 'base', + $base.'.coordinates', + $base.'.bounds', + 'autocomplete', + ]; + } +} diff --git a/tests/Helper/Functional/Place/AutocompleteFunctionalTest.php b/tests/Helper/Functional/Place/AutocompleteFunctionalTest.php new file mode 100644 index 00000000..ef2ed2fc --- /dev/null +++ b/tests/Helper/Functional/Place/AutocompleteFunctionalTest.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Functional\Place; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Place\Autocomplete; +use Ivory\GoogleMap\Place\AutocompleteComponentRestriction; +use Ivory\GoogleMap\Place\AutocompleteType; + +/** + * @author GeLo + * + * @group functional + */ +class AutocompleteFunctionalTest extends AbstractAutocompleteFunctionalTest +{ + public function testRender() + { + $this->renderAutocomplete($autocomplete = $this->createAutocomplete()); + $this->assertAutocomplete($autocomplete); + } + + public function testRenderWithBound() + { + $autocomplete = $this->createAutocomplete(); + $autocomplete->setBound(new Bound(new Coordinate(-1, -1), new Coordinate(1, 1))); + + $this->renderAutocomplete($autocomplete); + $this->assertAutocomplete($autocomplete); + } + + public function testRenderWithTypes() + { + $autocomplete = $this->createAutocomplete(); + $autocomplete->setTypes([AutocompleteType::CITIES]); + + $this->renderAutocomplete($autocomplete); + $this->assertAutocomplete($autocomplete); + } + + public function testRenderWithComponentRestrictions() + { + $autocomplete = $this->createAutocomplete(); + $autocomplete->setComponentRestrictions([AutocompleteComponentRestriction::COUNTRY => 'fr']); + + $this->renderAutocomplete($autocomplete); + $this->assertAutocomplete($autocomplete); + } + + public function testRenderWithValue() + { + $autocomplete = $this->createAutocomplete(); + $autocomplete->setValue('value'); + + $this->renderAutocomplete($autocomplete); + $this->assertAutocomplete($autocomplete); + } + + public function testRenderWithInputAttributes() + { + $autocomplete = $this->createAutocomplete(); + $autocomplete->setInputAttribute('placeholder', 'Enter your location'); + + $this->renderAutocomplete($autocomplete); + $this->assertAutocomplete($autocomplete); + } + + public function testRenderWithLibraries() + { + $autocomplete = $this->createAutocomplete(); + $autocomplete->addLibrary('drawing'); + + $this->renderAutocomplete($autocomplete); + $this->assertAutocomplete($autocomplete); + } + + public function testRenderWithLanguage() + { + $autocomplete = $this->createAutocomplete(); + $autocomplete->setLanguage('fr'); + + $this->renderAutocomplete($autocomplete); + $this->assertAutocomplete($autocomplete); + } + + /** + * @return Autocomplete + */ + private function createAutocomplete() + { + return new Autocomplete(); + } +} diff --git a/tests/Helper/Geometry/EncodingHelperTest.php b/tests/Helper/Geometry/EncodingHelperTest.php deleted file mode 100644 index a0a3bf34..00000000 --- a/tests/Helper/Geometry/EncodingHelperTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Geometry; - -use Ivory\GoogleMap\Helper\Geometry\EncodingHelper; - -/** - * Encoding helper test. - * - * @author GeLo - */ -class EncodingHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Geometry\EncodingHelper */ - protected $encodingHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->encodingHelper = new EncodingHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->encodingHelper); - } - - public function testRenderDecodePathWithoutSpecialChars() - { - $this->assertSame( - 'google.maps.geometry.encoding.decodePath("foo")', - $this->encodingHelper->renderDecodePath('foo') - ); - } - - public function testRenderDecodePathWithSpecialChars() - { - $this->assertSame( - 'google.maps.geometry.encoding.decodePath("v\"a\\\\lu\\\'e")', - $this->encodingHelper->renderDecodePath('v"a\lu\'e') - ); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The encoded path must be a string value. - */ - public function testRenderDecodePathWithInvalidValue() - { - $this->encodingHelper->renderDecodePath(true); - } -} diff --git a/tests/Helper/Layers/KMLLayerHelperTest.php b/tests/Helper/Layers/KMLLayerHelperTest.php deleted file mode 100644 index 843bf5aa..00000000 --- a/tests/Helper/Layers/KMLLayerHelperTest.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Layers; - -use Ivory\GoogleMap\Layers\KMLLayer; -use Ivory\GoogleMap\Helper\Layers\KMLLayerHelper; - -/** - * KML Layer helper test. - * - * @author GeLo - */ -class KMLLayerHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Layers\KMLLayerHelper */ - protected $kmlLayerHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->kmlLayerHelper = new KMLLayerHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->kmlLayerHelper); - } - - public function testRenderWithoutOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $kmlLayer = new KMLLayer('url'); - $kmlLayer->setJavascriptVariable('kmlLayer'); - - $this->assertSame( - 'kmlLayer = new google.maps.KmlLayer("url", {"map":map});'.PHP_EOL, - $this->kmlLayerHelper->render($kmlLayer, $map) - ); - } - - public function testRenderWithOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $kmlLayer = new KMLLayer('url'); - $kmlLayer->setJavascriptVariable('kmlLayer'); - $kmlLayer->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = 'kmlLayer = new google.maps.KmlLayer('. - '"url", '. - '{"map":map,"option1":"value1","option2":"value2"}'. - ');'.PHP_EOL; - - $this->assertSame($expected, $this->kmlLayerHelper->render($kmlLayer, $map)); - } -} diff --git a/tests/Helper/MapHelperTest.php b/tests/Helper/MapHelperTest.php deleted file mode 100644 index c1e56bd8..00000000 --- a/tests/Helper/MapHelperTest.php +++ /dev/null @@ -1,1280 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper; - -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\Events\Event; -use Ivory\GoogleMap\Helper\Extension\InfoBoxExtensionHelper; -use Ivory\GoogleMap\Helper\Overlays\InfoBoxHelper; -use Ivory\GoogleMap\Layers\KMLLayer; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\MapTypeId; -use Ivory\GoogleMap\Overlays\Circle; -use Ivory\GoogleMap\Overlays\EncodedPolyline; -use Ivory\GoogleMap\Overlays\GroundOverlay; -use Ivory\GoogleMap\Overlays\InfoWindow; -use Ivory\GoogleMap\Overlays\Marker; -use Ivory\GoogleMap\Overlays\Polygon; -use Ivory\GoogleMap\Overlays\Polyline; -use Ivory\GoogleMap\Overlays\Rectangle; -use Ivory\GoogleMap\Helper\MapHelper; - -/** - * Map helper test. - * - * @author GeLo - */ -class MapHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\MapHelper */ - protected $mapHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->mapHelper = new MapHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->mapHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Base\CoordinateHelper', - $this->mapHelper->getCoordinateHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Base\BoundHelper', - $this->mapHelper->getBoundHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Base\PointHelper', - $this->mapHelper->getPointHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Base\SizeHelper', - $this->mapHelper->getSizeHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\MapTypeIdHelper', - $this->mapHelper->getMapTypeIdHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper', - $this->mapHelper->getMapTypeControlHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper', - $this->mapHelper->getOverviewMapControlHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\PanControlHelper', - $this->mapHelper->getPanControlHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\RotateControlHelper', - $this->mapHelper->getRotateControlHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ScaleControlHelper', - $this->mapHelper->getScaleControlHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper', - $this->mapHelper->getStreetViewControlHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Controls\ZoomControlHelper', - $this->mapHelper->getZoomControlHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper', - $this->mapHelper->getMarkerClusterHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper', - $this->mapHelper->getMarkerImageHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper', - $this->mapHelper->getMarkerShapeHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper', - $this->mapHelper->getInfoWindowHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\PolylineHelper', - $this->mapHelper->getPolylineHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper', - $this->mapHelper->getEncodedPolylineHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\PolygonHelper', - $this->mapHelper->getPolygonHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\RectangleHelper', - $this->mapHelper->getRectangleHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\CircleHelper', - $this->mapHelper->getCircleHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper', - $this->mapHelper->getGroundOverlayHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Layers\KMLLayerHelper', - $this->mapHelper->getKmlLayerHelper() - ); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Events\EventManagerHelper', - $this->mapHelper->getEventManagerHelper() - ); - - $this->assertTrue($this->mapHelper->hasExtensionHelpers()); - $this->assertCount(1, $this->mapHelper->getExtensionHelpers()); - - $this->assertTrue($this->mapHelper->hasExtensionHelper('core')); - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Extension\CoreExtensionHelper', - $this->mapHelper->getExtensionHelper('core') - ); - } - - public function testInitialState() - { - $coordinateHelper = $this->getMock('Ivory\GoogleMap\Helper\Base\CoordinateHelper'); - $boundHelper = $this->getMock('Ivory\GoogleMap\Helper\Base\BoundHelper'); - $pointHelper = $this->getMock('Ivory\GoogleMap\Helper\Base\PointHelper'); - $sizeHelper = $this->getMock('Ivory\GoogleMap\Helper\Base\SizeHelper'); - $mapTypeIdHelper = $this->getMock('Ivory\GoogleMap\Helper\MapTypeIdHelper'); - $mapTypeControlHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\MapTypeControlHelper'); - $overviewMapControlHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\OverviewMapControlHelper'); - $panControlHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\PanControlHelper'); - $rotateControlHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\RotateControlHelper'); - $scaleControlHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ScaleControlHelper'); - $streetViewControlHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\StreetViewControlHelper'); - $zoomControlHelper = $this->getMock('Ivory\GoogleMap\Helper\Controls\ZoomControlHelper'); - $markerClusterHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface'); - $markerImageHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper'); - $markerShapeHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper'); - $infoWindowHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper'); - $polylineHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\PolylineHelper'); - $encodedPolylineHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper'); - $polygonHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\PolygonHelper'); - $rectangleHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\RectangleHelper'); - $circleHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\CircleHelper'); - $groundOverlayHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper'); - $kmlLayerHelper = $this->getMock('Ivory\GoogleMap\Helper\Layers\KMLLayerHelper'); - $eventManagerHelper = $this->getMock('Ivory\GoogleMap\Helper\Events\EventManagerHelper'); - $extensionHelpers = array('foo' => $this->getMock('Ivory\GoogleMap\Helper\Extension\ExtensionHelperInterface')); - - $this->mapHelper = new MapHelper( - $coordinateHelper, - $boundHelper, - $pointHelper, - $sizeHelper, - $mapTypeIdHelper, - $mapTypeControlHelper, - $overviewMapControlHelper, - $panControlHelper, - $rotateControlHelper, - $scaleControlHelper, - $streetViewControlHelper, - $zoomControlHelper, - $markerClusterHelper, - $markerImageHelper, - $markerShapeHelper, - $infoWindowHelper, - $polylineHelper, - $encodedPolylineHelper, - $polygonHelper, - $rectangleHelper, - $circleHelper, - $groundOverlayHelper, - $kmlLayerHelper, - $eventManagerHelper, - $extensionHelpers - ); - - $this->assertSame($coordinateHelper, $this->mapHelper->getCoordinateHelper()); - $this->assertSame($boundHelper, $this->mapHelper->getBoundHelper()); - $this->assertSame($pointHelper, $this->mapHelper->getPointHelper()); - $this->assertSame($sizeHelper, $this->mapHelper->getSizeHelper()); - $this->assertSame($mapTypeIdHelper, $this->mapHelper->getMapTypeIdHelper()); - $this->assertSame($mapTypeControlHelper, $this->mapHelper->getMapTypeControlHelper()); - $this->assertSame($overviewMapControlHelper, $this->mapHelper->getOverviewMapControlHelper()); - $this->assertSame($panControlHelper, $this->mapHelper->getPanControlHelper()); - $this->assertSame($rotateControlHelper, $this->mapHelper->getRotateControlHelper()); - $this->assertSame($scaleControlHelper, $this->mapHelper->getScaleControlHelper()); - $this->assertSame($streetViewControlHelper, $this->mapHelper->getStreetViewControlHelper()); - $this->assertSame($zoomControlHelper, $this->mapHelper->getZoomControlHelper()); - $this->assertSame($markerClusterHelper, $this->mapHelper->getMarkerClusterHelper()); - $this->assertSame($markerImageHelper, $this->mapHelper->getMarkerImageHelper()); - $this->assertSame($markerShapeHelper, $this->mapHelper->getMarkerShapeHelper()); - $this->assertSame($infoWindowHelper, $this->mapHelper->getInfoWindowHelper()); - $this->assertSame($polylineHelper, $this->mapHelper->getPolylineHelper()); - $this->assertSame($encodedPolylineHelper, $this->mapHelper->getEncodedPolylineHelper()); - $this->assertSame($polygonHelper, $this->mapHelper->getPolygonHelper()); - $this->assertSame($rectangleHelper, $this->mapHelper->getRectangleHelper()); - $this->assertSame($circleHelper, $this->mapHelper->getCircleHelper()); - $this->assertSame($groundOverlayHelper, $this->mapHelper->getGroundOverlayHelper()); - $this->assertSame($kmlLayerHelper, $this->mapHelper->getKmlLayerHelper()); - $this->assertSame($eventManagerHelper, $this->mapHelper->getEventManagerHelper()); - $this->assertSame($extensionHelpers, $this->mapHelper->getExtensionHelpers()); - } - - public function testRemoveExtensionHelperWithValidValue() - { - $extensionHelper = $this->getMock('Ivory\GoogleMap\Helper\Extension\ExtensionHelperInterface'); - $this->mapHelper->setExtensionHelper('foo', $extensionHelper); - - $this->assertTrue($this->mapHelper->hasExtensionHelper('foo')); - - $this->mapHelper->removeExtensionHelper('foo'); - - $this->assertFalse($this->mapHelper->hasExtensionHelper('foo')); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The extension helper "foo" does not exist. - */ - public function testRemoveExtensionHelperWithInvalidValue() - { - $this->mapHelper->removeExtensionHelper('foo'); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The extension helper "foo" does not exist. - */ - public function testGetExtensionHelperWithInvalidValue() - { - $this->mapHelper->getExtensionHelper('foo'); - } - - public function testRenderHtmlContainer() - { - $map = new Map(); - $map->setHtmlContainerId('html_container_id'); - - $this->assertSame( - '
'.PHP_EOL, - $this->mapHelper->renderHtmlContainer($map) - ); - } - - public function testRenderStylesheets() - { - $map = new Map(); - $map->setHtmlContainerId('html_container_id'); - $map->setStylesheetOptions(array('width' => '200px','height' => '100px', 'option1' => 'value1')); - - $expected = << -#html_container_id{ -width:200px; -height:100px; -option1:value1; -} - - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderStylesheets($map)); - } - - public function testRenderJsContainerInit() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $expected = 'map_container = {'. - '"map":null,'. - '"coordinates":{},'. - '"bounds":{},'. - '"points":{},'. - '"sizes":{},'. - '"circles":{},'. - '"encoded_polylines":{},'. - '"ground_overlays":{},'. - '"polygons":{},'. - '"polylines":{},'. - '"rectangles":{},'. - '"info_windows":{},'. - '"marker_images":{},'. - '"marker_shapes":{},'. - '"markers":{},'. - '"marker_cluster":null,'. - '"kml_layers":{},'. - '"event_manager":{"dom_events":{},"dom_events_once":{},"events":{},"events_once":{}},'. - '"closable_info_windows":{},'. - '"functions":{'. - '"to_array":function (object) { var array = []; for (var key in object) { array.push(object[key]); } return array; }'. - '}};'.PHP_EOL; - - $this->assertSame($expected, $this->mapHelper->renderJsContainerInit($map)); - } - - public function testRenderJsContainerBounds() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->getBound()->setJavascriptVariable('map_bound'); - - $map->addGroundOverlay($groundOverlay = new GroundOverlay()); - $groundOverlay->getBound()->setJavascriptVariable('ground_overlay_bound'); - $groundOverlay->getBound()->getSouthWest()->setJavascriptVariable('ground_overlay_coordinate_south_west'); - $groundOverlay->getBound()->getNorthEast()->setJavascriptVariable('ground_overlay_coordinate_north_east'); - - $map->addRectangle($rectangle = new Rectangle()); - $rectangle->getBound()->setJavascriptVariable('rectangle_bound'); - $rectangle->getBound()->getSouthWest()->setJavascriptVariable('rectangle_coordinate_south_west'); - $rectangle->getBound()->getNorthEast()->setJavascriptVariable('rectangle_coordinate_north_east'); - - $map->setAutoZoom(true); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerBounds($map)); - } - - public function testRenderJsContainerCoordinates() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->getCenter()->setJavascriptVariable('map_center'); - - $map->addRectangle($rectangle = new Rectangle()); - $rectangle->getBound()->getSouthWest()->setJavascriptVariable('rectangle_south_west'); - $rectangle->getBound()->getNorthEast()->setJavascriptVariable('rectangle_north_east'); - - $map->addCircle($circle = new Circle()); - $circle->getCenter()->setJavascriptVariable('circle_center'); - - $map->addInfoWindow($infoWindow = new InfoWindow()); - $infoWindow->setPosition(1, 2, true); - $infoWindow->getPosition()->setJavascriptVariable('info_window_position'); - - $map->addMarker($marker = new Marker()); - $marker->getPosition()->setJavascriptVariable('marker_position'); - - $map->addPolygon($polygon = new Polygon()); - $polygon->addCoordinate(1.1, 2.1); - $polygon->addCoordinate(3.1, 4.2); - - foreach ($polygon->getCoordinates() as $index => $polygonCoordinate) { - $polygonCoordinate->setJavascriptVariable('polygon_coordinate_'.$index); - } - - $map->addPolyline($polyline = new Polyline()); - $polyline->addCoordinate(1.2, 2.6); - $polyline->addCoordinate(3.2, 4.9); - - foreach ($polyline->getCoordinates() as $index => $polyline) { - $polyline->setJavascriptVariable('polyline_coordinate_'.$index); - } - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerCoordinates($map)); - } - - public function testRenderJsContainerPoints() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addMarker($marker = new Marker()); - - $marker->setIcon('url'); - - $marker->getIcon()->setAnchor(1, 2); - $marker->getIcon()->getAnchor()->setJavascriptVariable('marker_icon_anchor'); - - $marker->getIcon()->setOrigin(1, 2); - $marker->getIcon()->getOrigin()->setJavascriptVariable('marker_icon_origin'); - - $marker->setShadow('url'); - - $marker->getShadow()->setAnchor(1, 2); - $marker->getShadow()->getAnchor()->setJavascriptVariable('marker_shadow_anchor'); - - $marker->getShadow()->setOrigin(1, 2); - $marker->getShadow()->getOrigin()->setJavascriptVariable('marker_shadow_origin'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerPoints($map)); - } - - public function testRenderJsContainerSizes() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addInfoWindow($mapInfoWindow = new InfoWindow()); - $mapInfoWindow->setPixelOffset(1, 2); - $mapInfoWindow->getPixelOffset()->setJavascriptVariable('map_info_winfow_pixel_offset'); - - $map->addMarker($marker = new Marker()); - - $marker->setInfoWindow($markerInfoWindow = new InfoWindow()); - $markerInfoWindow->setPixelOffset(1, 2); - $markerInfoWindow->getPixelOffset()->setJavascriptVariable('marker_info_window_pixel_offset'); - - $marker->setIcon('url'); - - $marker->getIcon()->setSize(1, 2); - $marker->getIcon()->getSize()->setJavascriptVariable('marker_icon_size'); - - $marker->getIcon()->setScaledSize(1, 2); - $marker->getIcon()->getScaledSize()->setJavascriptVariable('marker_icon_scaled_size'); - - $marker->setShadow('url'); - - $marker->getShadow()->setSize(1, 2); - $marker->getShadow()->getSize()->setJavascriptVariable('marker_shadow_size'); - - $marker->getShadow()->setScaledSize(1, 2); - $marker->getShadow()->getScaledSize()->setJavascriptVariable('marker_shadow_scaled_size'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerSizes($map)); - } - - public function testRenderMapCenter() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->getCenter()->setJavascriptVariable('map_center'); - - $this->assertSame('map.setCenter(map_center);'.PHP_EOL, $this->mapHelper->renderMapCenter($map)); - } - - public function testRenderMapBound() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->getBound()->setJavascriptVariable('map_bound'); - - $this->assertSame('map.fitBounds(map_bound);'.PHP_EOL, $this->mapHelper->renderMapBound($map)); - } - - public function testRenderMap() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $expected = <<assertSame($expected, $this->mapHelper->renderMap($map)); - } - - public function testRenderMapWithEnabledMapControls() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->setMapTypeControl( - array(MapTypeId::TERRAIN), - ControlPosition::BOTTOM_CENTER, - MapTypeControlStyle::HORIZONTAL_BAR - ); - - // FIXME Add all map controls... - - $expected = 'map = new google.maps.Map('. - 'document.getElementById("map_canvas"), '. - '{'. - '"mapTypeId":google.maps.MapTypeId.ROADMAP,'. - '"mapTypeControl":true,'. - '"mapTypeControlOptions":'. - '{'. - '"mapTypeIds":[google.maps.MapTypeId.TERRAIN],'. - '"position":google.maps.ControlPosition.BOTTOM_CENTER,'. - '"style":google.maps.MapTypeControlStyle.HORIZONTAL_BAR'. - '},'. - '"zoom":3'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->mapHelper->renderMap($map)); - } - - public function testRenderMapWithDisabledMapControls() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->setMapOption('mapTypeControl', false); - - $expected = 'map = new google.maps.Map('. - 'document.getElementById("map_canvas"), '. - '{"mapTypeId":google.maps.MapTypeId.ROADMAP,"mapTypeControl":false,"zoom":3}'. - ');'.PHP_EOL; - - $this->assertSame($expected, $this->mapHelper->renderMap($map)); - } - - public function testRenderJsContainerMap() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->getCenter()->setJavascriptVariable('map_center'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerMap($map)); - } - - public function testRenderJsContainerCircles() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addCircle($circle = new Circle()); - $circle->setJavascriptVariable('circle'); - $circle->getCenter()->setJavascriptVariable('circle_center'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerCircles($map)); - } - - public function testRenderJsContainerEncodedPolylines() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addEncodedPolyline($encodedPolyline = new EncodedPolyline('foo')); - $encodedPolyline->setJavascriptVariable('encoded_polyline'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerEncodedPolylines($map)); - } - - public function testRenderJsContainerGroundOverlays() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addGroundOverlay($groundOverlay = new GroundOverlay('url')); - $groundOverlay->setJavascriptVariable('ground_overlay'); - $groundOverlay->getBound()->setJavascriptVariable('ground_overlay_bound'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerGroundOverlays($map)); - } - - public function testRenderJsContainerPolygons() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addPolygon($polygon = new Polygon()); - $polygon->setJavascriptVariable('polygon'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerPolygons($map)); - } - - public function testRenderJsContainerPolylines() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addPolyline($polyline = new Polyline()); - $polyline->setJavascriptVariable('polyline'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerPolylines($map)); - } - - public function testRenderJsContainerRectangles() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addRectangle($rectangle = new Rectangle()); - $rectangle->setJavascriptVariable('rectangle'); - $rectangle->getBound()->setJavascriptVariable('rectangle_bound'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerRectangles($map)); - } - - public function testRenderJsContainerInfoWindowsWithoutClosableOnes() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addInfoWindow($mapInfoWindow = new InfoWindow()); - $mapInfoWindow->setJavascriptVariable('map_info_window'); - $mapInfoWindow->setPosition(1, 2, true); - $mapInfoWindow->getPosition()->setJavascriptVariable('map_info_window_position'); - - $map->addMarker($marker = new Marker()); - $marker->setInfoWindow($markerInfoWindow = new InfoWindow()); - $markerInfoWindow->setJavascriptVariable('marker_info_window'); - $markerInfoWindow->setPosition(1, 2, true); - $markerInfoWindow->getPosition()->setJavascriptVariable('marker_info_window_position'); - - $expected = <<Default content<\/p>"}); -map_container.info_windows.marker_info_window = marker_info_window = new google.maps.InfoWindow({"content":"

Default content<\/p>"}); - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJsContainerInfoWindows($map)); - } - - public function testRenderJsContainerInfoWindowsWithClosableOnes() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addInfoWindow($mapInfoWindow = new InfoWindow()); - $mapInfoWindow->setJavascriptVariable('map_info_window'); - $mapInfoWindow->setPosition(1, 2, true); - $mapInfoWindow->getPosition()->setJavascriptVariable('map_info_window_position'); - - $map->addMarker($marker = new Marker()); - $marker->setInfoWindow($markerInfoWindow = new InfoWindow()); - $markerInfoWindow->setJavascriptVariable('marker_info_window'); - $markerInfoWindow->setPosition(1, 2, true); - $markerInfoWindow->getPosition()->setJavascriptVariable('marker_info_window_position'); - - $mapInfoWindow->setAutoClose(true); - $markerInfoWindow->setAutoClose(true); - - $expected = <<Default content<\/p>"}); -map_container.info_windows.marker_info_window = marker_info_window = new google.maps.InfoWindow({"content":"

Default content<\/p>"}); -map_container.closable_info_windows.map_info_window = map_info_window; -map_container.closable_info_windows.marker_info_window = marker_info_window; - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJsContainerInfoWindows($map)); - } - - public function testRenderJsContainerMarkerImages() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addMarker($marker = new Marker()); - - $marker->setIcon('url_icon'); - $marker->getIcon()->setJavascriptVariable('marker_icon'); - - $marker->setShadow('shadow_url'); - $marker->getShadow()->setJavascriptVariable('marker_shadow'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerMarkerImages($map)); - } - - public function testRenderJsContainerMarkerShapes() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addMarker($marker = new Marker()); - $marker->setShape('poly', array(1, 1, 1, -1, -1, -1, -1, 1)); - $marker->getShape()->setJavascriptVariable('marker_shape'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerMarkerShapes($map)); - } - - public function testRenderJsContainerMarkerCluster() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addMarker($marker = new Marker()); - $marker->setJavascriptVariable('marker'); - $marker->getPosition()->setJavascriptVariable('marker_position'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerMarkerCluster($map)); - } - - public function testRenderJsContainerKMLLayers() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addKMLLayer($kmlLayer = new KMLLayer('url')); - $kmlLayer->setJavascriptVariable('kml_layer'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerKMLLayers($map)); - } - - public function testRenderJsContainerEventManager() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $baseEvent = new Event('instance', 'click', 'function(){}', false); - - $map->getEventManager()->addDomEvent($domEvent = clone $baseEvent); - $domEvent->setJavascriptVariable('dom_event'); - - $map->getEventManager()->addDomEventOnce($domEventOnce = clone $baseEvent); - $domEventOnce->setJavascriptVariable('dom_event_once'); - - $map->getEventManager()->addEvent($event = clone $baseEvent); - $event->setJavascriptVariable('event'); - - $map->getEventManager()->addEventOnce($eventOnce = clone $baseEvent); - $eventOnce->setJavascriptVariable('event_once'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainerEventManager($map)); - } - - public function testRenderJsContainerWithDefaultMap() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->getCenter()->setJavascriptVariable('map_center'); - - $expected = <<assertSame($expected, $this->mapHelper->renderJsContainer($map)); - } - - public function testRenderJsContainerWithComplexMap() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->setAutoZoom(true); - $map->getBound()->setJavascriptVariable('map_bound'); - - $map->addCircle($circle = new Circle()); - $circle->setJavascriptVariable('circle'); - $circle->getCenter()->setJavascriptVariable('circle_center'); - - $map->addEncodedPolyline($encodedPolyline = new EncodedPolyline('foo')); - $encodedPolyline->setJavascriptVariable('encoded_polyline'); - - $map->addGroundOverlay($groundOverlay = new GroundOverlay('url')); - $groundOverlay->setJavascriptVariable('ground_overlay'); - $groundOverlay->getBound()->setJavascriptVariable('ground_overlay_bound'); - $groundOverlay->getBound()->setSouthWest(1, 2, true); - $groundOverlay->getBound()->getSouthWest()->setJavascriptVariable('ground_overlay_bound_south_west'); - $groundOverlay->getBound()->setNorthEast(3, 4, true); - $groundOverlay->getBound()->getNorthEast()->setJavascriptVariable('ground_overlay_bound_north_east'); - - $map->addPolygon($polygon = new Polygon()); - $polygon->setJavascriptVariable('polygon'); - - $map->addPolyline($polyline = new Polyline()); - $polyline->setJavascriptVariable('polyline'); - - $map->addRectangle($rectangle = new Rectangle()); - $rectangle->setJavascriptVariable('rectangle'); - $rectangle->getBound()->setJavascriptVariable('rectangle_bound'); - $rectangle->getBound()->setSouthWest(1, 2, true); - $rectangle->getBound()->getSouthWest()->setJavascriptVariable('rectangle_bound_south_west'); - $rectangle->getBound()->setNorthEast(3, 4, true); - $rectangle->getBound()->getNorthEast()->setJavascriptVariable('rectangle_bound_north_east'); - - $map->addInfoWindow($mapInfoWindow = new InfoWindow()); - $mapInfoWindow->setJavascriptVariable('map_info_window'); - $mapInfoWindow->setPosition(1, 2, true); - $mapInfoWindow->getPosition()->setJavascriptVariable('map_info_window_position'); - - $map->addMarker($marker = new Marker()); - $marker->setJavascriptVariable('marker'); - $marker->getPosition()->setJavascriptVariable('marker_position'); - - $marker->setInfoWindow($markerInfoWindow = new InfoWindow()); - $markerInfoWindow->setJavascriptVariable('marker_info_window'); - - $marker->setIcon('url'); - $marker->getIcon()->setJavascriptVariable('marker_icon'); - - $marker->setShadow('url'); - $marker->getShadow()->setJavascriptVariable('marker_shadow'); - - $map->addKMLLayer($kmlLayer = new KMLLayer('url')); - $kmlLayer->setJavascriptVariable('kml_layer'); - - $map->getEventManager()->addEvent($event = new Event('instance', 'click', 'function(){}', false)); - $event->setJavascriptVariable('event'); - - $expected = <<Default content<\/p>"}); -map_container.info_windows.marker_info_window = marker_info_window = new google.maps.InfoWindow({"content":"

Default content<\/p>"}); -map_container.marker_images.marker_icon = marker_icon = new google.maps.MarkerImage("url", null, null, null, null); -map_container.marker_images.marker_shadow = marker_shadow = new google.maps.MarkerImage("url", null, null, null, null); -map_container.markers.marker = marker = new google.maps.Marker({"position":marker_position,"map":map,"icon":marker_icon,"shadow":marker_shadow}); -map_container.kml_layers.kml_layer = kml_layer = new google.maps.KmlLayer("url", {"map":map}); -map_container.event_manager.events.event = event = google.maps.event.addListener(instance, "click", function(){}); -map_container.event_manager.events.marker_info_window_event = marker_info_window_event = google.maps.event.addListener(marker, "click", function () { - for (var info_window in map_container.closable_info_windows) { - map_container.closable_info_windows[info_window].close(); - } - marker_info_window.open(map, marker); - -}); -map_bound.union(circle.getBounds()); -encoded_polyline.getPath().forEach(function(element){map_bound.extend(element)}); -map_bound.union(ground_overlay_bound); -polygon.getPath().forEach(function(element){map_bound.extend(element)}); -polyline.getPath().forEach(function(element){map_bound.extend(element)}); -map_bound.union(rectangle_bound); -map_bound.extend(map_info_window.getPosition()); -map_bound.extend(marker.getPosition()); -map.fitBounds(map_bound); - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJsContainer($map)); - } - - public function testRenderJavascripts() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->getCenter()->setJavascriptVariable('map_center'); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJavascripts($map)); - } - - public function testRenderJavascriptsWithEncodedPolyline() - { - $encodedPolyline = new EncodedPolyline('foo'); - $encodedPolyline->setJavascriptVariable('encoded_polyline'); - - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->addEncodedPolyline($encodedPolyline); - - $map->getCenter()->setJavascriptVariable('map_center'); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"libraries=geometry&language=en&sensor=false"}); }; - - - - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJavascripts($map)); - } - - public function testRenderJavascriptsWithLibraries() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->setLibraries(array('places')); - - $map->getCenter()->setJavascriptVariable('map_center'); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"libraries=places&language=en&sensor=false"}); }; - - - - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJavascripts($map)); - } - - public function testRenderJavascriptsWithAsync() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->setAsync(true); - - $map->getCenter()->setJavascriptVariable('map_center'); - - $expected = << -function load_ivory_google_map() { -map_container = {"map":null,"coordinates":{},"bounds":{},"points":{},"sizes":{},"circles":{},"encoded_polylines":{},"ground_overlays":{},"polygons":{},"polylines":{},"rectangles":{},"info_windows":{},"marker_images":{},"marker_shapes":{},"markers":{},"marker_cluster":null,"kml_layers":{},"event_manager":{"dom_events":{},"dom_events_once":{},"events":{},"events_once":{}},"closable_info_windows":{},"functions":{"to_array":function (object) { var array = []; for (var key in object) { array.push(object[key]); } return array; }}}; -map_container.coordinates.map_center = map_center = new google.maps.LatLng(0, 0, true); -map_container.map = map = new google.maps.Map(document.getElementById("map_canvas"), {"mapTypeId":google.maps.MapTypeId.ROADMAP,"zoom":3}); -map.setCenter(map_center); -} - - - - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJavascripts($map)); - } - - public function testRenderJavascriptsWithMapInfoWindowOpened() - { - $infoWindow = new InfoWindow(); - $infoWindow->setJavascriptVariable('info_window'); - $infoWindow->setPosition(1.1, 2.2, true); - $infoWindow->getPosition()->setJavascriptVariable('info_window_position'); - $infoWindow->setContent('foo'); - $infoWindow->setAutoOpen(false); - $infoWindow->setOpen(true); - - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->getCenter()->setJavascriptVariable('map_center'); - $map->addInfoWindow($infoWindow); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJavascripts($map)); - } - - public function testRenderJavascriptsWithMarkerInfoWindowOpened() - { - $infoWindow = new InfoWindow(); - $infoWindow->setJavascriptVariable('info_window'); - $infoWindow->setContent('foo'); - $infoWindow->setAutoOpen(false); - $infoWindow->setOpen(true); - - $marker = new Marker(); - $marker->setJavascriptVariable('marker'); - $marker->setPosition(1.2, 2.1, true); - $marker->getPosition()->setJavascriptVariable('marker_position'); - $marker->setInfoWindow($infoWindow); - - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->getCenter()->setJavascriptVariable('map_center'); - $map->addMarker($marker); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJavascripts($map)); - } - - public function testRenderJavascriptsWithMultipleMaps() - { - $map1 = new Map(); - $map1->setJavascriptVariable('map1'); - $map1->getCenter()->setJavascriptVariable('map1_center'); - - $expected1 = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - - -EOF; - - $map2 = new Map(); - $map2->setJavascriptVariable('map2'); - $map2->getCenter()->setJavascriptVariable('map2_center'); - - $expected2 = << -map2_container = {"map":null,"coordinates":{},"bounds":{},"points":{},"sizes":{},"circles":{},"encoded_polylines":{},"ground_overlays":{},"polygons":{},"polylines":{},"rectangles":{},"info_windows":{},"marker_images":{},"marker_shapes":{},"markers":{},"marker_cluster":null,"kml_layers":{},"event_manager":{"dom_events":{},"dom_events_once":{},"events":{},"events_once":{}},"closable_info_windows":{},"functions":{"to_array":function (object) { var array = []; for (var key in object) { array.push(object[key]); } return array; }}}; -map2_container.coordinates.map2_center = map2_center = new google.maps.LatLng(0, 0, true); -map2_container.map = map2 = new google.maps.Map(document.getElementById("map_canvas"), {"mapTypeId":google.maps.MapTypeId.ROADMAP,"zoom":3}); -map2.setCenter(map2_center); - - -EOF; - - $this->assertSame($expected1, $this->mapHelper->renderJavascripts($map1)); - $this->assertSame($expected2, $this->mapHelper->renderJavascripts($map2)); - } - - public function testRenderJavascriptsWithInfoBox() - { - $this->mapHelper->setInfoWindowHelper(new InfoBoxHelper()); - $this->mapHelper->setExtensionHelper('info_box', new InfoBoxExtensionHelper()); - - $map = new Map(); - $map->setJavascriptVariable('map'); - $map->getCenter()->setJavascriptVariable('map_center'); - - $map->addInfoWindow($infoBox = new InfoWindow()); - $infoBox->setJavascriptVariable('map_info_box'); - $infoBox->setPosition(1, 2, true); - $infoBox->getPosition()->setJavascriptVariable('map_info_box_position'); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); }; - - - - - -EOF; - - $this->assertSame($expected, $this->mapHelper->renderJavascripts($map)); - } - - public function testRender() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->getCenter()->setJavascriptVariable('map_center'); - - $expected = << - - - - - -EOF; - - $this->assertSame($expected, $this->mapHelper->render($map)); - } -} diff --git a/tests/Helper/MapTypeIdHelperTest.php b/tests/Helper/MapTypeIdHelperTest.php deleted file mode 100644 index 8c58434b..00000000 --- a/tests/Helper/MapTypeIdHelperTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper; - -use Ivory\GoogleMap\MapTypeId; -use Ivory\GoogleMap\Helper\MapTypeIdHelper; - -/** - * Map type ID helper test. - * - * @author GeLo - */ -class MapTypeIdHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\MapTypeIdHelper */ - protected $mapTypeIdHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->mapTypeIdHelper = new MapTypeIdHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->mapTypeIdHelper); - } - - public function testRenderWithValidValue() - { - $this->assertSame('google.maps.MapTypeId.HYBRID', $this->mapTypeIdHelper->render(MapTypeId::HYBRID)); - $this->assertSame('google.maps.MapTypeId.ROADMAP', $this->mapTypeIdHelper->render(MapTypeId::ROADMAP)); - $this->assertSame('google.maps.MapTypeId.SATELLITE', $this->mapTypeIdHelper->render(MapTypeId::SATELLITE)); - $this->assertSame('google.maps.MapTypeId.TERRAIN', $this->mapTypeIdHelper->render(MapTypeId::TERRAIN)); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The map type id can only be : hybrid, roadmap, satellite, terrain. - */ - public function testRenderWithInvalidValue() - { - $this->mapTypeIdHelper->render('foo'); - } -} diff --git a/tests/Helper/Overlays/AnimationHelperTest.php b/tests/Helper/Overlays/AnimationHelperTest.php deleted file mode 100644 index 29daafe7..00000000 --- a/tests/Helper/Overlays/AnimationHelperTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\Animation; -use Ivory\GoogleMap\Helper\Overlays\AnimationHelper; - -/** - * Animation helper test. - * - * @author GeLo - */ -class AnimationHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\AnimationHelper */ - protected $animationHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->animationHelper = new AnimationHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->animationHelper); - } - - public function testRenderWithValidValue() - { - $this->assertSame('google.maps.Animation.BOUNCE', $this->animationHelper->render(Animation::BOUNCE)); - $this->assertSame('google.maps.Animation.DROP', $this->animationHelper->render(Animation::DROP)); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The animation can only be : bounce, drop. - */ - public function testRenderWithInvalidValue() - { - $this->animationHelper->render('foo'); - } -} diff --git a/tests/Helper/Overlays/CircleHelperTest.php b/tests/Helper/Overlays/CircleHelperTest.php deleted file mode 100644 index 8b07cd58..00000000 --- a/tests/Helper/Overlays/CircleHelperTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\Circle; -use Ivory\GoogleMap\Helper\Overlays\CircleHelper; - -/** - * Circle helper test. - * - * @author GeLo - */ -class CircleHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\CircleHelper */ - protected $circleHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->circleHelper = new CircleHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->circleHelper); - } - - public function testRender() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $circle = new Circle(); - $circle->setJavascriptVariable('circle'); - - $circle->setCenter(1.1, 2.1, true); - $circle->getCenter()->setJavascriptVariable('center'); - - $circle->setRadius(2); - $circle->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = 'circle = new google.maps.Circle({'. - '"map":map,'. - '"center":center,'. - '"radius":2,'. - '"option1":"value1",'. - '"option2":"value2"'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->circleHelper->render($circle, $map)); - } -} diff --git a/tests/Helper/Overlays/EncodedPolylineHelperTest.php b/tests/Helper/Overlays/EncodedPolylineHelperTest.php deleted file mode 100644 index 59936de3..00000000 --- a/tests/Helper/Overlays/EncodedPolylineHelperTest.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\EncodedPolyline; -use Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper; - -/** - * Encoded polyline helper test. - * - * @author GeLo - */ -class EncodedPolylineHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\EncodedPolylineHelper */ - protected $encodedPolylineHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->encodedPolylineHelper = new EncodedPolylineHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->encodedPolylineHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Geometry\EncodingHelper', - $this->encodedPolylineHelper->getEncodingHelper() - ); - } - - public function testInitialState() - { - $encodingHelper = $this->getMock('Ivory\GoogleMap\Helper\Geometry\EncodingHelper'); - - $this->encodedPolylineHelper = new EncodedPolylineHelper($encodingHelper); - - $this->assertSame($encodingHelper, $this->encodedPolylineHelper->getEncodingHelper()); - } - - public function testRenderWithoutOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $encodedPolyline = new EncodedPolyline('foo'); - $encodedPolyline->setJavascriptVariable('encodedPolyline'); - - $this->assertSame( - 'encodedPolyline = new google.maps.Polyline('. - '{"map":map,"path":google.maps.geometry.encoding.decodePath("foo")}'. - ');'.PHP_EOL, - $this->encodedPolylineHelper->render($encodedPolyline, $map) - ); - } - - public function testRenderWithOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $encodedPolyline = new EncodedPolyline('foo'); - $encodedPolyline->setJavascriptVariable('encodedPolyline'); - $encodedPolyline->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $this->assertSame( - 'encodedPolyline = new google.maps.Polyline('. - '{"map":map,"path":google.maps.geometry.encoding.decodePath("foo"),"option1":"value1","option2":"value2"}'. - ');'.PHP_EOL, - $this->encodedPolylineHelper->render($encodedPolyline, $map) - ); - } -} diff --git a/tests/Helper/Overlays/GroundOverlayHelperTest.php b/tests/Helper/Overlays/GroundOverlayHelperTest.php deleted file mode 100644 index 67702020..00000000 --- a/tests/Helper/Overlays/GroundOverlayHelperTest.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Overlays\GroundOverlay; -use Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper; - -/** - * Ground overlay helper test. - * - * @author GeLo - */ -class GroundOverlayHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\GroundOverlayHelper */ - protected $groundOverlayHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->groundOverlayHelper = new GroundOverlayHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->groundOverlayHelper); - } - - public function testRenderWithoutOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $bound = new Bound(); - $bound->setJavascriptVariable('bound'); - $bound->setSouthWest(-1.1, -2.1, true); - $bound->setNorthEast(1.1, 2.1, true); - - $groundOverlay = new GroundOverlay('url', $bound); - $groundOverlay->setJavascriptVariable('groundOverlay'); - - $this->assertSame( - 'groundOverlay = new google.maps.GroundOverlay("url", bound, {"map":map});'.PHP_EOL, - $this->groundOverlayHelper->render($groundOverlay, $map) - ); - } - - public function testRenderWithOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $bound = new Bound(); - $bound->setJavascriptVariable('bound'); - $bound->setSouthWest(-1.1, -2.1, true); - $bound->setNorthEast(1.1, 2.1, true); - - $groundOverlay = new GroundOverlay('url', $bound); - $groundOverlay->setJavascriptVariable('groundOverlay'); - $groundOverlay->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = <<assertSame($expected, $this->groundOverlayHelper->render($groundOverlay, $map)); - } -} diff --git a/tests/Helper/Overlays/InfoBoxHelperTest.php b/tests/Helper/Overlays/InfoBoxHelperTest.php deleted file mode 100644 index f2305315..00000000 --- a/tests/Helper/Overlays/InfoBoxHelperTest.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Helper\Overlays\InfoBoxHelper; -use Ivory\GoogleMap\Overlays\InfoWindow; - -/** - * InfoBox helper test. - * - * @author GeLo - */ -class InfoBoxHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\InfoBoxHelper */ - protected $infoBoxHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->infoBoxHelper = new InfoBoxHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->infoBoxHelper); - } - - public function testRender() - { - $infoWindow = new InfoWindow(); - - $infoWindow->setPosition(1.1, 2.1, true); - $infoWindow->getPosition()->setJavascriptVariable('position'); - - $infoWindow->setPixelOffset(3, 4, 'px', 'px'); - $infoWindow->getPixelOffset()->setJavascriptVariable('pixel_offset'); - - $infoWindow->setContent('content'); - $infoWindow->setOpen(true); - - $infoWindow->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = $infoWindow->getJavascriptVariable().' = new InfoBox({'. - '"position":position,'. - '"pixelOffset":pixel_offset,'. - '"content":"content",'. - '"option1":"value1",'. - '"option2":"value2"'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->infoBoxHelper->render($infoWindow, true)); - } -} diff --git a/tests/Helper/Overlays/InfoWindowHelperTest.php b/tests/Helper/Overlays/InfoWindowHelperTest.php deleted file mode 100644 index b195b4db..00000000 --- a/tests/Helper/Overlays/InfoWindowHelperTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\InfoWindow; -use Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper; - -/** - * Info window helper test. - * - * @author GeLo - */ -class InfoWindowHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper */ - protected $infoWindowHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->infoWindowHelper = new InfoWindowHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->infoWindowHelper); - } - - public function testRenderWithoutPosition() - { - $infoWindow = new InfoWindow(); - - $infoWindow->setPosition(1.1, 2.1, true); - $infoWindow->getPosition()->setJavascriptVariable('position'); - - $infoWindow->setPixelOffset(3, 4, 'px', 'px'); - $infoWindow->getPixelOffset()->setJavascriptVariable('pixel_offset'); - - $infoWindow->setContent('content'); - $infoWindow->setOpen(true); - - $expected = $infoWindow->getJavascriptVariable().' = new google.maps.InfoWindow({'. - '"position":position,'. - '"pixelOffset":pixel_offset,'. - '"content":"content"'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->infoWindowHelper->render($infoWindow, true)); - } - - public function testRenderWithPosition() - { - $infoWindow = new InfoWindow(); - - $infoWindow->setPosition(1.1, 2.1, true); - $infoWindow->getPosition()->setJavascriptVariable('position'); - - $infoWindow->setPixelOffset(3, 4, 'px', 'px'); - $infoWindow->getPixelOffset()->setJavascriptVariable('pixel_offset'); - - $infoWindow->setContent('content'); - $infoWindow->setOpen(true); - - $infoWindow->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = $infoWindow->getJavascriptVariable().' = new google.maps.InfoWindow({'. - '"pixelOffset":pixel_offset,'. - '"content":"content",'. - '"option1":"value1",'. - '"option2":"value2"'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->infoWindowHelper->render($infoWindow, false)); - } - - public function testRenderOpenWithoutMarker() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $infoWindow = new InfoWindow(); - $infoWindow->setJavascriptVariable('infoWindow'); - $infoWindow->setPosition(1.1, 2.1, true); - $infoWindow->setContent('content'); - $infoWindow->setOpen(true); - $infoWindow->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $this->assertSame('infoWindow.open(map);'.PHP_EOL, $this->infoWindowHelper->renderOpen($infoWindow, $map)); - } - - public function testRenderOpenWithMarker() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $infoWindow = new InfoWindow(); - $infoWindow->setJavascriptVariable('infoWindow'); - $infoWindow->setPosition(1.1, 2.1, true); - $infoWindow->setContent('content'); - $infoWindow->setOpen(true); - $infoWindow->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $marker = $this->getMock('Ivory\GoogleMap\Overlays\Marker'); - $marker - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('marker')); - - $this->assertSame( - 'infoWindow.open(map, marker);'.PHP_EOL, - $this->infoWindowHelper->renderOpen($infoWindow, $map, $marker) - ); - } -} diff --git a/tests/Helper/Overlays/MarkerCluster/AbstractMarkerClusterHelperTest.php b/tests/Helper/Overlays/MarkerCluster/AbstractMarkerClusterHelperTest.php deleted file mode 100644 index c82453f6..00000000 --- a/tests/Helper/Overlays/MarkerCluster/AbstractMarkerClusterHelperTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays\MarkerCluster; - -/** - * Abstract marker cluster helper test. - * - * @author GeLo - */ -class AbstractMarkerClusterHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\AbstractMarkerClusterHelper */ - protected $helper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->helper = $this->getMockForAbstractClass('Ivory\GoogleMap\Helper\Overlays\MarkerCluster\AbstractMarkerClusterHelper'); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->helper); - } - - public function testDefaultState() - { - $this->assertInstanceOf('Ivory\GoogleMap\Helper\Overlays\MarkerHelper', $this->helper->getMarkerHelper()); - } - - public function testInitialState() - { - $markerHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerHelper'); - - $this->helper = $this->getMockBuilder('Ivory\GoogleMap\Helper\Overlays\MarkerCluster\AbstractMarkerClusterHelper') - ->setConstructorArgs(array($markerHelper)) - ->getMockForAbstractClass(); - - $this->assertSame($markerHelper, $this->helper->getMarkerHelper()); - } -} diff --git a/tests/Helper/Overlays/MarkerCluster/DefaultMarkerClusterHelperTest.php b/tests/Helper/Overlays/MarkerCluster/DefaultMarkerClusterHelperTest.php deleted file mode 100644 index 98853587..00000000 --- a/tests/Helper/Overlays/MarkerCluster/DefaultMarkerClusterHelperTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays\MarkerCluster; - -use Ivory\GoogleMap\Helper\Overlays\MarkerCluster\DefaultMarkerClusterHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\InfoWindow; -use Ivory\GoogleMap\Overlays\Marker; - -/** - * Default marker cluster helper test. - * - * @author GeLo - */ -class DefaultMarkerClusterHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\DefaultMarkerClusterHelper */ - protected $helper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->helper = new DefaultMarkerClusterHelper(); - } - - /** - * {@inheritdoc} - */ - protected function setDown() - { - unset($this->helper); - } - - public function testDefaultState() - { - $this->assertInstanceOf('Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper', $this->helper->getInfoWindowHelper()); - } - - public function testInitialState() - { - $markerHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerHelper'); - $infoWindowHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\InfoWindowHelper'); - - $this->helper = new DefaultMarkerClusterHelper($markerHelper, $infoWindowHelper); - - $this->assertSame($markerHelper, $this->helper->getMarkerHelper()); - $this->assertSame($infoWindowHelper, $this->helper->getInfoWindowHelper()); - } - - public function testRender() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $markerCluster = $this->getMock('Ivory\GoogleMap\Overlays\MarkerCluster'); - - $this->assertNull($this->helper->render($markerCluster, $map)); - } - - public function testRenderLibraires() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $markerCluster = $this->getMock('Ivory\GoogleMap\Overlays\MarkerCluster'); - - $this->assertNull($this->helper->renderLibraries($markerCluster, $map)); - } - - public function testRenderMarkersWithoutAutoOpenInfoWindow() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addMarker($marker = new Marker()); - $marker->setJavascriptVariable('marker'); - $marker->getPosition()->setJavascriptVariable('marker_position'); - - $expected = <<assertSame($expected, $this->helper->renderMarkers($map->getMarkerCluster(), $map)); - } - - public function testRenderMarkersWithAutoOpenInfoWindow() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addMarker($marker = new Marker()); - $marker->setJavascriptVariable('marker'); - $marker->getPosition()->setJavascriptVariable('marker_position'); - - $marker->setInfoWindow($infoWindow = new InfoWindow()); - $infoWindow->setJavascriptVariable('marker_info_window'); - $infoWindow->setAutoOpen(true); - - $this->helper->renderMarkers($map->getMarkerCluster(), $map); - - $this->assertNotEmpty($map->getEventManager()->getEvents()); - } -} diff --git a/tests/Helper/Overlays/MarkerCluster/JsMarkerClusterHelperTest.php b/tests/Helper/Overlays/MarkerCluster/JsMarkerClusterHelperTest.php deleted file mode 100644 index d1b777a3..00000000 --- a/tests/Helper/Overlays/MarkerCluster/JsMarkerClusterHelperTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays\MarkerCluster; - -use Ivory\GoogleMap\Helper\Overlays\MarkerCluster\JsMarkerClusterHelper; -use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\Overlays\Marker; - -/** - * Javscript marker cluster helper test. - * - * @author GeLo - */ -class JsMarkerClusterHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\JsMarkerClusterHelper */ - protected $helper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->helper = new JsMarkerClusterHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->helper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\MarkerCluster\DefaultMarkerClusterHelper', - $this->helper - ); - } - - public function testRenderWithoutOptions() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->getMarkerCluster()->setJavascriptVariable('marker_cluster'); - - $map->addMarker($marker = new Marker()); - $marker->setJavascriptVariable('marker'); - $marker->getPosition()->setJavascriptVariable('marker_position'); - - $expected = <<assertSame($expected, $this->helper->render($map->getMarkerCluster(), $map)); - } - - public function testRenderWithOptions() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->getMarkerCluster()->setJavascriptVariable('marker_cluster'); - $map->getMarkerCluster()->setOption('foo', 'bar'); - - $map->addMarker($marker = new Marker()); - $marker->setJavascriptVariable('marker'); - $marker->getPosition()->setJavascriptVariable('marker_position'); - - $expected = <<assertSame($expected, $this->helper->render($map->getMarkerCluster(), $map)); - } - - public function testRenderLibraries() - { - $map = new Map(); - - $expected = << - -EOF; - - $this->assertSame($expected, $this->helper->renderLibraries($map->getMarkerCluster(), $map)); - } - - public function testRenderMarkers() - { - $map = new Map(); - $map->setJavascriptVariable('map'); - - $map->addMarker($marker = new Marker()); - $marker->setJavascriptVariable('marker'); - $marker->getPosition()->setJavascriptVariable('marker_position'); - - $expected = <<assertSame($expected, $this->helper->renderMarkers($map->getMarkerCluster(), $map)); - } -} diff --git a/tests/Helper/Overlays/MarkerCluster/MarkerClusterHelperTest.php b/tests/Helper/Overlays/MarkerCluster/MarkerClusterHelperTest.php deleted file mode 100644 index 970bf6eb..00000000 --- a/tests/Helper/Overlays/MarkerCluster/MarkerClusterHelperTest.php +++ /dev/null @@ -1,140 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays\MarkerCluster; - -use Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper; -use Ivory\GoogleMap\Overlays\MarkerCluster; - -/** - * Marker cluster helper test. - * - * @author GeLo - */ -class MarkerClusterHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelper */ - protected $helper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->helper = new MarkerClusterHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->helper); - } - - public function testDefaultState() - { - $this->assertTrue($this->helper->hasHelpers()); - - $this->assertTrue($this->helper->hasHelper(MarkerCluster::_DEFAULT)); - $this->assertTrue($this->helper->hasHelper(MarkerCluster::MARKER_CLUSTER)); - - $this->assertCount(2, $this->helper->getHelpers()); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\MarkerCluster\DefaultMarkerClusterHelper', - $this->helper->getHelper(MarkerCluster::_DEFAULT) - ); - } - - public function testInitialState() - { - $helper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface'); - $this->helper = new MarkerClusterHelper(array('foo' => $helper)); - - $this->assertSame(array('foo' => $helper), $this->helper->getHelpers()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The marker cluster helper can not be resolved. - */ - public function testHelperWithInvalidName() - { - $this->helper->getHelper('foo'); - } - - public function testRender() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - - $markerCluster = $this->getMock('Ivory\GoogleMap\Overlays\MarkerCluster'); - $markerCluster - ->expects($this->any()) - ->method('getType') - ->will($this->returnValue('foo')); - - $helperMock = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface'); - $helperMock - ->expects($this->once()) - ->method('render') - ->with($this->equalTo($markerCluster), $this->equalTo($map)) - ->will($this->returnValue('bar')); - - $this->helper->setHelper('foo', $helperMock); - - $this->assertSame('bar', $this->helper->render($markerCluster, $map)); - } - - public function testRenderMarkers() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - - $markerCluster = $this->getMock('Ivory\GoogleMap\Overlays\MarkerCluster'); - $markerCluster - ->expects($this->any()) - ->method('getType') - ->will($this->returnValue('foo')); - - $helperMock = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface'); - $helperMock - ->expects($this->once()) - ->method('renderMarkers') - ->with($this->equalTo($markerCluster), $this->equalTo($map)) - ->will($this->returnValue('bar')); - - $this->helper->setHelper('foo', $helperMock); - - $this->assertSame('bar', $this->helper->renderMarkers($markerCluster, $map)); - } - - public function testRenderLibraries() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - - $markerCluster = $this->getMock('Ivory\GoogleMap\Overlays\MarkerCluster'); - $markerCluster - ->expects($this->any()) - ->method('getType') - ->will($this->returnValue('foo')); - - $helperMock = $this->getMock('Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface'); - $helperMock - ->expects($this->once()) - ->method('renderLibraries') - ->with($this->equalTo($markerCluster), $this->equalTo($map)) - ->will($this->returnValue('bar')); - - $this->helper->setHelper('foo', $helperMock); - - $this->assertSame('bar', $this->helper->renderLibraries($markerCluster, $map)); - } -} diff --git a/tests/Helper/Overlays/MarkerHelperTest.php b/tests/Helper/Overlays/MarkerHelperTest.php deleted file mode 100644 index 448700ad..00000000 --- a/tests/Helper/Overlays/MarkerHelperTest.php +++ /dev/null @@ -1,168 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\Animation; -use Ivory\GoogleMap\Overlays\Marker; -use Ivory\GoogleMap\Helper\Overlays\MarkerHelper; - -/** - * Marker helper test. - * - * @author GeLo - */ -class MarkerHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerHelper */ - protected $markerHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->markerHelper = new MarkerHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->markerHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Overlays\AnimationHelper', - $this->markerHelper->getAnimationHelper() - ); - } - - public function testInitialState() - { - $animationHelper = $this->getMock('Ivory\GoogleMap\Helper\Overlays\AnimationHelper'); - - $this->markerHelper = new MarkerHelper($animationHelper); - - $this->assertSame($animationHelper, $this->markerHelper->getAnimationHelper()); - } - - public function testRenderWithoutOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $marker = new Marker(); - $marker->setJavascriptVariable('marker'); - - $marker->setAnimation(Animation::BOUNCE); - - $marker->setPosition(1.1, 2.1, true); - $marker->getPosition()->setJavascriptVariable('position'); - - $marker->setIcon('url'); - $marker->getIcon()->setJavascriptVariable('icon'); - - $marker->setShadow('url'); - $marker->getShadow()->setJavascriptVariable('shadow'); - - $marker->setShape('poly', array(1, 2, 3, 4)); - $marker->getShape()->setJavascriptVariable('shape'); - - $expected = 'marker = new google.maps.Marker({'. - '"position":position,'. - '"map":map,'. - '"animation":google.maps.Animation.BOUNCE,'. - '"icon":icon,'. - '"shadow":shadow,'. - '"shape":shape'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->markerHelper->render($marker, $map)); - } - - public function testRenderWithOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->any()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $marker = new Marker(); - $marker->setJavascriptVariable('marker'); - - $marker->setAnimation(Animation::BOUNCE); - - $marker->setPosition(1.1, 2.1, true); - $marker->getPosition()->setJavascriptVariable('position'); - - $marker->setIcon('url'); - $marker->getIcon()->setJavascriptVariable('icon'); - - $marker->setShadow('url'); - $marker->getShadow()->setJavascriptVariable('shadow'); - - $marker->setShape('poly', array(1, 2, 3, 4)); - $marker->getShape()->setJavascriptVariable('shape'); - - $marker->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = 'marker = new google.maps.Marker({'. - '"position":position,'. - '"map":map,'. - '"animation":google.maps.Animation.BOUNCE,'. - '"icon":icon,'. - '"shadow":shadow,'. - '"shape":shape,'. - '"option1":"value1",'. - '"option2":"value2"'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->markerHelper->render($marker, $map)); - } - - public function testRenderWitoutMap() - { - $marker = new Marker(); - $marker->setJavascriptVariable('marker'); - - $marker->setAnimation(Animation::BOUNCE); - - $marker->setPosition(1.1, 2.1, true); - $marker->getPosition()->setJavascriptVariable('position'); - - $marker->setIcon('url'); - $marker->getIcon()->setJavascriptVariable('icon'); - - $marker->setShadow('url'); - $marker->getShadow()->setJavascriptVariable('shadow'); - - $marker->setShape('poly', array(1, 2, 3, 4)); - $marker->getShape()->setJavascriptVariable('shape'); - - $expected = 'marker = new google.maps.Marker({'. - '"position":position,'. - '"animation":google.maps.Animation.BOUNCE,'. - '"icon":icon,'. - '"shadow":shadow,'. - '"shape":shape'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->markerHelper->render($marker)); - } -} diff --git a/tests/Helper/Overlays/MarkerImageHelperTest.php b/tests/Helper/Overlays/MarkerImageHelperTest.php deleted file mode 100644 index 8ef8a6ed..00000000 --- a/tests/Helper/Overlays/MarkerImageHelperTest.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\MarkerImage; -use Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper; - -/** - * Marker image helper test. - * - * @author GeLo - */ -class MarkerImageHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerImageHelper */ - protected $markerImageHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->markerImageHelper = new MarkerImageHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->markerImageHelper); - } - - public function testRender() - { - $markerImage = new MarkerImage(); - $markerImage->setJavascriptVariable('markerImage'); - $markerImage->setUrl('url'); - - $markerImage->setSize(1, 2); - $markerImage->getSize()->setJavascriptVariable('size'); - - $markerImage->setOrigin(3, 4); - $markerImage->getOrigin()->setJavascriptVariable('origin'); - - $markerImage->setAnchor(5, 6); - $markerImage->getAnchor()->setJavascriptVariable('anchor'); - - $markerImage->setScaledSize(7, 8); - $markerImage->getScaledSize()->setJavascriptVariable('scaled_size'); - - $expected = <<assertSame($expected, $this->markerImageHelper->render($markerImage)); - } -} diff --git a/tests/Helper/Overlays/MarkerShapeHelperTest.php b/tests/Helper/Overlays/MarkerShapeHelperTest.php deleted file mode 100644 index 8c88c60b..00000000 --- a/tests/Helper/Overlays/MarkerShapeHelperTest.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\MarkerShape; -use Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper; - -/** - * Marker shape helper test. - * - * @author GeLo - */ -class MarkerShapeHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\MarkerShapeHelper */ - protected $markerShapeHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->markerShapeHelper = new MarkerShapeHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->markerShapeHelper); - } - - public function testRenderWithPolyType() - { - $markerShape = new MarkerShape('poly', array(1, 2, 3, 4, 5, 6)); - $markerShape->setJavascriptVariable('markerShape'); - - $this->assertSame( - 'markerShape = new google.maps.MarkerShape({"type":"poly","coords":[1,2,3,4,5,6]});'.PHP_EOL, - $this->markerShapeHelper->render($markerShape) - ); - } - - public function testRenderWithCircleType() - { - $markerShape = new MarkerShape('circle', array(1, 2, 3)); - $markerShape->setJavascriptVariable('markerShape'); - - $this->assertSame( - 'markerShape = new google.maps.MarkerShape({"type":"circle","coords":[1,2,3]});'.PHP_EOL, - $this->markerShapeHelper->render($markerShape) - ); - } - - public function testRenderWithRectangleType() - { - $markerShape = new MarkerShape('rect', array(-1, -1, 1, 1)); - $markerShape->setJavascriptVariable('markerShape'); - - $this->assertSame( - 'markerShape = new google.maps.MarkerShape({"type":"rect","coords":[-1,-1,1,1]});'.PHP_EOL, - $this->markerShapeHelper->render($markerShape) - ); - } -} diff --git a/tests/Helper/Overlays/PolygonHelperTest.php b/tests/Helper/Overlays/PolygonHelperTest.php deleted file mode 100644 index ef1e52a4..00000000 --- a/tests/Helper/Overlays/PolygonHelperTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\Polygon; -use Ivory\GoogleMap\Helper\Overlays\PolygonHelper; - -/** - * Polygon helper test. - * - * @author GeLo - */ -class PolygonHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\PolygonHelper */ - protected $polygonHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->polygonHelper = new PolygonHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->polygonHelper); - } - - public function testRenderWithoutOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $polygon = new Polygon(); - $polygon->setJavascriptVariable('polygon'); - - $polygon->addCoordinate(1.1, 2.1); - $polygon->addCoordinate(3.1, 4.2); - $polygon->addCoordinate(7.4, 12.6); - - foreach ($polygon->getCoordinates() as $index => $coordinate) { - $coordinate->setJavascriptVariable('coordinate'.$index); - } - - $this->assertSame( - 'polygon = new google.maps.Polygon({"map":map,"paths":[coordinate0,coordinate1,coordinate2]});'.PHP_EOL, - $this->polygonHelper->render($polygon, $map) - ); - } - - public function testRenderWithOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $polygon = new Polygon(); - $polygon->setJavascriptVariable('polygon'); - - $polygon->addCoordinate(1.1, 2.1); - $polygon->addCoordinate(3.1, 4.2); - $polygon->addCoordinate(7.4, 12.6); - - foreach ($polygon->getCoordinates() as $index => $coordinate) { - $coordinate->setJavascriptVariable('coordinate'.$index); - } - - $polygon->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = 'polygon = new google.maps.Polygon({'. - '"map":map,'. - '"paths":['. - 'coordinate0,'. - 'coordinate1,'. - 'coordinate2'. - '],'. - '"option1":"value1",'. - '"option2":"value2"'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->polygonHelper->render($polygon, $map)); - } -} diff --git a/tests/Helper/Overlays/PolylineHelperTest.php b/tests/Helper/Overlays/PolylineHelperTest.php deleted file mode 100644 index f509e192..00000000 --- a/tests/Helper/Overlays/PolylineHelperTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Overlays\Polyline; -use Ivory\GoogleMap\Helper\Overlays\PolylineHelper; - -/** - * Polyline helper test. - * - * @author GeLo - */ -class PolylineHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\PolylineHelper */ - protected $polylineHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->polylineHelper = new PolylineHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->polylineHelper); - } - - public function testRenderWithoutOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $polyline = new Polyline(); - $polyline->setJavascriptVariable('polyline'); - - $polyline->addCoordinate(1.1, 2.1); - $polyline->addCoordinate(3.1, 4.2); - $polyline->addCoordinate(7.4, 12.6); - - foreach ($polyline->getCoordinates() as $index => $coordinate) { - $coordinate->setJavascriptVariable('coordinate'.$index); - } - - $this->assertSame( - 'polyline = new google.maps.Polyline({"map":map,"path":[coordinate0,coordinate1,coordinate2]});'.PHP_EOL, - $this->polylineHelper->render($polyline, $map) - ); - } - - public function testRenderWithOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $polyline = new Polyline(); - $polyline->setJavascriptVariable('polyline'); - - $polyline->addCoordinate(1.1, 2.1); - $polyline->addCoordinate(3.1, 4.2); - $polyline->addCoordinate(7.4, 12.6); - - foreach ($polyline->getCoordinates() as $index => $coordinate) { - $coordinate->setJavascriptVariable('coordinate'.$index); - } - - $polyline->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = 'polyline = new google.maps.Polyline({'. - '"map":map,'. - '"path":['. - 'coordinate0,'. - 'coordinate1,'. - 'coordinate2'. - '],'. - '"option1":"value1",'. - '"option2":"value2"'. - '});'.PHP_EOL; - - $this->assertSame($expected, $this->polylineHelper->render($polyline, $map)); - } -} diff --git a/tests/Helper/Overlays/RectangleHelperTest.php b/tests/Helper/Overlays/RectangleHelperTest.php deleted file mode 100644 index 378d12b8..00000000 --- a/tests/Helper/Overlays/RectangleHelperTest.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Overlays; - -use Ivory\GoogleMap\Base\Bound; -use Ivory\GoogleMap\Overlays\Rectangle; -use Ivory\GoogleMap\Helper\Overlays\RectangleHelper; - -/** - * Rectangle helper test. - * - * @author GeLo - */ -class RectangleHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Overlays\RectangleHelper */ - protected $rectangleHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->rectangleHelper = new RectangleHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->rectangleHelper); - } - - public function testRenderWithoutOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $bound = new Bound(); - $bound->setJavascriptVariable('rectangleBound'); - $bound->setSouthWest(-1.1, -2.1); - $bound->setNorthEast(1.1, 2.1); - - $rectangle = new Rectangle($bound); - $rectangle->setJavascriptVariable('rectangle'); - - $this->assertSame( - 'rectangle = new google.maps.Rectangle({"map":map,"bounds":rectangleBound});'.PHP_EOL, - $this->rectangleHelper->render($rectangle, $map) - ); - } - - public function testRenderWithOptions() - { - $map = $this->getMock('Ivory\GoogleMap\Map'); - $map - ->expects($this->once()) - ->method('getJavascriptVariable') - ->will($this->returnValue('map')); - - $bound = new Bound(); - $bound->setJavascriptVariable('rectangleBound'); - $bound->setSouthWest(-1.1, -2.1); - $bound->setNorthEast(1.1, 2.1); - - $rectangle = new Rectangle($bound); - $rectangle->setJavascriptVariable('rectangle'); - $rectangle->setOptions(array('option1' => 'value1', 'option2' => 'value2')); - - $expected = <<assertSame($expected, $this->rectangleHelper->render($rectangle, $map)); - } -} diff --git a/tests/Helper/Places/AutocompleteHelperTest.php b/tests/Helper/Places/AutocompleteHelperTest.php deleted file mode 100644 index 99d6d5ca..00000000 --- a/tests/Helper/Places/AutocompleteHelperTest.php +++ /dev/null @@ -1,290 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Helper\Places; - -use Ivory\GoogleMap\Helper\Places\AutocompleteHelper; -use Ivory\GoogleMap\Places\Autocomplete; -use Ivory\GoogleMap\Places\AutocompleteComponentRestriction; -use Ivory\GoogleMap\Places\AutocompleteType; - -/** - * Autocomplete helper test. - * - * @author GeLo - */ -class AutocompleteHelperTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Helper\Places\AutocompleteHelper */ - protected $autocompleteHelper; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->autocompleteHelper = new AutocompleteHelper(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->autocompleteHelper); - } - - public function testDefaultState() - { - $this->assertInstanceOf('Ivory\GoogleMap\Helper\ApiHelper', $this->autocompleteHelper->getApiHelper()); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Helper\Base\CoordinateHelper', - $this->autocompleteHelper->getCoordinateHelper() - ); - - $this->assertInstanceOf('ivory\GoogleMap\Helper\Base\BoundHelper', $this->autocompleteHelper->getBoundHelper()); - } - - public function testInitialState() - { - $apiHelper = $this->getMock('Ivory\GoogleMap\Helper\ApiHelper'); - $coordinateHelper = $this->getMock('Ivory\GoogleMap\Helper\Base\CoordinateHelper'); - $boundHelper = $this->getMock('Ivory\GoogleMap\Helper\Base\BoundHelper'); - - $this->autocompleteHelper = new AutocompleteHelper($apiHelper, $coordinateHelper, $boundHelper); - - $this->assertSame($apiHelper, $this->autocompleteHelper->getApiHelper()); - $this->assertSame($coordinateHelper, $this->autocompleteHelper->getCoordinateHelper()); - $this->assertSame($boundHelper, $this->autocompleteHelper->getBoundHelper()); - } - - public function testRenderHtmlContainerWithoutValue() - { - $autocomplete = new Autocomplete(); - - $this->assertSame( - ''.PHP_EOL, - $this->autocompleteHelper->renderHtmlContainer($autocomplete) - ); - } - - public function testRenderHtmlContainerWithValue() - { - $autocomplete = new Autocomplete(); - $autocomplete->setValue('foo'); - - $this->assertSame( - ''.PHP_EOL, - $this->autocompleteHelper->renderHtmlContainer($autocomplete) - ); - } - - public function testRenderHtmlContainerWithoutCustomInputAttributes() - { - $autocomplete = new Autocomplete(); - $autocomplete->setInputAttribute('class', 'foo'); - - $this->assertSame( - ''.PHP_EOL, - $this->autocompleteHelper->renderHtmlContainer($autocomplete) - ); - } - - public function testRenderAutocomplete() - { - $autocomplete = new Autocomplete(); - $autocomplete->setJavascriptVariable('autocomplete'); - - $expected = <<assertSame($expected, $this->autocompleteHelper->renderAutocomplete($autocomplete)); - } - - public function testRenderAutocompleteWithTypes() - { - $autocomplete = new Autocomplete(); - $autocomplete->setJavascriptVariable('autocomplete'); - $autocomplete->setTypes(array(AutocompleteType::ESTABLISHMENT, AutocompleteType::CITIES)); - - $expected = <<assertSame($expected, $this->autocompleteHelper->renderAutocomplete($autocomplete)); - } - - public function testRenderAutocompleteWithComponentRestrictions() - { - $autocomplete = new Autocomplete(); - $autocomplete->setJavascriptVariable('autocomplete'); - $autocomplete->setComponentRestrictions(array(AutocompleteComponentRestriction::COUNTRY => 'fr')); - - $expected = <<assertSame($expected, $this->autocompleteHelper->renderAutocomplete($autocomplete)); - } - - public function testRenderAutocompleteWithBound() - { - $autocomplete = new Autocomplete(); - $autocomplete->setJavascriptVariable('autocomplete'); - - $autocomplete->setBound(1, 2, 3, 4); - $autocomplete->getBound()->setJavascriptVariable('bound'); - - $expected = <<assertSame($expected, $this->autocompleteHelper->renderAutocomplete($autocomplete)); - } - - public function testRenderAutocompleteWithTypesAndComponentRestrictionsAndBound() - { - $autocomplete = new Autocomplete(); - $autocomplete->setJavascriptVariable('autocomplete'); - - $autocomplete->setTypes(array(AutocompleteType::ESTABLISHMENT, AutocompleteType::CITIES)); - $autocomplete->setComponentRestrictions(array(AutocompleteComponentRestriction::COUNTRY => 'fr')); - - $autocomplete->setBound(1, 2, 3, 4); - $autocomplete->getBound()->setJavascriptVariable('bound'); - - $expected = <<assertSame($expected, $this->autocompleteHelper->renderAutocomplete($autocomplete)); - } - - public function testRenderJavascriptsWithOneAutocomplete() - { - $autocomplete = new Autocomplete(); - $autocomplete->setJavascriptVariable('autocomplete'); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"libraries=places&language=en&sensor=false"}); }; - - - - -EOF; - - $this->assertSame($expected, $this->autocompleteHelper->renderJavascripts($autocomplete)); - } - - public function testRenderJavascriptsWithMultipleAutocompletes() - { - $autocomplete1 = new Autocomplete(); - $autocomplete1->setJavascriptVariable('autocomplete1'); - - $autocomplete2 = new Autocomplete(); - $autocomplete2->setJavascriptVariable('autocomplete2'); - - $expected1 = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"libraries=places&language=en&sensor=false"}); }; - - - - -EOF; - - $expected2 = << -autocomplete2 = new google.maps.places.Autocomplete(document.getElementById('place_input'), {}); - - -EOF; - - $this->assertSame($expected1, $this->autocompleteHelper->renderJavascripts($autocomplete1)); - $this->assertSame($expected2, $this->autocompleteHelper->renderJavascripts($autocomplete2)); - } - - public function testRenderJavascriptsWithBound() - { - $autocomplete = new Autocomplete(); - $autocomplete->setJavascriptVariable('autocomplete'); - - $autocomplete->setBound(1, 2, 3, 4, true, false); - $autocomplete->getBound()->setJavascriptVariable('bound'); - $autocomplete->getBound()->getSouthWest()->setJavascriptVariable('bound_south_west'); - $autocomplete->getBound()->getNorthEast()->setJavascriptVariable('bound_north_east'); - - $expected = << -function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"libraries=places&language=en&sensor=false"}); }; - - - - -EOF; - - $this->assertSame($expected, $this->autocompleteHelper->renderJavascripts($autocomplete)); - } - - public function testRenderJavascriptsWithAsync() - { - $autocomplete = new Autocomplete(); - $autocomplete->setJavascriptVariable('autocomplete'); - $autocomplete->setAsync(true); - - $expected = << -function load_ivory_google_place () { -autocomplete = new google.maps.places.Autocomplete(document.getElementById('place_input'), {}); -} - - - - -EOF; - - $this->assertSame($expected, $this->autocompleteHelper->renderJavascripts($autocomplete)); - } - - /** - * @expectedException Ivory\GoogleMap\Exception\HelperException - * @expectedExceptionMessage The place autocomplete bound must have coordinates. - */ - public function testRenderJavascriptsWithInvalidBound() - { - $autocomplete = new Autocomplete(); - - $autocomplete->setBound(1, 2, 3, 4); - $autocomplete->getBound()->setSouthWest(null); - $autocomplete->getBound()->setNorthEast(null); - - $this->autocompleteHelper->renderJavascripts($autocomplete); - } -} diff --git a/tests/Helper/Renderer/ApiInitRendererTest.php b/tests/Helper/Renderer/ApiInitRendererTest.php new file mode 100644 index 00000000..5a9193ff --- /dev/null +++ b/tests/Helper/Renderer/ApiInitRendererTest.php @@ -0,0 +1,106 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\ApiInitRenderer; + +/** + * @author GeLo + */ +class ApiInitRendererTest extends\PHPUnit_Framework_TestCase +{ + /** + * @var ApiInitRenderer + */ + private $apiInitRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->apiInitRenderer = new ApiInitRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->apiInitRenderer); + } + + public function testRender() + { + $this->assertSame( + 'function name(){source_callback("source1");source_callback("source2");requirement_callback(main_callback,function(){return requirement1&&requirement2;});};', + $this->apiInitRenderer->render( + 'name', + $this->createCallbacks($object = new \stdClass()), + $this->createRequirements($object), + ['source1', 'source2'], + 'source_callback', + 'requirement_callback' + ) + ); + } + + public function testRenderWithDebug() + { + $this->apiInitRenderer->getFormatter()->setDebug(true); + + $expected = <<assertSame($expected, $this->apiInitRenderer->render( + 'name', + $this->createCallbacks($object = new \stdClass()), + $this->createRequirements($object), + ['source1', 'source2'], + 'source_callback', + 'requirement_callback' + )); + } + + /** + * @param object $object + * + * @return \SplObjectStorage + */ + private function createCallbacks($object) + { + $callbacks = new \SplObjectStorage(); + $callbacks[$object] = 'main_callback'; + + return $callbacks; + } + + /** + * @param object $object + * + * @return \SplObjectStorage + */ + private function createRequirements($object) + { + $requirements = new \SplObjectStorage(); + $requirements[$object] = ['requirement1', 'requirement2']; + + return $requirements; + } +} diff --git a/tests/Helper/Renderer/ApiRendererTest.php b/tests/Helper/Renderer/ApiRendererTest.php new file mode 100644 index 00000000..1c3035cd --- /dev/null +++ b/tests/Helper/Renderer/ApiRendererTest.php @@ -0,0 +1,201 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\ApiInitRenderer; +use Ivory\GoogleMap\Helper\Renderer\ApiRenderer; +use Ivory\GoogleMap\Helper\Renderer\LoaderRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementLoaderRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\SourceRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class ApiRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ApiRenderer + */ + private $apiRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->apiRenderer = new ApiRenderer( + $formatter = new Formatter(), + new ApiInitRenderer($formatter), + new LoaderRenderer($formatter, new JsonBuilder()), + new RequirementLoaderRenderer($formatter), + new SourceRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->apiRenderer); + } + + public function testApiInitRenderer() + { + $this->apiRenderer->setApiInitRenderer($apiInitRenderer = $this->createApiInitRendererMock()); + + $this->assertSame($apiInitRenderer, $this->apiRenderer->getApiInitRenderer()); + } + + public function testLoaderRenderer() + { + $this->apiRenderer->setLoaderRenderer($loaderRenderer = $this->createLoaderRendererMock()); + + $this->assertSame($loaderRenderer, $this->apiRenderer->getLoaderRenderer()); + } + + public function testRequirementLoaderRenderer() + { + $requirementLoaderRenderer = $this->createRequirementLoaderRendererMock(); + $this->apiRenderer->setRequirementLoaderRenderer($requirementLoaderRenderer); + + $this->assertSame($requirementLoaderRenderer, $this->apiRenderer->getRequirementLoaderRenderer()); + } + + public function testSourceRenderer() + { + $this->apiRenderer->setSourceRenderer($sourceRenderer = $this->createSourceRendererMock()); + + $this->assertSame($sourceRenderer, $this->apiRenderer->getSourceRenderer()); + } + + public function testRender() + { + $this->assertSame( + 'function ivory_google_map_load(){google.load("maps","3",{"other_params":"language=en&libraries=library1,library2","callback":ivory_google_map_init})};function ivory_google_map_init_source(src){var script=document.createElement("script");script.type="text/javascript";script.async=true;script.src=src;document.getElementsByTagName("head")[0].appendChild(script);};function ivory_google_map_init_requirement(c,r){if(r()){c();}else{var i=setInterval(function(){if(r()){clearInterval(i);c();}},100);}};function ivory_google_map_init(){ivory_google_map_init_source("source1");ivory_google_map_init_source("source2");ivory_google_map_init_requirement(main_callback,function(){return requirement1&&requirement2;});};ivory_google_map_init_source("https://www.google.com/jsapi?callback=ivory_google_map_load");', + $this->apiRenderer->render( + 'en', + $this->createCallbacks($object = new \stdClass()), + $this->createRequirements($object), + ['source1', 'source2'], + ['library1', 'library2'] + ) + ); + } + + public function testRenderWithDebug() + { + $this->apiRenderer->getFormatter()->setDebug(true); + + $expected = <<assertSame($expected, $this->apiRenderer->render( + 'en', + $this->createCallbacks($object = new \stdClass()), + $this->createRequirements($object), + ['source1', 'source2'], + ['library1', 'library2'] + )); + } + + /** + * @param object $object + * + * @return \SplObjectStorage + */ + private function createCallbacks($object) + { + $callbacks = new \SplObjectStorage(); + $callbacks[$object] = 'main_callback'; + + return $callbacks; + } + + /** + * @param object $object + * + * @return \SplObjectStorage + */ + private function createRequirements($object) + { + $requirements = new \SplObjectStorage(); + $requirements[$object] = ['requirement1', 'requirement2']; + + return $requirements; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ApiInitRenderer + */ + private function createApiInitRendererMock() + { + return $this->createMock(ApiInitRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|LoaderRenderer + */ + private function createLoaderRendererMock() + { + return $this->createMock(LoaderRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RequirementLoaderRenderer + */ + private function createRequirementLoaderRendererMock() + { + return $this->createMock(RequirementLoaderRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|SourceRenderer + */ + private function createSourceRendererMock() + { + return $this->createMock(SourceRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Base/BoundRendererTest.php b/tests/Helper/Renderer/Base/BoundRendererTest.php new file mode 100644 index 00000000..85970e00 --- /dev/null +++ b/tests/Helper/Renderer/Base/BoundRendererTest.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Base; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Base\BoundRenderer; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class BoundRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var BoundRenderer + */ + private $boundRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->boundRenderer = new BoundRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->boundRenderer); + } + + public function testRender() + { + $bound = new Bound(); + $bound->setVariable('bound'); + + $this->assertSame( + 'bound=new google.maps.LatLngBounds()', + $this->boundRenderer->render($bound) + ); + } + + public function testRenderWithCoordinates() + { + $southWest = new Coordinate(); + $southWest->setVariable('south_west'); + + $northEast = new Coordinate(); + $northEast->setVariable('north_east'); + + $bound = new Bound($southWest, $northEast); + $bound->setVariable('bound'); + + $this->assertSame( + 'bound=new google.maps.LatLngBounds(south_west,north_east)', + $this->boundRenderer->render($bound) + ); + } + + public function testRenderWithExtendables() + { + $bound = new Bound(new Coordinate(), new Coordinate()); + $bound->setVariable('bound'); + $bound->addExtendable($this->createExtendableMock()); + + $this->assertSame( + 'bound=new google.maps.LatLngBounds()', + $this->boundRenderer->render($bound) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ExtendableInterface + */ + private function createExtendableMock() + { + return $this->createMock(ExtendableInterface::class); + } +} diff --git a/tests/Helper/Renderer/Base/CoordinateRendererTest.php b/tests/Helper/Renderer/Base/CoordinateRendererTest.php new file mode 100644 index 00000000..38cd43fc --- /dev/null +++ b/tests/Helper/Renderer/Base/CoordinateRendererTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Base; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Base\CoordinateRenderer; + +/** + * @author GeLo + */ +class CoordinateRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CoordinateRenderer + */ + private $coordinateRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->coordinateRenderer = new CoordinateRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->coordinateRenderer); + } + + public function testRender() + { + $coordinate = new Coordinate(1.2, 2.3); + $coordinate->setVariable('coordinate'); + + $this->assertSame( + 'coordinate=new google.maps.LatLng(1.2,2.3,true)', + $this->coordinateRenderer->render($coordinate) + ); + } +} diff --git a/tests/Helper/Renderer/Base/PointRendererTest.php b/tests/Helper/Renderer/Base/PointRendererTest.php new file mode 100644 index 00000000..ff713a8d --- /dev/null +++ b/tests/Helper/Renderer/Base/PointRendererTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Base; + +use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Base\PointRenderer; + +/** + * @author GeLo + */ +class PointRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PointRenderer + */ + private $pointRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->pointRenderer = new PointRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->pointRenderer); + } + + public function testRender() + { + $point = new Point(1.2, 2.3); + $point->setVariable('point'); + + $this->assertSame( + 'point=new google.maps.Point(1.2,2.3)', + $this->pointRenderer->render($point) + ); + } +} diff --git a/tests/Helper/Renderer/Base/SizeRendererTest.php b/tests/Helper/Renderer/Base/SizeRendererTest.php new file mode 100644 index 00000000..1c918831 --- /dev/null +++ b/tests/Helper/Renderer/Base/SizeRendererTest.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Base; + +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Base\SizeRenderer; + +/** + * @author GeLo + */ +class SizeRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var SizeRenderer + */ + private $sizeRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->sizeRenderer = new SizeRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->sizeRenderer); + } + + public function testRender() + { + $size = new Size(1.2, 2.3); + $size->setVariable('size'); + + $this->assertSame( + 'size=new google.maps.Size(1.2,2.3)', + $this->sizeRenderer->render($size) + ); + } + + public function testRenderWithUnits() + { + $size = new Size(1.2, 2.3, 'px', 'pt'); + $size->setVariable('size'); + + $this->assertSame( + 'size=new google.maps.Size(1.2,2.3,"px","pt")', + $this->sizeRenderer->render($size) + ); + } +} diff --git a/tests/Helper/Renderer/Control/ControlManagerRendererTest.php b/tests/Helper/Renderer/Control/ControlManagerRendererTest.php new file mode 100644 index 00000000..4dab673f --- /dev/null +++ b/tests/Helper/Renderer/Control/ControlManagerRendererTest.php @@ -0,0 +1,155 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ControlManager; +use Ivory\GoogleMap\Control\MapTypeControl; +use Ivory\GoogleMap\Control\RotateControl; +use Ivory\GoogleMap\Control\ScaleControl; +use Ivory\GoogleMap\Control\StreetViewControl; +use Ivory\GoogleMap\Control\ZoomControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlManagerRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlPositionRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Control\MapTypeControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\MapTypeControlStyleRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\RotateControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ScaleControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ScaleControlStyleRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\StreetViewControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ZoomControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ZoomControlStyleRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapTypeIdRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class ControlManagerRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ControlManagerRenderer + */ + private $controlManagerRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->controlManagerRenderer = new ControlManagerRenderer(); + } + + public function testDefaultState() + { + $this->assertFalse($this->controlManagerRenderer->hasRenderers()); + $this->assertEmpty($this->controlManagerRenderer->getRenderers()); + } + + public function testSetRenderers() + { + $this->controlManagerRenderer->setRenderers($renderers = [$renderer = $this->createControlRendererMock()]); + $this->controlManagerRenderer->setRenderers($renderers); + + $this->assertTrue($this->controlManagerRenderer->hasRenderers()); + $this->assertTrue($this->controlManagerRenderer->hasRenderer($renderer)); + $this->assertSame($renderers, $this->controlManagerRenderer->getRenderers()); + } + + public function testAddRenderers() + { + $this->controlManagerRenderer->setRenderers($firstRenderers = [$this->createControlRendererMock()]); + $this->controlManagerRenderer->addRenderers($secondRenderers = [$this->createControlRendererMock()]); + + $this->assertTrue($this->controlManagerRenderer->hasRenderers()); + $this->assertSame( + array_merge($firstRenderers, $secondRenderers), + $this->controlManagerRenderer->getRenderers() + ); + } + + public function testAddRenderer() + { + $this->controlManagerRenderer->addRenderer($renderer = $this->createControlRendererMock()); + + $this->assertTrue($this->controlManagerRenderer->hasRenderers()); + $this->assertTrue($this->controlManagerRenderer->hasRenderer($renderer)); + $this->assertSame([$renderer], $this->controlManagerRenderer->getRenderers()); + } + + public function testRemoveRenderer() + { + $this->controlManagerRenderer->addRenderer($renderer = $this->createControlRendererMock()); + $this->controlManagerRenderer->removeRenderer($renderer); + + $this->assertFalse($this->controlManagerRenderer->hasRenderers()); + $this->assertFalse($this->controlManagerRenderer->hasRenderer($renderer)); + $this->assertEmpty($this->controlManagerRenderer->getRenderers()); + } + + public function testRender() + { + $this->controlManagerRenderer->addRenderers([ + new MapTypeControlRenderer( + $formatter = new Formatter(), + $jsonBuilder = new JsonBuilder(), + new MapTypeIdRenderer($formatter), + $controlPositionRenderer = new ControlPositionRenderer($formatter), + new MapTypeControlStyleRenderer($formatter) + ), + new RotateControlRenderer($formatter, $jsonBuilder, $controlPositionRenderer), + new ScaleControlRenderer( + $formatter, + $jsonBuilder, + $controlPositionRenderer, + new ScaleControlStyleRenderer($formatter) + ), + new StreetViewControlRenderer($formatter, $jsonBuilder, $controlPositionRenderer), + new ZoomControlRenderer( + $formatter, + $jsonBuilder, + $controlPositionRenderer, + new ZoomControlStyleRenderer($formatter) + ), + ]); + + $controlManager = new ControlManager(); + $controlManager->setMapTypeControl(new MapTypeControl()); + $controlManager->setRotateControl(new RotateControl()); + $controlManager->setScaleControl(new ScaleControl()); + $controlManager->setStreetViewControl(new StreetViewControl()); + $controlManager->setZoomControl(new ZoomControl()); + + $this->controlManagerRenderer->render($controlManager, $jsonBuilder = new JsonBuilder()); + + $this->assertSame( + '{"mapTypeControl":true,"mapTypeControlOptions":{"mapTypeIds":[google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE],"position":google.maps.ControlPosition.TOP_RIGHT,"style":google.maps.MapTypeControlStyle.DEFAULT},"rotateControl":true,"rotateControlOptions":{"position":google.maps.ControlPosition.TOP_LEFT},"scaleControl":true,"scaleControlOptions":{"position":google.maps.ControlPosition.BOTTOM_LEFT,"style":google.maps.ScaleControlStyle.DEFAULT},"streetViewControl":true,"streetViewControlOptions":{"position":google.maps.ControlPosition.TOP_LEFT},"zoomControl":true,"zoomControlOptions":{"position":google.maps.ControlPosition.TOP_LEFT,"style":google.maps.ZoomControlStyle.DEFAULT}}', + $jsonBuilder->build() + ); + } + + public function testRenderWithoutControls() + { + $this->controlManagerRenderer->render(new ControlManager(), $jsonBuilder = new JsonBuilder()); + + $this->assertSame('[]', $jsonBuilder->build()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ControlRendererInterface + */ + private function createControlRendererMock() + { + return $this->createMock(ControlRendererInterface::class); + } +} diff --git a/tests/Helper/Renderer/Control/ControlPositionRendererTest.php b/tests/Helper/Renderer/Control/ControlPositionRendererTest.php new file mode 100644 index 00000000..134fb8b6 --- /dev/null +++ b/tests/Helper/Renderer/Control/ControlPositionRendererTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ControlPosition; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlPositionRenderer; + +/** + * @author GeLo + */ +class ControlPositionRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ControlPositionRenderer + */ + private $controlPositionRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->controlPositionRenderer = new ControlPositionRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->controlPositionRenderer); + } + + public function testRender() + { + $this->assertSame( + 'google.maps.ControlPosition.TOP_LEFT', + $this->controlPositionRenderer->render(ControlPosition::TOP_LEFT) + ); + } +} diff --git a/tests/Helper/Renderer/Control/MapTypeControlRendererTest.php b/tests/Helper/Renderer/Control/MapTypeControlRendererTest.php new file mode 100644 index 00000000..c98f13d6 --- /dev/null +++ b/tests/Helper/Renderer/Control/MapTypeControlRendererTest.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\MapTypeControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlPositionRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Control\MapTypeControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\MapTypeControlStyleRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapTypeIdRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MapTypeControlRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapTypeControlRenderer + */ + private $mapTypeControlRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapTypeControlRenderer = new MapTypeControlRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new MapTypeIdRenderer($formatter), + new ControlPositionRenderer($formatter), + new MapTypeControlStyleRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->mapTypeControlRenderer); + $this->assertInstanceOf(ControlRendererInterface::class, $this->mapTypeControlRenderer); + } + + public function testMapTypeIdRenderer() + { + $mapTypeIdRenderer = $this->createMapTypeIdRendererMock(); + $this->mapTypeControlRenderer->setMapTypeIdRenderer($mapTypeIdRenderer); + + $this->assertSame($mapTypeIdRenderer, $this->mapTypeControlRenderer->getMapTypeIdRenderer()); + } + + public function testControlPositionRenderer() + { + $controlPositionRenderer = $this->createControlPositionRendererMock(); + $this->mapTypeControlRenderer->setControlPositionRenderer($controlPositionRenderer); + + $this->assertSame($controlPositionRenderer, $this->mapTypeControlRenderer->getControlPositionRenderer()); + } + + public function testMapTypeControlStyleRenderer() + { + $mapTypeControlStyleRenderer = $this->createMapTypeControlStyleRendererMock(); + $this->mapTypeControlRenderer->setMapTypeControlStyleRenderer($mapTypeControlStyleRenderer); + + $this->assertSame( + $mapTypeControlStyleRenderer, + $this->mapTypeControlRenderer->getMapTypeControlStyleRenderer() + ); + } + + public function testRender() + { + $this->assertSame( + '{"mapTypeIds":[google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE],"position":google.maps.ControlPosition.TOP_RIGHT,"style":google.maps.MapTypeControlStyle.DEFAULT}', + $this->mapTypeControlRenderer->render(new MapTypeControl()) + ); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Expected a "Ivory\GoogleMap\Control\MapTypeControl", got "string". + */ + public function testRenderWithInvalidControl() + { + $this->mapTypeControlRenderer->render('foo'); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MapTypeIdRenderer + */ + private function createMapTypeIdRendererMock() + { + return $this->createMock(MapTypeIdRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ControlPositionRenderer + */ + private function createControlPositionRendererMock() + { + return $this->createMock(ControlPositionRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MapTypeControlStyleRenderer + */ + private function createMapTypeControlStyleRendererMock() + { + return $this->createMock(MapTypeControlStyleRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Control/MapTypeControlStyleRendererTest.php b/tests/Helper/Renderer/Control/MapTypeControlStyleRendererTest.php new file mode 100644 index 00000000..f04f5c16 --- /dev/null +++ b/tests/Helper/Renderer/Control/MapTypeControlStyleRendererTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\MapTypeControlStyle; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\MapTypeControlStyleRenderer; + +/** + * @author GeLo + */ +class MapTypeControlStyleRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapTypeControlStyleRenderer + */ + private $mapTypeControlStyleRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapTypeControlStyleRenderer = new MapTypeControlStyleRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->mapTypeControlStyleRenderer); + } + + public function testRender() + { + $this->assertSame( + 'google.maps.MapTypeControlStyle.DROPDOWN_MENU', + $this->mapTypeControlStyleRenderer->render(MapTypeControlStyle::DROPDOWN_MENU) + ); + } +} diff --git a/tests/Helper/Renderer/Control/RotateControlRendererTest.php b/tests/Helper/Renderer/Control/RotateControlRendererTest.php new file mode 100644 index 00000000..0d5dcf36 --- /dev/null +++ b/tests/Helper/Renderer/Control/RotateControlRendererTest.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\RotateControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlPositionRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Control\RotateControlRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class RotateControlRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var RotateControlRenderer + */ + private $rotateControlRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->rotateControlRenderer = new RotateControlRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new ControlPositionRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->rotateControlRenderer); + $this->assertInstanceOf(ControlRendererInterface::class, $this->rotateControlRenderer); + } + + public function testControlPositionRenderer() + { + $controlPositionRenderer = $this->createControlPositionRendererMock(); + $this->rotateControlRenderer->setControlPositionRenderer($controlPositionRenderer); + + $this->assertSame($controlPositionRenderer, $this->rotateControlRenderer->getControlPositionRenderer()); + } + + public function testRender() + { + $this->assertSame( + '{"position":google.maps.ControlPosition.TOP_LEFT}', + $this->rotateControlRenderer->render(new RotateControl()) + ); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Expected a "Ivory\GoogleMap\Control\RotateControl", got "string". + */ + public function testRenderWithInvalidControl() + { + $this->rotateControlRenderer->render('foo'); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ControlPositionRenderer + */ + private function createControlPositionRendererMock() + { + return $this->createMock(ControlPositionRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Control/ScaleControlRendererTest.php b/tests/Helper/Renderer/Control/ScaleControlRendererTest.php new file mode 100644 index 00000000..8a595dbc --- /dev/null +++ b/tests/Helper/Renderer/Control/ScaleControlRendererTest.php @@ -0,0 +1,100 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ScaleControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlPositionRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Control\ScaleControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ScaleControlStyleRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class ScaleControlRendererTest extends\PHPUnit_Framework_TestCase +{ + /** + * @var ScaleControlRenderer + */ + private $scaleControlRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->scaleControlRenderer = new ScaleControlRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new ControlPositionRenderer($formatter), + new ScaleControlStyleRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->scaleControlRenderer); + $this->assertInstanceOf(ControlRendererInterface::class, $this->scaleControlRenderer); + } + + public function testControlPositionRenderer() + { + $controlPositionRenderer = $this->createControlPositionRendererMock(); + $this->scaleControlRenderer->setControlPositionRenderer($controlPositionRenderer); + + $this->assertSame($controlPositionRenderer, $this->scaleControlRenderer->getControlPositionRenderer()); + } + + public function testScaleControlStyleRenderer() + { + $scaleControlStyleRenderer = $this->createScaleControlStyleRendererMock(); + $this->scaleControlRenderer->setScaleControlStyleRenderer($scaleControlStyleRenderer); + + $this->assertSame($scaleControlStyleRenderer, $this->scaleControlRenderer->getScaleControlStyleRenderer()); + } + + public function testRender() + { + $this->assertSame( + '{"position":google.maps.ControlPosition.BOTTOM_LEFT,"style":google.maps.ScaleControlStyle.DEFAULT}', + $this->scaleControlRenderer->render(new ScaleControl()) + ); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Expected a "Ivory\GoogleMap\Control\ScaleControl", got "string". + */ + public function testRenderWithInvalidControl() + { + $this->scaleControlRenderer->render('foo'); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ControlPositionRenderer + */ + private function createControlPositionRendererMock() + { + return $this->createMock(ControlPositionRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ScaleControlStyleRenderer + */ + private function createScaleControlStyleRendererMock() + { + return $this->createMock(ScaleControlStyleRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Control/ScaleControlStyleRendererTest.php b/tests/Helper/Renderer/Control/ScaleControlStyleRendererTest.php new file mode 100644 index 00000000..50206ed0 --- /dev/null +++ b/tests/Helper/Renderer/Control/ScaleControlStyleRendererTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ScaleControlStyle; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ScaleControlStyleRenderer; + +/** + * @author GeLo + */ +class ScaleControlStyleRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ScaleControlStyleRenderer + */ + private $scaleControlStyleRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->scaleControlStyleRenderer = new ScaleControlStyleRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->scaleControlStyleRenderer); + } + + public function testRender() + { + $this->assertSame( + 'google.maps.ScaleControlStyle.DEFAULT', + $this->scaleControlStyleRenderer->render(ScaleControlStyle::DEFAULT_) + ); + } +} diff --git a/tests/Helper/Renderer/Control/StreetViewControlRendererTest.php b/tests/Helper/Renderer/Control/StreetViewControlRendererTest.php new file mode 100644 index 00000000..d9303876 --- /dev/null +++ b/tests/Helper/Renderer/Control/StreetViewControlRendererTest.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\StreetViewControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlPositionRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Control\StreetViewControlRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class StreetViewControlRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var StreetViewControlRenderer + */ + private $streetViewControlRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->streetViewControlRenderer = new StreetViewControlRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new ControlPositionRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->streetViewControlRenderer); + $this->assertInstanceOf(ControlRendererInterface::class, $this->streetViewControlRenderer); + } + + public function testControlPositionRenderer() + { + $controlPositionRenderer = $this->createControlPositionRendererMock(); + $this->streetViewControlRenderer->setControlPositionRenderer($controlPositionRenderer); + + $this->assertSame($controlPositionRenderer, $this->streetViewControlRenderer->getControlPositionRenderer()); + } + + public function testRender() + { + $this->assertSame( + '{"position":google.maps.ControlPosition.TOP_LEFT}', + $this->streetViewControlRenderer->render(new StreetViewControl()) + ); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Expected a "Ivory\GoogleMap\Control\StreetViewControl", got "string". + */ + public function testRenderWithInvalidControl() + { + $this->streetViewControlRenderer->render('foo'); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ControlPositionRenderer + */ + private function createControlPositionRendererMock() + { + return $this->createMock(ControlPositionRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Control/ZoomControlRendererTest.php b/tests/Helper/Renderer/Control/ZoomControlRendererTest.php new file mode 100644 index 00000000..8bb09e7c --- /dev/null +++ b/tests/Helper/Renderer/Control/ZoomControlRendererTest.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ZoomControl; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlPositionRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Control\ZoomControlRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ZoomControlStyleRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class ZoomControlRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ZoomControlRenderer + */ + private $zoomControlRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->zoomControlRenderer = new ZoomControlRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new ControlPositionRenderer($formatter), + new ZoomControlStyleRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->zoomControlRenderer); + $this->assertInstanceOf(ControlRendererInterface::class, $this->zoomControlRenderer); + } + + public function testControlPositionRenderer() + { + $controlPositionRenderer = $this->createControlPositionRendererMock(); + $this->zoomControlRenderer->setControlPositionRenderer($controlPositionRenderer); + + $this->assertSame($controlPositionRenderer, $this->zoomControlRenderer->getControlPositionRenderer()); + } + + public function testZoomControlStyleRenderer() + { + $zoomControlStyleRenderer = $this->createZoomControlStyleRendererMock(); + $this->zoomControlRenderer->setZoomControlStyleRenderer($zoomControlStyleRenderer); + + $this->assertSame($zoomControlStyleRenderer, $this->zoomControlRenderer->getZoomControlStyleRenderer()); + } + + public function testRender() + { + $this->assertSame( + '{"position":google.maps.ControlPosition.TOP_LEFT,"style":google.maps.ZoomControlStyle.DEFAULT}', + $this->zoomControlRenderer->render(new ZoomControl()) + ); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Expected a "Ivory\GoogleMap\Control\ZoomControl", got "string". + */ + public function testRenderWithInvalidControl() + { + $this->zoomControlRenderer->render('foo'); + } + + private function createControlPositionRendererMock() + { + return $this->createMock(ControlPositionRenderer::class); + } + + private function createZoomControlStyleRendererMock() + { + return $this->createMock(ZoomControlStyleRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Control/ZoomControlStyleRendererTest.php b/tests/Helper/Renderer/Control/ZoomControlStyleRendererTest.php new file mode 100644 index 00000000..56e0e887 --- /dev/null +++ b/tests/Helper/Renderer/Control/ZoomControlStyleRendererTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Control; + +use Ivory\GoogleMap\Control\ZoomControlStyle; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Control\ZoomControlStyleRenderer; + +/** + * @author GeLo + */ +class ZoomControlStyleRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ZoomControlStyleRenderer + */ + private $zoomControlStyleRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->zoomControlStyleRenderer = new ZoomControlStyleRenderer(new Formatter()); + } + + public function testRender() + { + $this->assertSame( + 'google.maps.ZoomControlStyle.LARGE', + $this->zoomControlStyleRenderer->render(ZoomControlStyle::LARGE) + ); + } +} diff --git a/tests/Helper/Renderer/Event/AbstractEventRendererTest.php b/tests/Helper/Renderer/Event/AbstractEventRendererTest.php new file mode 100644 index 00000000..433eecd1 --- /dev/null +++ b/tests/Helper/Renderer/Event/AbstractEventRendererTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\AbstractEventRenderer; + +/** + * @author GeLo + */ +class AbstractEventRendererTest extends\PHPUnit_Framework_TestCase +{ + /** + * @var AbstractEventRenderer|\\PHPUnit_Framework_MockObject_MockObject + */ + private $eventRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->eventRenderer = $this->createAbstractEventRendererMock(); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->eventRenderer); + } + + public function testRender() + { + $event = new Event('instance', 'trigger', 'handle'); + $event->setVariable('event'); + + $this->assertSame( + 'event=google.maps.event.method(instance,"trigger",handle,false)', + $this->eventRenderer->render($event) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|AbstractEventRenderer + */ + private function createAbstractEventRendererMock() + { + $eventRenderer = $this->getMockBuilder(AbstractEventRenderer::class) + ->setConstructorArgs([new Formatter()]) + ->getMockForAbstractClass(); + + $eventRenderer + ->expects($this->any()) + ->method('getMethod') + ->will($this->returnValue('method')); + + return $eventRenderer; + } +} diff --git a/tests/Helper/Renderer/Event/DomEventOnceRendererTest.php b/tests/Helper/Renderer/Event/DomEventOnceRendererTest.php new file mode 100644 index 00000000..92e4014b --- /dev/null +++ b/tests/Helper/Renderer/Event/DomEventOnceRendererTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\AbstractEventRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\DomEventOnceRenderer; + +/** + * @author GeLo + */ +class DomEventOnceRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DomEventOnceRenderer + */ + private $domEventOnceRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->domEventOnceRenderer = new DomEventOnceRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractEventRenderer::class, $this->domEventOnceRenderer); + } + + public function testRender() + { + $event = new Event('instance', 'trigger', 'handle'); + $event->setVariable('event'); + + $this->assertSame( + 'event=google.maps.event.addDomListenerOnce(instance,"trigger",handle,false)', + $this->domEventOnceRenderer->render($event) + ); + } +} diff --git a/tests/Helper/Renderer/Event/DomEventRendererTest.php b/tests/Helper/Renderer/Event/DomEventRendererTest.php new file mode 100644 index 00000000..bcaddb0d --- /dev/null +++ b/tests/Helper/Renderer/Event/DomEventRendererTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\AbstractEventRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\DomEventRenderer; + +/** + * @author GeLo + */ +class DomEventRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DomEventRenderer + */ + private $domEventRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->domEventRenderer = new DomEventRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractEventRenderer::class, $this->domEventRenderer); + } + + public function testRender() + { + $event = new Event('instance', 'trigger', 'handle'); + $event->setVariable('event'); + + $this->assertSame( + 'event=google.maps.event.addDomListener(instance,"trigger",handle,false)', + $this->domEventRenderer->render($event) + ); + } +} diff --git a/tests/Helper/Renderer/Event/EventOnceRendererTest.php b/tests/Helper/Renderer/Event/EventOnceRendererTest.php new file mode 100644 index 00000000..9ed9e4ea --- /dev/null +++ b/tests/Helper/Renderer/Event/EventOnceRendererTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\AbstractEventRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\EventOnceRenderer; + +/** + * @author GeLo + */ +class EventOnceRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EventOnceRenderer + */ + private $domEventOnceRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->domEventOnceRenderer = new EventOnceRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractEventRenderer::class, $this->domEventOnceRenderer); + } + + public function testRender() + { + $event = new Event('instance', 'trigger', 'handle'); + $event->setVariable('event'); + + $this->assertSame( + 'event=google.maps.event.addListenerOnce(instance,"trigger",handle)', + $this->domEventOnceRenderer->render($event) + ); + } +} diff --git a/tests/Helper/Renderer/Event/EventRendererTest.php b/tests/Helper/Renderer/Event/EventRendererTest.php new file mode 100644 index 00000000..5aba00f6 --- /dev/null +++ b/tests/Helper/Renderer/Event/EventRendererTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Event; + +use Ivory\GoogleMap\Event\Event; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Event\AbstractEventRenderer; +use Ivory\GoogleMap\Helper\Renderer\Event\EventRenderer; + +/** + * @author GeLo + */ +class EventRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EventRenderer + */ + private $domEventRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->domEventRenderer = new EventRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractEventRenderer::class, $this->domEventRenderer); + } + + public function testRender() + { + $event = new Event('instance', 'trigger', 'handle'); + $event->setVariable('event'); + + $this->assertSame( + 'event=google.maps.event.addListener(instance,"trigger",handle)', + $this->domEventRenderer->render($event) + ); + } +} diff --git a/tests/Helper/Renderer/Geometry/EncodingRendererTest.php b/tests/Helper/Renderer/Geometry/EncodingRendererTest.php new file mode 100644 index 00000000..2b4fd9f6 --- /dev/null +++ b/tests/Helper/Renderer/Geometry/EncodingRendererTest.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Geometry; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Geometry\EncodingRenderer; + +/** + * @author GeLo + */ +class EncodingRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EncodingRenderer + */ + private $encodingRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->encodingRenderer = new EncodingRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->encodingRenderer); + } + + /** + * @param string $expected + * @param string $encodedPath + * + * @dataProvider renderProvider + */ + public function testRender($expected, $encodedPath) + { + $this->assertSame( + 'google.maps.geometry.encoding.decodePath("'.$expected.'")', + $this->encodingRenderer->renderDecodePath($encodedPath) + ); + } + + /** + * @return string[][] + */ + public function renderProvider() + { + return [ + ['foo', 'foo'], + ['\\\\\"', '"'], + ['\\\\\'', '\''], + ['\\\\\\\\', '\\'], + ]; + } +} diff --git a/tests/Helper/Renderer/Html/AbstractTagRendererTest.php b/tests/Helper/Renderer/Html/AbstractTagRendererTest.php new file mode 100644 index 00000000..05dbc193 --- /dev/null +++ b/tests/Helper/Renderer/Html/AbstractTagRendererTest.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\AbstractTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; + +/** + * @author GeLo + */ +class AbstractTagRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AbstractTagRenderer|\PHPUnit_Framework_MockObject_MockObject + */ + private $tagRenderer; + + /** + * @var TagRenderer|\PHPUnit_Framework_MockObject_MockObject + */ + private $innerTagRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->innerTagRenderer = $this->createTagRendererMock(); + $this->tagRenderer = $this->createAbstractTagRendererMock($this->innerTagRenderer); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->tagRenderer); + } + + public function testDefaultState() + { + $this->assertSame($this->innerTagRenderer, $this->tagRenderer->getTagRenderer()); + } + + public function testTagRenderer() + { + $this->tagRenderer->setTagRenderer($tagRenderer = $this->createTagRendererMock()); + + $this->assertSame($tagRenderer, $this->tagRenderer->getTagRenderer()); + } + + /** + * @param TagRenderer|null $tagRenderer + * + * @return \PHPUnit_Framework_MockObject_MockObject|AbstractTagRenderer + */ + private function createAbstractTagRendererMock(TagRenderer $tagRenderer = null) + { + return $this->getMockBuilder(AbstractTagRenderer::class) + ->setConstructorArgs([$this->createFormatterMock(), $tagRenderer ?: $this->createTagRendererMock()]) + ->getMockForAbstractClass(); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Formatter + */ + private function createFormatterMock() + { + return $this->createMock(Formatter::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|TagRenderer + */ + private function createTagRendererMock() + { + return $this->createMock(TagRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Html/JavascriptTagRendererTest.php b/tests/Helper/Renderer/Html/JavascriptTagRendererTest.php new file mode 100644 index 00000000..593a4b75 --- /dev/null +++ b/tests/Helper/Renderer/Html/JavascriptTagRendererTest.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Html\AbstractTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\JavascriptTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; + +/** + * @author GeLo + */ +class JavascriptTagRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var JavascriptTagRenderer + */ + private $javascriptTagRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->javascriptTagRenderer = new JavascriptTagRenderer( + $formatter = new Formatter(), + new TagRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractTagRenderer::class, $this->javascriptTagRenderer); + } + + /** + * @param string $expected + * @param string|null $code + * @param string[] $attributes + * @param bool $newLine + * @param bool $debug + * + * @dataProvider renderProvider + */ + public function testRender($expected, $code = null, array $attributes = [], $newLine = true, $debug = false) + { + $this->javascriptTagRenderer->getFormatter()->setDebug($debug); + + $this->assertSame($expected, $this->javascriptTagRenderer->render($code, $attributes, $newLine)); + } + + /** + * @return mixed[][] + */ + public function renderProvider() + { + return [ + // Debug disabled + [''], + ['', 'code'], + ['', null, ['foo' => 'bar']], + ['', null, [], false], + ['', 'code', ['foo' => 'bar'], false], + + // Debug enabled + [''.PHP_EOL, null, [], true, true], + [''.PHP_EOL, 'code', [], true, true], + [''.PHP_EOL, null, ['foo' => 'bar'], true, true], + ['', null, [], false, true], + ['', 'code', ['foo' => 'bar'], false, true], + ]; + } +} diff --git a/tests/Helper/Renderer/Html/StylesheetRendererTest.php b/tests/Helper/Renderer/Html/StylesheetRendererTest.php new file mode 100644 index 00000000..95daa9ac --- /dev/null +++ b/tests/Helper/Renderer/Html/StylesheetRendererTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\StylesheetRenderer; + +/** + * @author GeLo + */ +class StylesheetRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var StylesheetRenderer + */ + private $stylesheetRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->stylesheetRenderer = new StylesheetRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->stylesheetRenderer); + } + + public function testRender() + { + $this->assertSame('stylesheet:value;', $this->stylesheetRenderer->render('stylesheet', 'value')); + } + + public function testRenderWithDebug() + { + $this->stylesheetRenderer->getFormatter()->setDebug(true); + + $this->assertSame('stylesheet: value;', $this->stylesheetRenderer->render('stylesheet', 'value')); + } +} diff --git a/tests/Helper/Renderer/Html/StylesheetTagRendererTest.php b/tests/Helper/Renderer/Html/StylesheetTagRendererTest.php new file mode 100644 index 00000000..17cec117 --- /dev/null +++ b/tests/Helper/Renderer/Html/StylesheetTagRendererTest.php @@ -0,0 +1,107 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Html\AbstractTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\StylesheetRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\StylesheetTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; + +/** + * @author GeLo + */ +class StylesheetTagRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var StylesheetTagRenderer + */ + private $stylesheetTagRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->stylesheetTagRenderer = new StylesheetTagRenderer( + $formatter = new Formatter(), + new TagRenderer($formatter), + new StylesheetRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractTagRenderer::class, $this->stylesheetTagRenderer); + } + + public function testStylesheetRenderer() + { + $stylesheetRenderer = $this->createStylesheetRendererMock(); + $this->stylesheetTagRenderer->setStylesheetRenderer($stylesheetRenderer); + + $this->assertSame($stylesheetRenderer, $this->stylesheetTagRenderer->getStylesheetRenderer()); + } + + /** + * @param string $expected + * @param string $name + * @param string[] $stylesheets + * @param string[] $attributes + * @param bool $newLine + * @param bool $debug + * + * @dataProvider renderProvider + */ + public function testRender( + $expected, + $name, + array $stylesheets = [], + array $attributes = [], + $newLine = true, + $debug = false + ) { + $this->stylesheetTagRenderer->getFormatter()->setDebug($debug); + + $this->assertSame($expected, $this->stylesheetTagRenderer->render($name, $stylesheets, $attributes, $newLine)); + } + + /** + * @return mixed[][] + */ + public function renderProvider() + { + return [ + // Debug disabled + ['', 'name'], + ['', 'name', ['foo' => 'bar']], + ['', 'name', [], ['foo' => 'bar']], + ['', 'name', [], [], false], + ['', 'name', ['foo' => 'bar'], ['baz' => 'bat'], false], + + // Debug enabled + [''.PHP_EOL, 'name', [], [], true, true], + [''.PHP_EOL, 'name', ['foo' => 'bar'], [], true, true], + [''.PHP_EOL, 'name', [], ['foo' => 'bar'], true, true], + ['', 'name', [], [], false, true], + ['', 'name', ['foo' => 'bar'], ['baz' => 'bat'], false, true], + ]; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|StylesheetRenderer + */ + private function createStylesheetRendererMock() + { + return $this->createMock(StylesheetRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Html/TagRendererTest.php b/tests/Helper/Renderer/Html/TagRendererTest.php new file mode 100644 index 00000000..eec9e8d2 --- /dev/null +++ b/tests/Helper/Renderer/Html/TagRendererTest.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Html; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; + +/** + * @author GeLo + */ +class TagRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var TagRenderer + */ + private $tagRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->tagRenderer = new TagRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->tagRenderer); + } + + /** + * @param string $expected + * @param string $name + * @param string|null $code + * @param string[] $attributes + * @param bool $newLine + * @param bool $debug + * + * @dataProvider renderProvider + */ + public function testRender( + $expected, + $name, + $code = null, + array $attributes = [], + $newLine = false, + $debug = false + ) { + $this->tagRenderer->getFormatter()->setDebug($debug); + + $this->assertSame($expected, $this->tagRenderer->render($name, $code, $attributes, $newLine)); + } + + /** + * @return mixed[][] + */ + public function renderProvider() + { + return [ + // Debug disabled + ['', 'tag'], + ['code', 'tag', 'code'], + ['', 'tag', null, ['foo' => 'bar']], + ['', 'tag', null, [], false], + ['code', 'tag', 'code', ['foo' => 'bar'], true], + + // Debug enabled + [''.PHP_EOL, 'tag', null, [], true, true], + [''.PHP_EOL.' code'.PHP_EOL.''.PHP_EOL, 'tag', 'code', [], true, true], + [''.PHP_EOL, 'tag', null, ['foo' => 'bar'], true, true], + ['', 'tag', null, [], false, true], + [''.PHP_EOL.' code'.PHP_EOL.'', 'tag', 'code', ['foo' => 'bar'], false, true], + ]; + } +} diff --git a/tests/Helper/Renderer/JsonRendererTest.php b/tests/Helper/Renderer/JsonRendererTest.php new file mode 100644 index 00000000..966b6bcc --- /dev/null +++ b/tests/Helper/Renderer/JsonRendererTest.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class JsonRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AbstractJsonRenderer|\PHPUnit_Framework_MockObject_MockObject + */ + private $jsonRenderer; + + /** + * @var JsonBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $jsonBuilder; + + /** + * @var Formatter|\PHPUnit_Framework_MockObject_MockObject + */ + private $formatter; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->formatter = $this->createFormatterMock(); + $this->jsonBuilder = $this->createJsonBuilderMock(); + + $this->jsonRenderer = $this->createAbstractJsonRendererMock($this->formatter, $this->jsonBuilder); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->jsonRenderer); + } + + public function testDefaultState() + { + $this->assertSame($this->formatter, $this->jsonRenderer->getFormatter()); + $this->assertNotSame($this->jsonBuilder, $this->jsonRenderer->getJsonBuilder()); + $this->assertInstanceOf(JsonBuilder::class, $this->jsonRenderer->getJsonBuilder()); + } + + public function testJsonBuilder() + { + $this->jsonRenderer->setJsonBuilder($jsonBuilder = $this->createJsonBuilderMock()); + + $this->assertNotSame($jsonBuilder, $this->jsonRenderer->getJsonBuilder()); + $this->assertInstanceOf(JsonBuilder::class, $this->jsonRenderer->getJsonBuilder()); + } + + /** + * @param Formatter|null $formatter + * @param JsonBuilder|null $jsonBuilder + * + * @return \PHPUnit_Framework_MockObject_MockObject|AbstractJsonRenderer + */ + private function createAbstractJsonRendererMock(Formatter $formatter = null, JsonBuilder $jsonBuilder = null) + { + return $this->getMockBuilder(AbstractJsonRenderer::class) + ->setConstructorArgs([ + $formatter ?: $this->createFormatterMock(), + $jsonBuilder ?: $this->createJsonBuilderMock(), + ]) + ->getMockForAbstractClass(); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Formatter + */ + private function createFormatterMock() + { + return $this->createMock(Formatter::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|JsonBuilder + */ + private function createJsonBuilderMock() + { + $jsonBuilder = $this->createMock(JsonBuilder::class); + $jsonBuilder + ->expects($this->any()) + ->method('reset') + ->will($this->returnSelf()); + + $jsonBuilder + ->expects($this->any()) + ->method('setJsonEncodeOptions') + ->will($this->returnSelf()); + + return $jsonBuilder; + } +} diff --git a/tests/Helper/Renderer/Layer/KmlLayerRendererTest.php b/tests/Helper/Renderer/Layer/KmlLayerRendererTest.php new file mode 100644 index 00000000..f9aee465 --- /dev/null +++ b/tests/Helper/Renderer/Layer/KmlLayerRendererTest.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Layer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Layer\KmlLayerRenderer; +use Ivory\GoogleMap\Layer\KmlLayer; +use Ivory\GoogleMap\Map; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class KmlLayerRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var KmlLayerRenderer + */ + private $kmlLayerRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->kmlLayerRenderer = new KmlLayerRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->kmlLayerRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $kmlLayer = new KmlLayer('url', ['foo' => 'bar']); + $kmlLayer->setVariable('kml_layer'); + + $this->assertSame( + 'kml_layer=new google.maps.KmlLayer("url",{"map":map,"foo":"bar"})', + $this->kmlLayerRenderer->render($kmlLayer, $map) + ); + } +} diff --git a/tests/Helper/Renderer/LoaderRendererTest.php b/tests/Helper/Renderer/LoaderRendererTest.php new file mode 100644 index 00000000..2c1a59ec --- /dev/null +++ b/tests/Helper/Renderer/LoaderRendererTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\LoaderRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class LoaderRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var LoaderRenderer + */ + private $loaderRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->loaderRenderer = new LoaderRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->loaderRenderer); + } + + public function testRender() + { + $this->assertSame( + 'function name(){google.load("maps","3",{"other_params":"language=en&libraries=library1,library2","callback":callback})};', + $this->loaderRenderer->render( + 'name', + 'callback', + 'en', + ['library1', 'library2'] + ) + ); + } + + public function testRenderWithDebug() + { + $this->loaderRenderer->getFormatter()->setDebug(true); + + $expected = <<assertSame($expected, $this->loaderRenderer->render( + 'name', + 'callback', + 'en', + ['library1', 'library2'] + )); + } + + public function testRenderSource() + { + $this->assertSame( + 'https://www.google.com/jsapi?callback=callback', + $this->loaderRenderer->renderSource('callback') + ); + } +} diff --git a/tests/Helper/Renderer/MapBoundRendererTest.php b/tests/Helper/Renderer/MapBoundRendererTest.php new file mode 100644 index 00000000..1b8fa505 --- /dev/null +++ b/tests/Helper/Renderer/MapBoundRendererTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapBoundRenderer; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class MapBoundRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapBoundRenderer + */ + private $mapBoundRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapBoundRenderer = new MapBoundRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->mapBoundRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + $map->getBound()->setVariable('bound'); + + $this->assertSame('map.fitBounds(bound)', $this->mapBoundRenderer->render($map)); + } +} diff --git a/tests/Helper/Renderer/MapCenterRendererTest.php b/tests/Helper/Renderer/MapCenterRendererTest.php new file mode 100644 index 00000000..1883db4a --- /dev/null +++ b/tests/Helper/Renderer/MapCenterRendererTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapCenterRenderer; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class MapCenterRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapCenterRenderer + */ + private $mapCenterRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapCenterRenderer = new MapCenterRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->mapCenterRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + $map->getCenter()->setVariable('center'); + + $this->assertSame('map.setCenter(center)', $this->mapCenterRenderer->render($map)); + } +} diff --git a/tests/Helper/Renderer/MapContainerRendererTest.php b/tests/Helper/Renderer/MapContainerRendererTest.php new file mode 100644 index 00000000..c3cb59c6 --- /dev/null +++ b/tests/Helper/Renderer/MapContainerRendererTest.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapContainerRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MapContainerRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapContainerRenderer + */ + private $mapContainerRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapContainerRenderer = new MapContainerRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->mapContainerRenderer); + } + + public function testRender() + { + $this->assertSame( + '{"base":{"coordinates":[],"bounds":[],"points":[],"sizes":[]},"map":null,"overlays":{"circles":[],"encoded_polylines":[],"ground_overlays":[],"polygons":[],"polylines":[],"rectangles":[],"info_windows":[],"info_boxes":[],"marker_images":[],"markers":[],"marker_cluster":null},"layers":{"kml_layers":[]},"events":{"dom_events":[],"dom_events_once":[],"events":[],"events_once":[]},"functions":[]}', + $this->mapContainerRenderer->render() + ); + } + + public function testRenderWithDebug() + { + $this->mapContainerRenderer->getFormatter()->setDebug(true); + + $expected = <<assertSame($expected, $this->mapContainerRenderer->render()); + } +} diff --git a/tests/Helper/Renderer/MapHtmlRendererTest.php b/tests/Helper/Renderer/MapHtmlRendererTest.php new file mode 100644 index 00000000..7fe0911a --- /dev/null +++ b/tests/Helper/Renderer/MapHtmlRendererTest.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Html\AbstractTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\StylesheetRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapHtmlRenderer; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class MapHtmlRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapHtmlRenderer + */ + private $mapHtmlRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapHtmlRenderer = new MapHtmlRenderer( + $formatter = new Formatter(), + new TagRenderer($formatter), + new StylesheetRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractTagRenderer::class, $this->mapHtmlRenderer); + } + + public function testStylesheetRenderer() + { + $this->mapHtmlRenderer->setStylesheetRenderer($stylesheetRenderer = $this->createStylesheetRendererMock()); + + $this->assertSame($stylesheetRenderer, $this->mapHtmlRenderer->getStylesheetRenderer()); + } + + public function testRender() + { + $this->assertSame( + '

', + $this->mapHtmlRenderer->render(new Map()) + ); + } + + public function testRenderWithSIzes() + { + $map = new Map(); + $map->setStylesheetOption('width', '100px'); + $map->setStylesheetOption('height', '200px'); + + $this->assertSame( + '
', + $this->mapHtmlRenderer->render($map) + ); + } + + public function testRenderWithDebug() + { + $this->mapHtmlRenderer->getFormatter()->setDebug(true); + + $this->assertSame( + '
'.PHP_EOL, + $this->mapHtmlRenderer->render(new Map()) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|StylesheetRenderer + */ + private function createStylesheetRendererMock() + { + return $this->createMock(StylesheetRenderer::class); + } +} diff --git a/tests/Helper/Renderer/MapRendererTest.php b/tests/Helper/Renderer/MapRendererTest.php new file mode 100644 index 00000000..9b29124b --- /dev/null +++ b/tests/Helper/Renderer/MapRendererTest.php @@ -0,0 +1,151 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Control\ControlManagerRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapRenderer; +use Ivory\GoogleMap\Helper\Renderer\MapTypeIdRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\MapTypeId; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MapRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapRenderer + */ + private $mapRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapRenderer = new MapRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new MapTypeIdRenderer($formatter), + new ControlManagerRenderer(), + new RequirementRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->mapRenderer); + } + + public function testMapTypeIdRenderer() + { + $this->mapRenderer->setMapTypeIdRenderer($mapTypeIdRenderer = $this->createMapTypeIdRendererMock()); + + $this->assertSame($mapTypeIdRenderer, $this->mapRenderer->getMapTypeIdRenderer()); + } + + public function testControlManagerRenderer() + { + $controlManagerRenderer = $this->createControlManagerRendererMock(); + $this->mapRenderer->setControlManagerRenderer($controlManagerRenderer); + + $this->assertSame($controlManagerRenderer, $this->mapRenderer->getControlManagerRenderer()); + } + + public function testRequirementRenderer() + { + $this->mapRenderer->setRequirementRenderer($requirementRenderer = $this->createRequirementRendererMock()); + + $this->assertSame($requirementRenderer, $this->mapRenderer->getRequirementRenderer()); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + $map->setMapOptions(['foo' => 'bar']); + + $this->assertSame( + 'map=new google.maps.Map(document.getElementById("map_canvas"),{"mapTypeId":google.maps.MapTypeId.ROADMAP,"foo":"bar","zoom":3})', + $this->mapRenderer->render($map) + ); + } + + public function testRenderWithAutoZoom() + { + $map = new Map(); + $map->setVariable('map'); + $map->setAutoZoom(true); + + $this->assertSame( + 'map=new google.maps.Map(document.getElementById("map_canvas"),{"mapTypeId":google.maps.MapTypeId.ROADMAP})', + $this->mapRenderer->render($map) + ); + } + + public function testRenderWithExplicitZoom() + { + $map = new Map(); + $map->setVariable('map'); + $map->setMapOption('zoom', 5); + + $this->assertSame( + 'map=new google.maps.Map(document.getElementById("map_canvas"),{"mapTypeId":google.maps.MapTypeId.ROADMAP,"zoom":5})', + $this->mapRenderer->render($map) + ); + } + + public function testRenderWithExplicitMapTypeId() + { + $map = new Map(); + $map->setVariable('map'); + $map->setMapOption('mapTypeId', MapTypeId::HYBRID); + + $this->assertSame( + 'map=new google.maps.Map(document.getElementById("map_canvas"),{"mapTypeId":google.maps.MapTypeId.HYBRID,"zoom":3})', + $this->mapRenderer->render($map) + ); + } + + public function testRenderRequirement() + { + $this->assertSame('typeof google.maps!==typeof undefined', $this->mapRenderer->renderRequirement()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MapTypeIdRenderer + */ + private function createMapTypeIdRendererMock() + { + return $this->createMock(MapTypeIdRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ControlManagerRenderer + */ + private function createControlManagerRendererMock() + { + return $this->createMock(ControlManagerRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RequirementRenderer + */ + private function createRequirementRendererMock() + { + return $this->createMock(RequirementRenderer::class); + } +} diff --git a/tests/Helper/Renderer/MapTypeIdRendererTest.php b/tests/Helper/Renderer/MapTypeIdRendererTest.php new file mode 100644 index 00000000..3b99c648 --- /dev/null +++ b/tests/Helper/Renderer/MapTypeIdRendererTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\MapTypeIdRenderer; +use Ivory\GoogleMap\MapTypeId; + +/** + * @author GeLo + */ +class MapTypeIdRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MapTypeIdRenderer + */ + private $mapTypeIdRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->mapTypeIdRenderer = new MapTypeIdRenderer(new Formatter()); + } + + public function testRender() + { + $this->assertSame('google.maps.MapTypeId.HYBRID', $this->mapTypeIdRenderer->render(MapTypeId::HYBRID)); + } +} diff --git a/tests/Helper/Renderer/Overlay/AnimationRendererTest.php b/tests/Helper/Renderer/Overlay/AnimationRendererTest.php new file mode 100644 index 00000000..b2dc8926 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/AnimationRendererTest.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\AnimationRenderer; +use Ivory\GoogleMap\Overlay\Animation; + +/** + * @author GeLo + */ +class AnimationRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AnimationRenderer + */ + private $animationRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->animationRenderer = new AnimationRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->animationRenderer); + } + + public function testRender() + { + $this->assertSame('google.maps.Animation.DROP', $this->animationRenderer->render(Animation::DROP)); + } +} diff --git a/tests/Helper/Renderer/Overlay/CircleRendererTest.php b/tests/Helper/Renderer/Overlay/CircleRendererTest.php new file mode 100644 index 00000000..fb81a160 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/CircleRendererTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\CircleRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Circle; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class CircleRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CircleRenderer + */ + private $circleRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->circleRenderer = new CircleRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->circleRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $center = new Coordinate(); + $center->setVariable('center'); + + $circle = new Circle($center, 1.2, ['foo' => 'bar']); + $circle->setVariable('circle'); + + $this->assertSame( + 'circle=new google.maps.Circle({"map":map,"center":center,"radius":1.2,"foo":"bar"})', + $this->circleRenderer->render($circle, $map) + ); + } +} diff --git a/tests/Helper/Renderer/Overlay/DefaultInfoWindowRendererTest.php b/tests/Helper/Renderer/Overlay/DefaultInfoWindowRendererTest.php new file mode 100644 index 00000000..81f53185 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/DefaultInfoWindowRendererTest.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\AbstractInfoWindowRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\DefaultInfoWindowRenderer; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class DefaultInfoWindowRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DefaultInfoWindowRenderer|\PHPUnit_Framework_MockObject_MockObject + */ + private $defaultInfoWindowRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->defaultInfoWindowRenderer = new DefaultInfoWindowRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractInfoWindowRenderer::class, $this->defaultInfoWindowRenderer); + } + + public function testRender() + { + $position = new Coordinate(); + $position->setVariable('position'); + + $pixelOffset = new Size(); + $pixelOffset->setVariable('pixel_offset'); + + $infoWindow = new InfoWindow('content', InfoWindowType::DEFAULT_, $position); + $infoWindow->setVariable('info_window'); + $infoWindow->setPixelOffset($pixelOffset); + $infoWindow->setOptions(['foo' => 'bar']); + + $this->assertSame( + 'info_window=new google.maps.InfoWindow({"position":position,"pixelOffset":pixel_offset,"content":"content","foo":"bar"})', + $this->defaultInfoWindowRenderer->render($infoWindow) + ); + } + + public function testRenderWithoutPosition() + { + $infoWindow = new InfoWindow('content'); + $infoWindow->setVariable('info_window'); + + $this->assertSame( + 'info_window=new google.maps.InfoWindow({"content":"content"})', + $this->defaultInfoWindowRenderer->render($infoWindow, false) + ); + } +} diff --git a/tests/Helper/Renderer/Overlay/EncodedPolylineRendererTest.php b/tests/Helper/Renderer/Overlay/EncodedPolylineRendererTest.php new file mode 100644 index 00000000..cf0815e6 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/EncodedPolylineRendererTest.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Geometry\EncodingRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\EncodedPolylineRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class EncodedPolylineRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EncodedPolylineRenderer + */ + private $encodedPolylineRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->encodedPolylineRenderer = new EncodedPolylineRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new EncodingRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->encodedPolylineRenderer); + } + + public function testEncodingRenderer() + { + $this->encodedPolylineRenderer->setEncodingRenderer($encodingRenderer = $this->createEncodingRendererMock()); + + $this->assertSame($encodingRenderer, $this->encodedPolylineRenderer->getEncodingRenderer()); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $encodedPolyline = new EncodedPolyline('value', ['foo' => 'bar']); + $encodedPolyline->setVariable('encoded_polyline'); + + $this->assertSame( + 'encoded_polyline=new google.maps.Polyline({"map":map,"path":google.maps.geometry.encoding.decodePath("value"),"foo":"bar"})', + $this->encodedPolylineRenderer->render($encodedPolyline, $map) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|EncodingRenderer + */ + private function createEncodingRendererMock() + { + return $this->createMock(EncodingRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Overlay/Extendable/ExtendableRendererTest.php b/tests/Helper/Renderer/Overlay/Extendable/ExtendableRendererTest.php new file mode 100644 index 00000000..58fba58d --- /dev/null +++ b/tests/Helper/Renderer/Overlay/Extendable/ExtendableRendererTest.php @@ -0,0 +1,137 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\ExtendableRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\ExtendableRendererInterface; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class ExtendableRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ExtendableRenderer + */ + private $extendableRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->extendableRenderer = new ExtendableRenderer(); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableRendererInterface::class, $this->extendableRenderer); + } + + public function testSetRenderers() + { + $renderers = [$name = 'foo' => $renderer = $this->createExtendableRendererMock()]; + + $this->extendableRenderer->setRenderers($renderers); + $this->extendableRenderer->setRenderers($renderers); + + $this->assertTrue($this->extendableRenderer->hasRenderers()); + $this->assertTrue($this->extendableRenderer->hasRenderer($name)); + $this->assertSame($renderer, $this->extendableRenderer->getRenderer($name)); + $this->assertSame($renderers, $this->extendableRenderer->getRenderers()); + } + + public function testAddRenderers() + { + $firstRenderers = ['foo' => $this->createExtendableRendererMock()]; + $secondRenderers = ['bar' => $this->createExtendableRendererMock()]; + + $this->extendableRenderer->setRenderers($firstRenderers); + $this->extendableRenderer->addRenderers($secondRenderers); + + $this->assertTrue($this->extendableRenderer->hasRenderers()); + $this->assertSame(array_merge($firstRenderers, $secondRenderers), $this->extendableRenderer->getRenderers()); + } + + public function testSetRenderer() + { + $this->extendableRenderer->setRenderer($name = 'foo', $renderer = $this->createExtendableRendererMock()); + + $this->assertTrue($this->extendableRenderer->hasRenderers()); + $this->assertTrue($this->extendableRenderer->hasRenderer($name)); + $this->assertSame($renderer, $this->extendableRenderer->getRenderer($name)); + $this->assertSame([$name => $renderer], $this->extendableRenderer->getRenderers()); + } + + public function testRemoveRenderer() + { + $this->extendableRenderer->setRenderer($name = 'foo', $this->createExtendableRendererMock()); + $this->extendableRenderer->removeRenderer($name); + + $this->assertFalse($this->extendableRenderer->hasRenderers()); + $this->assertFalse($this->extendableRenderer->hasRenderer($name)); + $this->assertNull($this->extendableRenderer->getRenderer($name)); + $this->assertEmpty($this->extendableRenderer->getRenderers()); + } + + public function testRender() + { + $extendableRenderer = $this->createExtendableRendererMock(); + $extendableRenderer + ->expects($this->once()) + ->method('render') + ->with( + $this->identicalTo($extendable = $this->createExtendableMock()), + $this->identicalTo($bound = $this->createBoundMock()) + ) + ->will($this->returnValue($result = 'result')); + + $this->extendableRenderer->setRenderer(get_class($extendable), $extendableRenderer); + + $this->assertSame($result, $this->extendableRenderer->render($extendable, $bound)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessageRegExp /The extendable renderer for ".*" could not be found\./ + */ + public function testRenderWithInvalidExtendable() + { + $this->extendableRenderer->render($this->createExtendableMock(), $this->createBoundMock()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ExtendableRendererInterface + */ + private function createExtendableRendererMock() + { + return $this->createMock(ExtendableRendererInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ExtendableInterface + */ + private function createExtendableMock() + { + return $this->createMock(ExtendableInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Helper/Renderer/Overlay/Extendable/PathExtendableRendererTest.php b/tests/Helper/Renderer/Overlay/Extendable/PathExtendableRendererTest.php new file mode 100644 index 00000000..f0cdf006 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/Extendable/PathExtendableRendererTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\ExtendableRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\PathExtendableRenderer; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class PathExtendableRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PathExtendableRenderer + */ + private $pathExtendableRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->pathExtendableRenderer = new PathExtendableRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->pathExtendableRenderer); + $this->assertInstanceOf(ExtendableRendererInterface::class, $this->pathExtendableRenderer); + } + + public function testRender() + { + $extendable = $this->createExtendableMock(); + $extendable + ->expects($this->once()) + ->method('getVariable') + ->will($this->returnValue('extendable')); + + $bound = $this->createBoundMock(); + $bound + ->expects($this->once()) + ->method('getVariable') + ->will($this->returnValue('bound')); + + $this->assertSame( + 'extendable.getPath().forEach(function(b){bound.extend(b)})', + $this->pathExtendableRenderer->render($extendable, $bound) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ExtendableInterface + */ + private function createExtendableMock() + { + return $this->createMock(ExtendableInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Helper/Renderer/Overlay/Extendable/PositionExtendableRendererTest.php b/tests/Helper/Renderer/Overlay/Extendable/PositionExtendableRendererTest.php new file mode 100644 index 00000000..f07605d5 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/Extendable/PositionExtendableRendererTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\ExtendableRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\PositionExtendableRenderer; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class PositionExtendableRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PositionExtendableRenderer + */ + private $positionExtendableRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->positionExtendableRenderer = new PositionExtendableRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->positionExtendableRenderer); + $this->assertInstanceOf(ExtendableRendererInterface::class, $this->positionExtendableRenderer); + } + + public function testRender() + { + $extendable = $this->createExtendableMock(); + $extendable + ->expects($this->once()) + ->method('getVariable') + ->will($this->returnValue('extendable')); + + $bound = $this->createBoundMock(); + $bound + ->expects($this->once()) + ->method('getVariable') + ->will($this->returnValue('bound')); + + $this->assertSame( + 'bound.extend(extendable.getPosition())', + $this->positionExtendableRenderer->render($extendable, $bound) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ExtendableInterface + */ + private function createExtendableMock() + { + return $this->createMock(ExtendableInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Helper/Renderer/Overlay/Extendable/UnionExtendableRendererTest.php b/tests/Helper/Renderer/Overlay/Extendable/UnionExtendableRendererTest.php new file mode 100644 index 00000000..4b74e32c --- /dev/null +++ b/tests/Helper/Renderer/Overlay/Extendable/UnionExtendableRendererTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay\Extendable; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\ExtendableRendererInterface; +use Ivory\GoogleMap\Helper\Renderer\Overlay\Extendable\UnionExtendableRenderer; +use Ivory\GoogleMap\Overlay\ExtendableInterface; + +/** + * @author GeLo + */ +class UnionExtendableRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var UnionExtendableRenderer + */ + private $unionExtendableRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->unionExtendableRenderer = new UnionExtendableRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->unionExtendableRenderer); + $this->assertInstanceOf(ExtendableRendererInterface::class, $this->unionExtendableRenderer); + } + + public function testRender() + { + $extendable = $this->createExtendableMock(); + $extendable + ->expects($this->once()) + ->method('getVariable') + ->will($this->returnValue('extendable')); + + $bound = $this->createBoundMock(); + $bound + ->expects($this->once()) + ->method('getVariable') + ->will($this->returnValue('bound')); + + $this->assertSame( + 'bound.union(extendable.getBounds())', + $this->unionExtendableRenderer->render($extendable, $bound) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ExtendableInterface + */ + private function createExtendableMock() + { + return $this->createMock(ExtendableInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Helper/Renderer/Overlay/GroundOverlayRendererTest.php b/tests/Helper/Renderer/Overlay/GroundOverlayRendererTest.php new file mode 100644 index 00000000..7f82937a --- /dev/null +++ b/tests/Helper/Renderer/Overlay/GroundOverlayRendererTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\GroundOverlayRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\GroundOverlay; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class GroundOverlayRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var GroundOverlayRenderer + */ + private $groundOverlayRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->groundOverlayRenderer = new GroundOverlayRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->groundOverlayRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $bound = new Bound(); + $bound->setVariable('bound'); + + $groundOverlay = new GroundOverlay('url', $bound, ['foo' => 'bar']); + $groundOverlay->setVariable('ground_overlay'); + + $this->assertSame( + 'ground_overlay=new google.maps.GroundOverlay("url",bound,{"map":map,"foo":"bar"})', + $this->groundOverlayRenderer->render($groundOverlay, $map) + ); + } +} diff --git a/tests/Helper/Renderer/Overlay/IconRendererTest.php b/tests/Helper/Renderer/Overlay/IconRendererTest.php new file mode 100644 index 00000000..ff5fb95d --- /dev/null +++ b/tests/Helper/Renderer/Overlay/IconRendererTest.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\IconRenderer; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class IconRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var IconRenderer + */ + private $iconRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->iconRenderer = new IconRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->iconRenderer); + } + + public function testRender() + { + $size = new Size(); + $size->setVariable('size'); + + $origin = new Point(); + $origin->setVariable('origin'); + + $anchor = new Point(); + $anchor->setVariable('anchor'); + + $scaledSize = new Size(); + $scaledSize->setVariable('scaled_size'); + + $this->assertSame( + '{"url":"url","anchor":anchor,"origin":origin,"scaledSize":scaled_size,"size":scaled_size}', + $this->iconRenderer->render(new Icon('url', $anchor, $origin, $scaledSize, $size)) + ); + } + + public function testRenderWithoutOptions() + { + $this->assertSame( + '{"url":"https:\/\/maps.gstatic.com\/mapfiles\/markers\/marker.png"}', + $this->iconRenderer->render(new Icon()) + ); + } +} diff --git a/tests/Helper/Renderer/Overlay/InfoBoxRendererTest.php b/tests/Helper/Renderer/Overlay/InfoBoxRendererTest.php new file mode 100644 index 00000000..4d8e837a --- /dev/null +++ b/tests/Helper/Renderer/Overlay/InfoBoxRendererTest.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Overlay\AbstractInfoWindowRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoBoxRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class InfoBoxRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var InfoBoxRenderer + */ + private $infoBoxRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->infoBoxRenderer = new InfoBoxRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new RequirementRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractInfoWindowRenderer::class, $this->infoBoxRenderer); + } + + public function testRequirementRenderer() + { + $this->infoBoxRenderer->setRequirementRenderer($requirementRenderer = $this->createRequirementRendererMock()); + + $this->assertSame($requirementRenderer, $this->infoBoxRenderer->getRequirementRenderer()); + } + + public function testRender() + { + $position = new Coordinate(); + $position->setVariable('position'); + + $pixelOffset = new Size(); + $pixelOffset->setVariable('pixel_offset'); + + $infoWindow = new InfoWindow('content', InfoWindowType::INFO_BOX, $position); + $infoWindow->setVariable('info_window'); + $infoWindow->setPixelOffset($pixelOffset); + $infoWindow->setOptions(['foo' => 'bar']); + + $this->assertSame( + 'info_window=new InfoBox({"position":position,"pixelOffset":pixel_offset,"content":"content","foo":"bar"})', + $this->infoBoxRenderer->render($infoWindow) + ); + } + + public function testRenderWithoutPosition() + { + $infoWindow = new InfoWindow('content'); + $infoWindow->setVariable('info_window'); + + $this->assertSame( + 'info_window=new InfoBox({"content":"content"})', + $this->infoBoxRenderer->render($infoWindow, false) + ); + } + + public function testRenderSource() + { + $this->assertSame( + 'https://cdn.rawgit.com/googlemaps/v3-utility-library/master/infobox/src/infobox_packed.js', + $this->infoBoxRenderer->renderSource() + ); + } + + public function testRenderRequirement() + { + $this->assertSame('typeof InfoBox!==typeof undefined', $this->infoBoxRenderer->renderRequirement()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RequirementRenderer + */ + private function createRequirementRendererMock() + { + return $this->createMock(RequirementRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Overlay/InfoWindowCloseRendererTest.php b/tests/Helper/Renderer/Overlay/InfoWindowCloseRendererTest.php new file mode 100644 index 00000000..8927c781 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/InfoWindowCloseRendererTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowCloseRenderer; +use Ivory\GoogleMap\Overlay\InfoWindow; + +/** + * @author GeLo + */ +class InfoWindowCloseRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var InfoWindowCloseRenderer + */ + private $infoWindowCloseRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->infoWindowCloseRenderer = new InfoWindowCloseRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->infoWindowCloseRenderer); + } + + public function testRender() + { + $infoWindow = new InfoWindow('content'); + $infoWindow->setVariable('info_window'); + + $this->assertSame('info_window.close()', $this->infoWindowCloseRenderer->render($infoWindow)); + } +} diff --git a/tests/Helper/Renderer/Overlay/InfoWindowOpenRendererTest.php b/tests/Helper/Renderer/Overlay/InfoWindowOpenRendererTest.php new file mode 100644 index 00000000..77bdc0af --- /dev/null +++ b/tests/Helper/Renderer/Overlay/InfoWindowOpenRendererTest.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowOpenRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\Marker; + +/** + * @author GeLo + */ +class InfoWindowOpenRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var InfoWindowOpenRenderer + */ + private $infoWindowOpenRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->infoWindowOpenRenderer = new InfoWindowOpenRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->infoWindowOpenRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $marker = new Marker(new Coordinate()); + $marker->setVariable('marker'); + + $infoWindow = new InfoWindow('content'); + $infoWindow->setVariable('info_window'); + + $this->assertSame( + 'info_window.open(map,marker)', + $this->infoWindowOpenRenderer->render($infoWindow, $map, $marker) + ); + } + + public function testRenderWithoutMarker() + { + $map = new Map(); + $map->setVariable('map'); + + $infoWindow = new InfoWindow('content'); + $infoWindow->setVariable('info_window'); + + $this->assertSame( + 'info_window.open(map)', + $this->infoWindowOpenRenderer->render($infoWindow, $map) + ); + } +} diff --git a/tests/Helper/Renderer/Overlay/InfoWindowRendererTest.php b/tests/Helper/Renderer/Overlay/InfoWindowRendererTest.php new file mode 100644 index 00000000..f7aa8f8f --- /dev/null +++ b/tests/Helper/Renderer/Overlay/InfoWindowRendererTest.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\AbstractInfoWindowRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\InfoWindowRendererInterface; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class InfoWindowRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AbstractInfoWindowRenderer|\PHPUnit_Framework_MockObject_MockObject + */ + private $infoWindowRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->infoWindowRenderer = $this->createAbstractInfoWindowRendererMock(); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->infoWindowRenderer); + $this->assertInstanceOf(InfoWindowRendererInterface::class, $this->infoWindowRenderer); + } + + public function testRender() + { + $position = new Coordinate(); + $position->setVariable('position'); + + $pixelOffset = new Size(); + $pixelOffset->setVariable('pixel_offset'); + + $infoWindow = new InfoWindow('content', InfoWindowType::DEFAULT_, $position); + $infoWindow->setVariable('info_window'); + $infoWindow->setPixelOffset($pixelOffset); + $infoWindow->setOptions(['foo' => 'bar']); + + $this->assertSame( + 'info_window=new google.maps.class({"position":position,"pixelOffset":pixel_offset,"content":"content","foo":"bar"})', + $this->infoWindowRenderer->render($infoWindow) + ); + } + + public function testRenderWithoutPosition() + { + $infoWindow = new InfoWindow('content'); + $infoWindow->setVariable('info_window'); + + $this->assertSame( + 'info_window=new google.maps.class({"content":"content"})', + $this->infoWindowRenderer->render($infoWindow, false) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|AbstractInfoWindowRenderer + */ + private function createAbstractInfoWindowRendererMock() + { + $infoWindowRenderer = $this->getMockBuilder(AbstractInfoWindowRenderer::class) + ->setConstructorArgs([new Formatter(), new JsonBuilder()]) + ->getMockForAbstractClass(); + + $infoWindowRenderer + ->expects($this->any()) + ->method('getClass') + ->will($this->returnValue('class')); + + return $infoWindowRenderer; + } +} diff --git a/tests/Helper/Renderer/Overlay/MarkerClustererRendererTest.php b/tests/Helper/Renderer/Overlay/MarkerClustererRendererTest.php new file mode 100644 index 00000000..1d57d92f --- /dev/null +++ b/tests/Helper/Renderer/Overlay/MarkerClustererRendererTest.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerClustererRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\MarkerCluster; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MarkerClustererRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MarkerClustererRenderer + */ + private $markerClustererRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->markerClustererRenderer = new MarkerClustererRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new RequirementRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->markerClustererRenderer); + } + + public function testRequirementRenderer() + { + $requirementRenderer = $this->createRequirementRendererMock(); + $this->markerClustererRenderer->setRequirementRenderer($requirementRenderer); + + $this->assertSame($requirementRenderer, $this->markerClustererRenderer->getRequirementRenderer()); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $markerCluster = new MarkerCluster(); + $markerCluster->setVariable('marker_cluster'); + $markerCluster->setOptions(['foo' => 'bar']); + + $this->assertSame( + 'marker_cluster=new MarkerClusterer(map,markers,{"foo":"bar"})', + $this->markerClustererRenderer->render($markerCluster, $map, 'markers') + ); + } + + public function testRenderSource() + { + $this->assertSame( + 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/src/markerclusterer.js', + $this->markerClustererRenderer->renderSource() + ); + } + + public function testRenderRequirement() + { + $this->assertSame( + 'typeof MarkerClusterer!==typeof undefined', + $this->markerClustererRenderer->renderRequirement() + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RequirementRenderer + */ + private function createRequirementRendererMock() + { + return $this->createMock(RequirementRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Overlay/MarkerRendererTest.php b/tests/Helper/Renderer/Overlay/MarkerRendererTest.php new file mode 100644 index 00000000..803ffb12 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/MarkerRendererTest.php @@ -0,0 +1,140 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\AnimationRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\IconRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerShapeRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Animation; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Overlay\MarkerShapeType; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MarkerRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MarkerRenderer + */ + private $markerRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->markerRenderer = new MarkerRenderer( + $formatter = new Formatter(), + $jsonBuilder = new JsonBuilder(), + new AnimationRenderer($formatter), + new IconRenderer($formatter, $jsonBuilder), + new MarkerShapeRenderer($formatter, $jsonBuilder) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->markerRenderer); + } + + public function testAnimationRenderer() + { + $this->markerRenderer->setAnimationRenderer($animationRenderer = $this->createAnimationRendererMock()); + + $this->assertSame($animationRenderer, $this->markerRenderer->getAnimationRenderer()); + } + + public function testIconRendererMock() + { + $this->markerRenderer->setIconRenderer($iconRenderer = $this->createIconRendererMock()); + + $this->assertSame($iconRenderer, $this->markerRenderer->getIconRenderer()); + } + + public function testMarkerShapeRenderer() + { + $this->markerRenderer->setMarkerShapeRenderer($markerShapeRenderer = $this->createMarkerShapeRendererMock()); + + $this->assertSame($markerShapeRenderer, $this->markerRenderer->getMarkerShapeRenderer()); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $position = new Coordinate(); + $position->setVariable('position'); + + $marker = new Marker( + $position, + Animation::DROP, + new Icon(), + new MarkerShape(MarkerShapeType::CIRCLE, [1.2, 2.3, 3.4]), + ['foo' => 'bar'] + ); + + $marker->setVariable('marker'); + + $this->assertSame( + 'marker=new google.maps.Marker({"position":position,"map":map,"animation":google.maps.Animation.DROP,"icon":{"url":"https:\/\/maps.gstatic.com\/mapfiles\/markers\/marker.png"},"shape":{"type":"circle","coords":[1.2,2.3,3.4]},"foo":"bar"})', + $this->markerRenderer->render($marker, $map) + ); + } + + public function testRenderWithoutOptions() + { + $position = new Coordinate(); + $position->setVariable('position'); + + $marker = new Marker($position); + $marker->setVariable('marker'); + + $this->assertSame( + 'marker=new google.maps.Marker({"position":position})', + $this->markerRenderer->render($marker) + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|AnimationRenderer + */ + private function createAnimationRendererMock() + { + return $this->createMock(AnimationRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|IconRenderer + */ + private function createIconRendererMock() + { + return $this->createMock(IconRenderer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MarkerShapeRenderer + */ + private function createMarkerShapeRendererMock() + { + return $this->createMock(MarkerShapeRenderer::class); + } +} diff --git a/tests/Helper/Renderer/Overlay/MarkerShapeRendererTest.php b/tests/Helper/Renderer/Overlay/MarkerShapeRendererTest.php new file mode 100644 index 00000000..2563f524 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/MarkerShapeRendererTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\MarkerShapeRenderer; +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Overlay\MarkerShapeType; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class MarkerShapeRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MarkerShapeRenderer + */ + private $markerShapeRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->markerShapeRenderer = new MarkerShapeRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->markerShapeRenderer); + } + + public function testRender() + { + $this->assertSame( + '{"type":"circle","coords":[1.2,2.3,3.4]}', + $this->markerShapeRenderer->render(new MarkerShape(MarkerShapeType::CIRCLE, [1.2, 2.3, 3.4])) + ); + } +} diff --git a/tests/Helper/Renderer/Overlay/PolygonRendererTest.php b/tests/Helper/Renderer/Overlay/PolygonRendererTest.php new file mode 100644 index 00000000..eba61d8d --- /dev/null +++ b/tests/Helper/Renderer/Overlay/PolygonRendererTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\PolygonRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polygon; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class PolygonRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PolygonRenderer + */ + private $polygonRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->polygonRenderer = new PolygonRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->polygonRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $coordinate1 = new Coordinate(); + $coordinate1->setVariable('coordinate1'); + + $coordinate2 = new Coordinate(); + $coordinate2->setVariable('coordinate2'); + + $polygon = new Polygon([$coordinate1, $coordinate2], ['foo' => 'bar']); + $polygon->setVariable('polygon'); + + $this->assertSame( + 'polygon=new google.maps.Polygon({"map":map,"paths":[coordinate1,coordinate2],"foo":"bar"})', + $this->polygonRenderer->render($polygon, $map) + ); + } +} diff --git a/tests/Helper/Renderer/Overlay/PolylineRendererTest.php b/tests/Helper/Renderer/Overlay/PolylineRendererTest.php new file mode 100644 index 00000000..453b4b27 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/PolylineRendererTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\PolylineRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Polyline; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class PolylineRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PolylineRenderer + */ + private $polylineRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->polylineRenderer = new PolylineRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->polylineRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $coordinate1 = new Coordinate(); + $coordinate1->setVariable('coordinate1'); + + $coordinate2 = new Coordinate(); + $coordinate2->setVariable('coordinate2'); + + $polyline = new Polyline([$coordinate1, $coordinate2], ['foo' => 'bar']); + $polyline->setVariable('polyline'); + + $this->assertSame( + 'polyline=new google.maps.Polyline({"map":map,"path":[coordinate1,coordinate2],"foo":"bar"})', + $this->polylineRenderer->render($polyline, $map) + ); + } +} diff --git a/tests/Helper/Renderer/Overlay/RectangleRendererTest.php b/tests/Helper/Renderer/Overlay/RectangleRendererTest.php new file mode 100644 index 00000000..b725f362 --- /dev/null +++ b/tests/Helper/Renderer/Overlay/RectangleRendererTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Overlay\RectangleRenderer; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Rectangle; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class RectangleRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var RectangleRenderer + */ + private $rectangleRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->rectangleRenderer = new RectangleRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->rectangleRenderer); + } + + public function testRender() + { + $map = new Map(); + $map->setVariable('map'); + + $bound = new Bound(); + $bound->setVariable('bound'); + + $rectangle = new Rectangle($bound, ['foo' => 'bar']); + $rectangle->setVariable('rectangle'); + + $this->assertSame( + 'rectangle=new google.maps.Rectangle({"map":map,"bounds":bound,"foo":"bar"})', + $this->rectangleRenderer->render($rectangle, $map) + ); + } +} diff --git a/tests/Helper/Renderer/Place/AutocompleteContainerRendererTest.php b/tests/Helper/Renderer/Place/AutocompleteContainerRendererTest.php new file mode 100644 index 00000000..94d95b71 --- /dev/null +++ b/tests/Helper/Renderer/Place/AutocompleteContainerRendererTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Place; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteContainerRenderer; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class AutocompleteContainerRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AutocompleteContainerRenderer + */ + private $autocompleteContainerRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->autocompleteContainerRenderer = new AutocompleteContainerRenderer(new Formatter(), new JsonBuilder()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->autocompleteContainerRenderer); + } + + public function testRender() + { + $this->assertSame( + '{"base":{"coordinates":[],"bounds":[]},"autocomplete":null}', + $this->autocompleteContainerRenderer->render() + ); + } +} diff --git a/tests/Helper/Renderer/Place/AutocompleteHtmlRendererTest.php b/tests/Helper/Renderer/Place/AutocompleteHtmlRendererTest.php new file mode 100644 index 00000000..2540da1f --- /dev/null +++ b/tests/Helper/Renderer/Place/AutocompleteHtmlRendererTest.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Place; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\Html\AbstractTagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Html\TagRenderer; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteHtmlRenderer; +use Ivory\GoogleMap\Place\Autocomplete; + +/** + * @author GeLo + */ +class AutocompleteHtmlRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AutocompleteHtmlRenderer + */ + private $autocompleteHtmlRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->autocompleteHtmlRenderer = new AutocompleteHtmlRenderer( + $formatter = new Formatter(), + new TagRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractTagRenderer::class, $this->autocompleteHtmlRenderer); + } + + public function testRender() + { + $autocomplete = new Autocomplete(); + $autocomplete->setVariable('autocomplete'); + $autocomplete->setValue('value'); + + $this->assertSame( + '', + $this->autocompleteHtmlRenderer->render($autocomplete) + ); + } + + public function testRenderWithoutOptions() + { + $autocomplete = new Autocomplete(); + $autocomplete->setVariable('autocomplete'); + + $this->assertSame( + '', + $this->autocompleteHtmlRenderer->render($autocomplete) + ); + } +} diff --git a/tests/Helper/Renderer/Place/AutocompleteRendererTest.php b/tests/Helper/Renderer/Place/AutocompleteRendererTest.php new file mode 100644 index 00000000..0fc9653d --- /dev/null +++ b/tests/Helper/Renderer/Place/AutocompleteRendererTest.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Place; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractJsonRenderer; +use Ivory\GoogleMap\Helper\Renderer\Place\AutocompleteRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementRenderer; +use Ivory\GoogleMap\Place\Autocomplete; +use Ivory\GoogleMap\Place\AutocompleteComponentRestriction; +use Ivory\GoogleMap\Place\AutocompleteType; +use Ivory\JsonBuilder\JsonBuilder; + +/** + * @author GeLo + */ +class AutocompleteRendererTest extends\PHPUnit_Framework_TestCase +{ + /** + * @var AutocompleteRenderer + */ + private $autocompleteRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->autocompleteRenderer = new AutocompleteRenderer( + $formatter = new Formatter(), + new JsonBuilder(), + new RequirementRenderer($formatter) + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractJsonRenderer::class, $this->autocompleteRenderer); + } + + public function testRequirementRenderer() + { + $requirementRenderer = $this->createRequirementRendererMock(); + $this->autocompleteRenderer->setRequirementRenderer($requirementRenderer); + + $this->assertSame($requirementRenderer, $this->autocompleteRenderer->getRequirementRenderer()); + } + + public function testRender() + { + $bound = new Bound(); + $bound->setVariable('bound'); + + $autocomplete = new Autocomplete(); + $autocomplete->setTypes([AutocompleteType::CITIES]); + $autocomplete->setBound($bound); + $autocomplete->setComponentRestrictions([AutocompleteComponentRestriction::COUNTRY => 'fr']); + $autocomplete->setVariable('autocomplete'); + + $this->assertSame( + 'autocomplete=new google.maps.places.Autocomplete(document.getElementById("place_input"),{"types":["(cities)"],"bounds":bound,"componentRestrictions":{"country":"fr"}})', + $this->autocompleteRenderer->render($autocomplete) + ); + } + + public function testRenderWithoutOptions() + { + $autocomplete = new Autocomplete(); + $autocomplete->setVariable('autocomplete'); + + $this->assertSame( + 'autocomplete=new google.maps.places.Autocomplete(document.getElementById("place_input"),{})', + $this->autocompleteRenderer->render($autocomplete) + ); + } + + public function testRenderRequirement() + { + $this->assertSame( + 'typeof google.maps.places!==typeof undefined', + $this->autocompleteRenderer->renderRequirement() + ); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RequirementRenderer + */ + private function createRequirementRendererMock() + { + return $this->createMock(RequirementRenderer::class); + } +} diff --git a/tests/Helper/Renderer/RendererTest.php b/tests/Helper/Renderer/RendererTest.php new file mode 100644 index 00000000..e2e30609 --- /dev/null +++ b/tests/Helper/Renderer/RendererTest.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; + +/** + * @author GeLo + */ +class RendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AbstractRenderer + */ + private $renderer; + + /** + * @var Formatter + */ + private $formatter; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->formatter = $this->createFormatterMock(); + $this->renderer = $this->createAbstractRendererMock($this->formatter); + } + + public function testDefaultState() + { + $this->assertSame($this->formatter, $this->renderer->getFormatter()); + } + + public function testFormatter() + { + $this->renderer->setFormatter($formatter = $this->createFormatterMock()); + + $this->assertSame($formatter, $this->renderer->getFormatter()); + } + + /** + * @param Formatter|null $formatter + * + * @return \PHPUnit_Framework_MockObject_MockObject|AbstractRenderer + */ + private function createAbstractRendererMock(Formatter $formatter = null) + { + return $this->getMockBuilder(AbstractRenderer::class) + ->setConstructorArgs([$formatter ?: $this->createFormatterMock()]) + ->getMockForAbstractClass(); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Formatter + */ + private function createFormatterMock() + { + return $this->createMock(Formatter::class); + } +} diff --git a/tests/Helper/Renderer/Utility/CallbackRendererTest.php b/tests/Helper/Renderer/Utility/CallbackRendererTest.php new file mode 100644 index 00000000..2b22f535 --- /dev/null +++ b/tests/Helper/Renderer/Utility/CallbackRendererTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\CallbackRenderer; + +/** + * @author GeLo + */ +class CallbackRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CallbackRenderer + */ + private $callbackRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->callbackRenderer = new CallbackRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->callbackRenderer); + } + + public function testRender() + { + $this->assertSame('ivory_google_map_name', $this->callbackRenderer->render('name')); + } +} diff --git a/tests/Helper/Renderer/Utility/ObjectToArrayRendererTest.php b/tests/Helper/Renderer/Utility/ObjectToArrayRendererTest.php new file mode 100644 index 00000000..38bf0338 --- /dev/null +++ b/tests/Helper/Renderer/Utility/ObjectToArrayRendererTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\ObjectToArrayRenderer; + +/** + * @author GeLo + */ +class ObjectToArrayRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ObjectToArrayRenderer + */ + private $objectToArrayRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->objectToArrayRenderer = new ObjectToArrayRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->objectToArrayRenderer); + } + + public function testRender() + { + $this->assertSame( + 'function(o){var a=[];for(var k in o){a.push(o[k]);}return a;}', + $this->objectToArrayRenderer->render() + ); + } + + public function testRenderWithVariables() + { + $this->assertSame( + 'function(object){var array=[];for(var key in object){array.push(object[key]);}return array;}', + $this->objectToArrayRenderer->render('array', 'object', 'key') + ); + } + + public function testRenderWithDebug() + { + $this->objectToArrayRenderer->getFormatter()->setDebug(true); + + $this->assertSame( + 'function (o) {'.PHP_EOL.' var a = [];'.PHP_EOL.' for (var k in o) {'.PHP_EOL.' a.push(o[k]);'.PHP_EOL.' }'.PHP_EOL.' return a;'.PHP_EOL.'}', + $this->objectToArrayRenderer->render() + ); + } +} diff --git a/tests/Helper/Renderer/Utility/RequirementLoaderRendererTest.php b/tests/Helper/Renderer/Utility/RequirementLoaderRendererTest.php new file mode 100644 index 00000000..e4789cab --- /dev/null +++ b/tests/Helper/Renderer/Utility/RequirementLoaderRendererTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\RequirementLoaderRenderer; + +/** + * @author GeLo + */ +class RequirementLoaderRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var RequirementLoaderRenderer + */ + private $requirementLoaderRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->requirementLoaderRenderer = new RequirementLoaderRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->requirementLoaderRenderer); + } + + public function testRender() + { + $this->assertSame( + 'function name(c,r){if(r()){c();}else{var i=setInterval(function(){if(r()){clearInterval(i);c();}},10);}};', + $this->requirementLoaderRenderer->render('name') + ); + } + + public function testRenderWithVariables() + { + $this->assertSame( + 'function name(callback,requirement){if(requirement()){callback();}else{var interval=setInterval(function(){if(requirement()){clearInterval(interval);callback();}},10);}};', + $this->requirementLoaderRenderer->render('name', 'interval', 'callback', 'requirement') + ); + } + + public function testRenderWithDebug() + { + $this->requirementLoaderRenderer->getFormatter()->setDebug(true); + + $this->assertSame( + 'function name (c, r) {'.PHP_EOL.' if (r()) {'.PHP_EOL.' c();'.PHP_EOL.' } else {'.PHP_EOL.' var i = setInterval(function () {'.PHP_EOL.' if (r()) {'.PHP_EOL.' clearInterval(i);'.PHP_EOL.' c();'.PHP_EOL.' }'.PHP_EOL.' }, 10);'.PHP_EOL.' }'.PHP_EOL.'};'.PHP_EOL, + $this->requirementLoaderRenderer->render('name') + ); + } +} diff --git a/tests/Helper/Renderer/Utility/SourceRendererTest.php b/tests/Helper/Renderer/Utility/SourceRendererTest.php new file mode 100644 index 00000000..7004fa32 --- /dev/null +++ b/tests/Helper/Renderer/Utility/SourceRendererTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Helper\Renderer\Utility; + +use Ivory\GoogleMap\Helper\Formatter\Formatter; +use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; +use Ivory\GoogleMap\Helper\Renderer\Utility\SourceRenderer; + +/** + * @author GeLo + */ +class SourceRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var SourceRenderer + */ + private $sourceRenderer; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->sourceRenderer = new SourceRenderer(new Formatter()); + } + + public function testInheritance() + { + $this->assertInstanceOf(AbstractRenderer::class, $this->sourceRenderer); + } + + public function testRender() + { + $this->assertSame( + 'function name(src){var script=document.createElement("script");script.type="text/javascript";script.async=true;script.src=src;document.getElementsByTagName("head")[0].appendChild(script);};', + $this->sourceRenderer->render('name') + ); + } + + public function testRenderWithVariables() + { + $this->assertSame( + 'function name(source){var variable=document.createElement("script");variable.type="text/javascript";variable.async=true;variable.src=source;document.getElementsByTagName("head")[0].appendChild(variable);};', + $this->sourceRenderer->render('name', 'source', 'variable') + ); + } + + public function testRenderWithDebug() + { + $this->sourceRenderer->getFormatter()->setDebug(true); + + $this->assertSame( + 'function name (src) {'.PHP_EOL.' var script = document.createElement("script");'.PHP_EOL.' script.type = "text/javascript";'.PHP_EOL.' script.async = true;'.PHP_EOL.' script.src = src;'.PHP_EOL.' document.getElementsByTagName("head")[0].appendChild(script);'.PHP_EOL.'};'.PHP_EOL, + $this->sourceRenderer->render('name') + ); + } +} diff --git a/tests/Layer/KmlLayerTest.php b/tests/Layer/KmlLayerTest.php new file mode 100644 index 00000000..4eab5dc7 --- /dev/null +++ b/tests/Layer/KmlLayerTest.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Layer; + +use Ivory\GoogleMap\Layer\KmlLayer; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class KmlLayerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var KmlLayer + */ + private $kmlLayer; + + /** + * @var string + */ + private $url; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->kmlLayer = new KmlLayer($this->url = 'http://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml'); + } + + public function testInheritance() + { + $this->assertInstanceOf(OptionsAwareInterface::class, $this->kmlLayer); + $this->assertInstanceOf(VariableAwareInterface::class, $this->kmlLayer); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('kml_layer', $this->kmlLayer->getVariable()); + $this->assertSame($this->url, $this->kmlLayer->getUrl()); + $this->assertFalse($this->kmlLayer->hasOptions()); + } + + public function testInitialState() + { + $this->kmlLayer = new KmlLayer($this->url, $options = ['foo' => 'bar']); + + $this->assertSame($this->url, $this->kmlLayer->getUrl()); + $this->assertSame($options, $this->kmlLayer->getOptions()); + } + + public function testUrl() + { + $this->kmlLayer->setUrl($url = 'http://googlemaps.github.io/js-v1-samples/ggeoxml/cta.kml'); + + $this->assertSame($url, $this->kmlLayer->getUrl()); + } +} diff --git a/tests/Layer/LayerManagerTest.php b/tests/Layer/LayerManagerTest.php new file mode 100644 index 00000000..7d8ec1dd --- /dev/null +++ b/tests/Layer/LayerManagerTest.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Layer; + +use Ivory\GoogleMap\Layer\KmlLayer; +use Ivory\GoogleMap\Layer\LayerManager; +use Ivory\GoogleMap\Map; + +/** + * @author GeLo + */ +class LayerManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var LayerManager + */ + private $layerManager; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->layerManager = new LayerManager(); + } + + public function testDefaultState() + { + $this->assertFalse($this->layerManager->hasMap()); + $this->assertNull($this->layerManager->getMap()); + $this->assertFalse($this->layerManager->hasKmlLayers()); + $this->assertEmpty($this->layerManager->getKmlLayers()); + } + + public function testMap() + { + $map = $this->createMapMock(); + $map + ->expects($this->once()) + ->method('getLayerManager') + ->will($this->returnValue(null)); + + $map + ->expects($this->once()) + ->method('setLayerManager') + ->with($this->identicalTo($this->layerManager)); + + $this->layerManager->setMap($map); + + $this->assertTrue($this->layerManager->hasMap()); + $this->assertSame($map, $this->layerManager->getMap()); + } + + public function testSetKmlLayers() + { + $this->layerManager->setKmlLayers($kmlLayers = [$kmlLayer = $this->createKmlLayerMock()]); + $this->layerManager->setKmlLayers($kmlLayers); + + $this->assertTrue($this->layerManager->hasKmlLayers()); + $this->assertTrue($this->layerManager->hasKmlLayer($kmlLayer)); + $this->assertSame($kmlLayers, $this->layerManager->getKmlLayers()); + } + + public function testAddKmlLayers() + { + $this->layerManager->setKmlLayers($firstKmlLayers = [$this->createKmlLayerMock()]); + $this->layerManager->addKmlLayers($secondKmlLayers = [$this->createKmlLayerMock()]); + + $this->assertTrue($this->layerManager->hasKmlLayers()); + $this->assertSame(array_merge($firstKmlLayers, $secondKmlLayers), $this->layerManager->getKmlLayers()); + } + + public function testAddKmlLayer() + { + $this->layerManager->addKmlLayer($kmlLayer = $this->createKmlLayerMock()); + + $this->assertTrue($this->layerManager->hasKmlLayers()); + $this->assertTrue($this->layerManager->hasKmlLayer($kmlLayer)); + $this->assertSame([$kmlLayer], $this->layerManager->getKmlLayers()); + } + + public function testRemoveKmlLayer() + { + $this->layerManager->addKmlLayer($kmlLayer = $this->createKmlLayerMock()); + $this->layerManager->removeKmlLayer($kmlLayer); + + $this->assertFalse($this->layerManager->hasKmlLayers()); + $this->assertFalse($this->layerManager->hasKmlLayer($kmlLayer)); + $this->assertEmpty($this->layerManager->getKmlLayers()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Map + */ + private function createMapMock() + { + return $this->createMock(Map::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|KmlLayer + */ + private function createKmlLayerMock() + { + return $this->createMock(KmlLayer::class); + } +} diff --git a/tests/Layers/KMLLayerTest.php b/tests/Layers/KMLLayerTest.php deleted file mode 100644 index c97c015f..00000000 --- a/tests/Layers/KMLLayerTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Events; - -use Ivory\GoogleMap\Layers\KMLLayer; - -/** - * KML layer test. - * - * @author GeLo - */ -class KMLLayerTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Layers\KMLLayer */ - protected $kmlLayer; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->kmlLayer = new KMLLayer(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->kmlLayer); - } - - public function testDefaultState() - { - $this->assertNull($this->kmlLayer->getUrl()); - } - - public function testInitialState() - { - $this->kmlLayer = new KMLLayer('foo'); - - $this->assertSame('foo', $this->kmlLayer->getUrl()); - } - - public function testUrlWithValidValue() - { - $this->kmlLayer->setUrl('foo'); - - $this->assertSame('foo', $this->kmlLayer->getUrl()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\LayerException - * @expectedExceptionMessage The kml layer url must be a string value. - */ - public function testUrlWithInvalidValue() - { - $this->kmlLayer->setUrl(true); - } -} diff --git a/tests/MapTest.php b/tests/MapTest.php index 0f4aad43..fc17a9ba 100644 --- a/tests/MapTest.php +++ b/tests/MapTest.php @@ -11,22 +11,24 @@ namespace Ivory\Tests\GoogleMap; -use Ivory\GoogleMap\Controls\ControlPosition; -use Ivory\GoogleMap\Controls\MapTypeControlStyle; -use Ivory\GoogleMap\Controls\ScaleControlStyle; -use Ivory\GoogleMap\Controls\ZoomControlStyle; +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Control\ControlManager; +use Ivory\GoogleMap\Event\EventManager; +use Ivory\GoogleMap\Layer\LayerManager; use Ivory\GoogleMap\Map; -use Ivory\GoogleMap\MapTypeId; +use Ivory\GoogleMap\Overlay\OverlayManager; +use Ivory\GoogleMap\Utility\VariableAwareInterface; /** - * Map test. - * * @author GeLo */ class MapTest extends \PHPUnit_Framework_TestCase { - /** @var \Ivory\GoogleMap\Map */ - protected $map; + /** + * @var Map + */ + private $map; /** * {@inheritdoc} @@ -36,875 +38,310 @@ protected function setUp() $this->map = new Map(); } - /** - * Set up the map bound. - */ - protected function setUpBound() + public function testInheritance() { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $bound - ->expects($this->any()) - ->method('hasCoordinates') - ->will($this->returnValue(true)); - - $this->map->setBound($bound); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->map); + $this->assertInstanceOf(VariableAwareInterface::class, $this->map); } public function testDefaultState() { - $this->assertSame('map_canvas', $this->map->getHtmlContainerId()); - $this->assertFalse($this->map->isAsync()); + $this->assertStringStartsWith('map', $this->map->getVariable()); + $this->assertSame('map_canvas', $this->map->getHtmlId()); $this->assertFalse($this->map->isAutoZoom()); - - $this->assertSame($this->map->getCenter()->getLatitude(), 0); - $this->assertSame($this->map->getCenter()->getLongitude(), 0); - $this->assertTrue($this->map->getCenter()->isNoWrap()); - - $this->assertNull($this->map->getBound()->getNorthEast()); - $this->assertNull($this->map->getBound()->getSouthWest()); - $this->assertEmpty($this->map->getBound()->getExtends()); - - $this->assertSame(array('mapTypeId' => 'roadmap','zoom' => 3), $this->map->getMapOptions()); - $this->assertSame(array('width' => '300px', 'height' => '300px'), $this->map->getStylesheetOptions()); - - $this->assertFalse($this->map->hasMapTypeControl()); - $this->assertFalse($this->map->hasOverviewMapControl()); - $this->assertFalse($this->map->hasPanControl()); - $this->assertFalse($this->map->hasRotateControl()); - $this->assertFalse($this->map->hasScaleControl()); - $this->assertFalse($this->map->hasStreetViewControl()); - $this->assertFalse($this->map->hasZoomControl()); - - $this->assertInstanceOf('Ivory\GoogleMap\Events\EventManager', $this->map->getEventManager()); - $this->assertInstanceOf('Ivory\GoogleMap\Overlays\MarkerCluster', $this->map->getMarkerCluster()); - - $this->assertEmpty($this->map->getMarkers()); - $this->assertEmpty($this->map->getInfoWindows()); - $this->assertEmpty($this->map->getPolylines()); - $this->assertEmpty($this->map->getPolygons()); - $this->assertEmpty($this->map->getEncodedPolylines()); - $this->assertEmpty($this->map->getRectangles()); - $this->assertEmpty($this->map->getCircles()); - $this->assertEmpty($this->map->getGroundOverlays()); - - $this->assertEmpty($this->map->getKMLLayers()); - + $this->assertInstanceOf(Coordinate::class, $this->map->getCenter()); + $this->assertInstanceOf(Bound::class, $this->map->getBound()); + $this->assertInstanceOf(ControlManager::class, $this->map->getControlManager()); + $this->assertInstanceOf(EventManager::class, $this->map->getEventManager()); + $this->assertInstanceOf(OverlayManager::class, $this->map->getOverlayManager()); + $this->assertInstanceOf(LayerManager::class, $this->map->getLayerManager()); $this->assertFalse($this->map->hasLibraries()); + $this->assertEmpty($this->map->getLibraries()); $this->assertSame('en', $this->map->getLanguage()); + $this->assertFalse($this->map->hasMapOptions()); + $this->assertEmpty($this->map->getMapOptions()); + $this->assertFalse($this->map->hasStylesheetOptions()); + $this->assertEmpty($this->map->getStylesheetOptions()); } - public function testHtmlContainerIdWithValidValue() + public function testHtmlId() { - $this->map->setHtmlContainerId('html_container_id'); - - $this->assertSame('html_container_id', $this->map->getHtmlContainerId()); - } + $this->map->setHtmlId($htmlId = 'html_id'); - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The html container id of a map must be a string value. - */ - public function testHtmlContainerWithInvalidValue() - { - $this->map->setHtmlContainerId(true); + $this->assertSame($htmlId, $this->map->getHtmlId()); } - public function testAsyncWithValidValue() - { - $this->map->setAsync(true); - - $this->assertTrue($this->map->isAsync()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The asynchronous load of a map must be a boolean value. - */ - public function testAsyncWithInvalidValue() - { - $this->map->setAsync('foo'); - } - - public function testAutoZoomWithValidValue() + public function testAutoZoom() { $this->map->setAutoZoom(true); $this->assertTrue($this->map->isAutoZoom()); } - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The auto zoom of a map must be a boolean value. - */ - public function testAutoZoomWithInvalidValue() - { - $this->map->setAutoZoom('foo'); - } - - public function testCenterWithCoordinate() - { - $coordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->map->setCenter($coordinate); - - $this->assertSame($coordinate, $this->map->getCenter()); - } - - public function testCenterWithLatitueAndLongitude() + public function testCenter() { - $this->map->setCenter(1, 2, false); + $this->map->setCenter($center = $this->createCoordinateMock()); - $this->assertEquals(1, $this->map->getCenter()->getLatitude()); - $this->assertEquals(2, $this->map->getCenter()->getLongitude()); - $this->assertFalse($this->map->getCenter()->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The center setter arguments is invalid. - * The available prototypes are : - * - function setCenter(Ivory\GoogleMap\Base\Coordinate $center) - * - function setCenter(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testCenterWithInvalidValue() - { - $this->map->setCenter('foo'); + $this->assertSame($center, $this->map->getCenter()); } - public function testBoundWithBound() + public function testBound() { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $this->map->setBound($bound); + $this->map->setBound($bound = $this->createBoundMock()); $this->assertSame($bound, $this->map->getBound()); } - public function testBoundWithCoordinates() + public function testControlManager() { - $southWestCoordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $northEastCoordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->map->setBound($southWestCoordinate, $northEastCoordinate); - - $this->assertSame($southWestCoordinate, $this->map->getBound()->getSouthWest()); - $this->assertSame($northEastCoordinate, $this->map->getBound()->getNorthEast()); - } + $controlManager = $this->createControlManagerMock(); + $controlManager + ->expects($this->once()) + ->method('getMap') + ->will($this->returnValue(null)); - public function testBoundWithLatitudesAndLongitudes() - { - $this->map->setBound(1, 2, 3, 4, true, false); + $controlManager + ->expects($this->once()) + ->method('setMap') + ->with($this->identicalTo($this->map)); - $this->assertSame(1, $this->map->getBound()->getSouthWest()->getLatitude()); - $this->assertSame(2, $this->map->getBound()->getSouthWest()->getLongitude()); - $this->assertTrue($this->map->getBound()->getSouthWest()->isNoWrap()); + $this->map->setControlManager($controlManager); - $this->assertEquals(3, $this->map->getBound()->getNorthEast()->getLatitude()); - $this->assertEquals(4, $this->map->getBound()->getNorthEast()->getLongitude()); - $this->assertFalse($this->map->getBound()->getNorthEast()->isNoWrap()); + $this->assertSame($controlManager, $this->map->getControlManager()); } - public function testBoundWithNullValue() + public function testEventManager() { - $this->map->setBound(1, 2, 3, 4); - $this->map->setBound(null); + $eventManager = $this->createEventManagerMock(); + $eventManager + ->expects($this->once()) + ->method('getMap') + ->will($this->returnValue(null)); - $this->assertNull($this->map->getBound()->getSouthWest()); - $this->assertNull($this->map->getBound()->getNorthEast()); - } + $eventManager + ->expects($this->once()) + ->method('setMap') + ->with($this->identicalTo($this->map)); - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The bound setter arguments is invalid. - * The available prototypes are : - * - function setBound(Ivory\GoogleMap\Base\Bound $bound) - * - function setBount(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - */ - public function testBoundWithInvalidValue() - { - $this->map->setBound('foo'); - } + $this->map->setEventManager($eventManager); - public function testHasMapOptionWithValidValue() - { - $this->assertTrue($this->map->hasMapOption('zoom')); - $this->assertFalse($this->map->hasMapOption('foo')); + $this->assertSame($eventManager, $this->map->getEventManager()); } - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The map option property of a map must be a string value. - */ - public function testHasMapOptionWithInvalidValue() + public function testLayerManager() { - $this->map->hasMapOption(true); - } + $layerManager = $this->createLayerManagerMock(); + $layerManager + ->expects($this->once()) + ->method('getMap') + ->will($this->returnValue(null)); - public function testSetMapOptionsWithValidValue() - { - $this->map->setMapOptions(array('foo' => 'bar')); + $layerManager + ->expects($this->once()) + ->method('setMap') + ->with($this->identicalTo($this->map)); - $this->assertSame('bar', $this->map->getMapOption('foo')); - } + $this->map->setLayerManager($layerManager); - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - */ - public function testSetMapOptionWithInvalidValue() - { - $this->map->setMapOption(true, false); + $this->assertSame($layerManager, $this->map->getLayerManager()); } - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - */ - public function testGetMapOptionWithInvalidValue() + public function testOverlayManager() { - $this->map->getMapOption('foo'); - } + $overlayManager = $this->createOverlayManagerMock(); + $overlayManager + ->expects($this->once()) + ->method('getMap') + ->will($this->returnValue(null)); - public function testRemoveMapOptionWithValidValue() - { - $this->map->removeMapOption('zoom'); + $overlayManager + ->expects($this->once()) + ->method('setMap') + ->with($this->identicalTo($this->map)); - $this->assertFalse($this->map->hasMapOption('zoom')); - } + $this->map->setOverlayManager($overlayManager); - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The map option "foo" does not exist. - */ - public function testRemoveMapOptionWithInvalidValue() - { - $this->map->removeMapOption('foo'); + $this->assertSame($overlayManager, $this->map->getOverlayManager()); } - public function testHasStylesheetOptionWithValidValue() + public function testSetLibraries() { - $this->assertTrue($this->map->hasStylesheetOption('width')); - $this->assertFalse($this->map->hasStylesheetOption('foo')); - } + $this->map->setLibraries($libraries = [$library = 'geometry']); + $this->map->setLibraries($libraries); - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The stylesheet option property of a map must be a string value. - */ - public function testHasStylesheetOptionWithInvalidValue() - { - $this->map->hasStylesheetOption(true); + $this->assertTrue($this->map->hasLibraries()); + $this->assertTrue($this->map->hasLibrary($library)); + $this->assertSame($libraries, $this->map->getLibraries()); } - public function testSetStylesheetOptionsWithValidValue() + public function testAddLibraries() { - $this->map->setStylesheetOptions(array('foo' => 'bar')); + $this->map->setLibraries($firstLibraries = ['geometry']); + $this->map->addLibraries($secondLibraries = ['places']); - $this->assertSame('bar', $this->map->getStylesheetOption('foo')); + $this->assertTrue($this->map->hasLibraries()); + $this->assertSame(array_merge($firstLibraries, $secondLibraries), $this->map->getLibraries()); } - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - */ - public function testSetStylesheetOptionWithInvalidValue() + public function testAddLibrary() { - $this->map->setStylesheetOption(true, false); - } + $this->map->addLibrary($library = 'geometry'); - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - */ - public function testGetStylesheetOptionWithInvalidValue() - { - $this->map->getStylesheetOption('foo'); + $this->assertTrue($this->map->hasLibraries()); + $this->assertTrue($this->map->hasLibrary($library)); + $this->assertSame([$library], $this->map->getLibraries()); } - public function testRemoveStylesheetOptionWithValidValue() + public function testRemoveLibrary() { - $this->map->removeStylesheetOption('width'); - - $this->assertFalse($this->map->hasStylesheetOption('width')); - } + $this->map->addLibrary($library = 'geometry'); + $this->map->removeLibrary($library); - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The stylesheet option "foo" does not exist. - */ - public function testRemoveStylesheetOptionWithInvalidValue() - { - $this->map->removeStylesheetOption('foo'); + $this->assertFalse($this->map->hasLibraries()); + $this->assertFalse($this->map->hasLibrary($library)); + $this->assertEmpty($this->map->getLibraries()); } - public function testMapTypeControlWithMapTypeControl() + public function testLanguage() { - $mapTypeControl = $this->getMock('Ivory\GoogleMap\Controls\MapTypeControl'); - $this->map->setMapTypeControl($mapTypeControl); + $this->map->setLanguage($language = 'fr'); - $this->assertSame($mapTypeControl, $this->map->getMapTypeControl()); - $this->assertTrue($this->map->getMapOption('mapTypeControl')); + $this->assertSame($language, $this->map->getLanguage()); } - public function testMapTypeControlWithMapTypeControlParameters() + public function testSetMapOptions() { - $mapTypeIds = array(MapTypeId::TERRAIN); - $controlPosition = ControlPosition::BOTTOM_CENTER; - $mapTypeControlStyle = MapTypeControlStyle::HORIZONTAL_BAR; + $this->map->setMapOptions($mapOptions = [$mapOption = 'clickableIcons' => $value = false]); + $this->map->setMapOptions($mapOptions); - $this->map->setMapTypeControl($mapTypeIds, $controlPosition, $mapTypeControlStyle); - - $this->assertSame($mapTypeIds, $this->map->getMapTypeControl()->getMapTypeIds()); - $this->assertSame($controlPosition, $this->map->getMapTypeControl()->getControlPosition()); - $this->assertSame($mapTypeControlStyle, $this->map->getMapTypeControl()->getMapTypeControlStyle()); - - $this->assertTrue($this->map->getMapOption('mapTypeControl')); + $this->assertTrue($this->map->hasMapOptions()); + $this->assertTrue($this->map->hasMapOption($mapOption)); + $this->assertSame($mapOptions, $this->map->getMapOptions()); + $this->assertSame($value, $this->map->getMapOption($mapOption)); } - public function testMapTypeControlWithNullValue() + public function testAddMapOptions() { - $this->map->setMapTypeControl($this->getMock('Ivory\GoogleMap\Controls\MapTypeControl')); - $this->map->setMapTypeControl(null); + $this->map->setMapOptions($firstMapOptions = ['clickableIcons' => false]); + $this->map->addMapOptions($secondMapOptions = ['disableDefaultUI' => true]); - $this->assertNull($this->map->getMapTypeControl()); - $this->assertFalse($this->map->hasMapOption('mapTypeControl')); + $this->assertTrue($this->map->hasMapOptions()); + $this->assertSame( + array_merge($firstMapOptions, $secondMapOptions), + $this->map->getMapOptions() + ); } - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The map type control setter arguments is invalid. - * The available prototypes are : - * - function setMapTypeControl(Ivory\GoogleMap\Controls\MapTypeControl $mapTypeControl = null) - * - function setMaptypeControl(array $mapTypeIds, string $controlPosition, string $mapTypeControlStyle) - */ - public function testMapTypeControlWithInvalidValue() + public function testAddMapOption() { - $this->map->setMapTypeControl('foo'); - } + $this->map->setMapOption($mapOption = 'clickableIcons', $value = false); - public function testOverviewMapControlWithOverviewMapControl() - { - $overviewMapControl = $this->getMock('Ivory\GoogleMap\Controls\OverviewMapControl'); - $this->map->setOverviewMapControl($overviewMapControl); - - $this->assertSame($overviewMapControl, $this->map->getOverviewMapControl()); - $this->assertTrue($this->map->getMapOption('overviewMapControl')); + $this->assertTrue($this->map->hasMapOptions()); + $this->assertTrue($this->map->hasMapOption($mapOption)); + $this->assertSame([$mapOption => $value], $this->map->getMapOptions()); + $this->assertSame($value, $this->map->getMapOption($mapOption)); } - public function testOverviewMapControlWithOverviewMapControlParameters() + public function testRemoveMapOption() { - $this->map->setOverviewMapControl(true); + $this->map->setMapOption($mapOption = 'clickableIcons', false); + $this->map->removeMapOption($mapOption); - $this->assertTrue($this->map->getOverviewMapControl()->isOpened()); - $this->assertTrue($this->map->getMapOption('overviewMapControl')); + $this->assertFalse($this->map->hasMapOptions()); + $this->assertFalse($this->map->hasMapOption($mapOption)); + $this->assertEmpty($this->map->getMapOptions()); + $this->assertNull($this->map->getMapOption($mapOption)); } - public function testOverviewMapControlWithNullValue() + public function testSetStylesheetOptions() { - $this->map->setOverviewMapControl($this->getMock('Ivory\GoogleMap\Controls\OverviewMapControl')); - $this->map->setOverviewMapControl(null); + $this->map->setStylesheetOptions($stylesheetOptions = [$stylesheetOption = 'border' => $value = '1px']); + $this->map->setStylesheetOptions($stylesheetOptions); - $this->assertNull($this->map->getOverviewMapControl()); - $this->assertFalse($this->map->hasMapOption('overviewMapControl')); - } + $this->assertTrue($this->map->hasStylesheetOptions()); + $this->assertTrue($this->map->hasStylesheetOption($stylesheetOption)); + $this->assertSame($stylesheetOptions, $this->map->getStylesheetOptions()); - /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The overview map control setter arguments is invalid. - * The available prototypes are : - * - function setOverviewMapControl(Ivory\GoogleMap\Controls\OverviewMapControl $overviewMapControl = null) - * - function setOverviewMapControl(boolean $opened) - */ - public function testOverviewMapControlWithInvalidValue() - { - $this->map->setOverviewMapControl('foo'); + $this->assertSame($value, $this->map->getStylesheetOption($stylesheetOption)); } - public function testPanControlWithPanControl() + public function testAddStylesheetOptions() { - $panControl = $this->getMock('Ivory\GoogleMap\Controls\PanControl'); - $this->map->setPanControl($panControl); + $this->map->setStylesheetOptions($firstStylesheetOptions = ['border' => '1px']); + $this->map->addStylesheetOptions($secondStylesheetOptions = ['margin' => '10px']); - $this->assertSame($panControl, $this->map->getPanControl()); - $this->assertTrue($this->map->getMapOption('panControl')); + $this->assertTrue($this->map->hasStylesheetOptions()); + $this->assertSame( + array_merge($firstStylesheetOptions, $secondStylesheetOptions), + $this->map->getStylesheetOptions() + ); } - public function testPanControlWithPanControlParameters() + public function testAddStylesheetOption() { - $this->map->setPanControl(ControlPosition::BOTTOM_CENTER); + $this->map->setStylesheetOption($stylesheetOption = 'border', $value = '1px'); - $this->assertSame(ControlPosition::BOTTOM_CENTER, $this->map->getPanControl()->getControlPosition()); - $this->assertTrue($this->map->getMapOption('panControl')); + $this->assertTrue($this->map->hasStylesheetOptions()); + $this->assertTrue($this->map->hasStylesheetOption($stylesheetOption)); + $this->assertSame([$stylesheetOption => $value], $this->map->getStylesheetOptions()); + $this->assertSame($value, $this->map->getStylesheetOption($stylesheetOption)); } - public function testPanControlWithNullValue() + public function testRemoveStylesheetOption() { - $this->map->setPanControl($this->getMock('Ivory\GoogleMap\Controls\PanControl')); - $this->map->setPanControl(null); + $this->map->setStylesheetOption($stylesheetOption = 'border', '1px'); + $this->map->removeStylesheetOption($stylesheetOption); - $this->assertNull($this->map->getPanControl()); - $this->assertFalse($this->map->hasMapOption('panControl')); + $this->assertFalse($this->map->hasStylesheetOptions()); + $this->assertFalse($this->map->hasStylesheetOption($stylesheetOption)); + $this->assertEmpty($this->map->getStylesheetOptions()); + $this->assertNull($this->map->getStylesheetOption($stylesheetOption)); } /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The pan control setter arguments is invalid. - * The available prototypes are : - * - function setPanControl(Ivory\GoogleMap\Controls\PanControl $panControl = null) - * - function setPanControl(string $controlPosition) + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate */ - public function testPanControlWithInvalidValue() - { - $this->map->setPanControl(true); - } - - public function testRotateControlWithRotateControl() + private function createCoordinateMock() { - $rotateControl = $this->getMock('Ivory\GoogleMap\Controls\RotateControl'); - $this->map->setRotateControl($rotateControl); - - $this->assertSame($rotateControl, $this->map->getRotateControl()); - $this->assertTrue($this->map->getMapOption('rotateControl')); - } - - public function testRotateControlWithRotateControlParameters() - { - $this->map->setRotateControl(ControlPosition::BOTTOM_CENTER); - - $this->assertSame(ControlPosition::BOTTOM_CENTER, $this->map->getRotateControl()->getControlPosition()); - $this->assertTrue($this->map->getMapOption('rotateControl')); - } - - public function testRotateControlWithNullValue() - { - $this->map->setRotateControl($this->getMock('Ivory\GoogleMap\Controls\RotateControl')); - $this->map->setRotateControl(null); - - $this->assertNull($this->map->getRotateControl()); - $this->assertFalse($this->map->hasMapOption('rotateControl')); + return $this->createMock(Coordinate::class); } /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The rotate control setter arguments is invalid. - * The available prototypes are : - * - function setRotateControl(Ivory\GoogleMap\Controls\RotateControl $rotateControl = null) - * - function setRotateControl(string $controlPosition) + * @return \PHPUnit_Framework_MockObject_MockObject|Bound */ - public function testRotateControlWithInvalidValue() - { - $this->map->setRotateControl(true); - } - - public function testScaleControlWithScaleControl() - { - $scaleControl = $this->getMock('Ivory\GoogleMap\Controls\ScaleControl'); - $this->map->setScaleControl($scaleControl); - - $this->assertSame($scaleControl, $this->map->getScaleControl()); - $this->assertTrue($this->map->getMapOption('scaleControl')); - } - - public function testScaleControlWithScaleControlParameters() - { - $controlPosition = ControlPosition::BOTTOM_CENTER; - $scaleControlStyle = ScaleControlStyle::DEFAULT_; - - $this->map->setScaleControl($controlPosition, $scaleControlStyle); - - $this->assertSame($controlPosition, $this->map->getScaleControl()->getControlPosition()); - $this->assertSame($scaleControlStyle, $this->map->getScaleControl()->getScaleControlStyle()); - - $this->assertTrue($this->map->getMapOption('scaleControl')); - } - - public function testScaleControlWithNullValue() + private function createBoundMock() { - $this->map->setScaleControl($this->getMock('Ivory\GoogleMap\Controls\ScaleControl')); - $this->map->setScaleControl(null); - - $this->assertNull($this->map->getScaleControl()); - $this->assertFalse($this->map->hasMapOption('scaleControl')); + return $this->createMock(Bound::class); } /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The scale control setter arguments is invalid. - * The available prototypes are : - * - function setScaleControl(Ivory\GoogleMap\Controls\ScaleControl $scaleControl = null) - * - function setScaleControl(string $controlPosition, string $scaleControlStyle) + * @return \PHPUnit_Framework_MockObject_MockObject|ControlManager */ - public function testScaleControlWithInvalidValue() + private function createControlManagerMock() { - $this->map->setScaleControl(true); - } - - public function testStreetViewControlWithStreetViewControl() - { - $streetViewControl = $this->getMock('Ivory\GoogleMap\Controls\StreetViewControl'); - $this->map->setStreetViewControl($streetViewControl); - - $this->assertSame($streetViewControl, $this->map->getStreetViewControl()); - $this->assertTrue($this->map->getMapOption('streetViewControl')); - } - - public function testStreetViewControlWithStreetViewControlParameters() - { - $this->map->setStreetViewControl(ControlPosition::BOTTOM_CENTER); - - $this->assertSame(ControlPosition::BOTTOM_CENTER, $this->map->getStreetViewControl()->getControlPosition()); - $this->assertTrue($this->map->getMapOption('streetViewControl')); - } - - public function testStreetViewControlWithNullValue() - { - $this->map->setStreetViewControl($this->getMock('Ivory\GoogleMap\Controls\StreetViewControl')); - $this->map->setStreetViewControl(null); - - $this->assertNull($this->map->getStreetViewControl()); - $this->assertFalse($this->map->hasMapOption('streetViewControl')); + return $this->createMock(ControlManager::class); } /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The street view control setter arguments is invalid. - * The available prototypes are : - * - function setStreetViewControl(Ivory\GoogleMap\Controls\StreetViewControl $streetViewControl = null) - * - function setStreetViewControl(string $controlPosition) + * @return \PHPUnit_Framework_MockObject_MockObject|EventManager */ - public function testStreetViewControlWithInvalidValue() - { - $this->map->setStreetViewControl(true); - } - - public function testZoomControlWithZoomControl() + private function createEventManagerMock() { - $zoomControl = $this->getMock('Ivory\GoogleMap\Controls\ZoomControl'); - $this->map->setZoomControl($zoomControl); - - $this->assertSame($zoomControl, $this->map->getZoomControl()); - $this->assertTrue($this->map->getMapOption('zoomControl')); - } - - public function testZoomControlWithZoomControlParameters() - { - $controlPosition = ControlPosition::BOTTOM_CENTER; - $zoomControlStyle = ZoomControlStyle::LARGE; - - $this->map->setZoomControl($controlPosition, $zoomControlStyle); - - $this->assertSame($controlPosition, $this->map->getZoomControl()->getControlPosition()); - $this->assertSame($zoomControlStyle, $this->map->getZoomControl()->getZoomControlStyle()); - $this->assertTrue($this->map->getMapOption('zoomControl')); - } - - public function testZoomControlWithNullValue() - { - $this->map->setZoomControl($this->getMock('Ivory\GoogleMap\Controls\ZoomControl')); - $this->map->setZoomControl(null); - - $this->assertNull($this->map->getZoomControl()); - $this->assertFalse($this->map->hasMapOption('zoomControl')); + return $this->createMock(EventManager::class); } /** - * @expectedException \Ivory\GoogleMap\Exception\MapException - * @expectedExceptionMessage The zoom control setter arguments is invalid. - * The available prototypes are : - * - function setZoomControl(Ivory\GoogleMap\Controls\ZoomControl $zoomControl = null) - * - function setZoomControl(string $controlPosition, string $zoomControlStyle) + * @return \PHPUnit_Framework_MockObject_MockObject|LayerManager */ - public function testZoomControlWithInvalidValue() - { - $this->map->setZoomControl(true); - } - - public function testEventManager() - { - $eventManager = $this->getMock('Ivory\GoogleMap\Events\EventManager'); - $this->map->setEventManager($eventManager); - - $this->assertSame($eventManager, $this->map->getEventManager()); - } - - public function testMarkerCluster() - { - $markerCluster = $this->getMock('Ivory\GoogleMap\Overlays\MarkerCluster'); - $this->map->setMarkerCluster($markerCluster); - - $this->assertSame($markerCluster, $this->map->getMarkerCluster()); - } - - public function testMarkerWithAutoZoom() - { - $marker = $this->getMock('Ivory\GoogleMap\Overlays\Marker'); - $this->map->setAutoZoom(true); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->once()) - ->method('extend') - ->with($this->equalTo($marker)); - - $this->map->addMarker($marker); - - $this->assertSame(array($marker), $this->map->getMarkers()); - } - - public function testMarkerWithoutAutoZoom() - { - $marker = $this->getMock('Ivory\GoogleMap\Overlays\Marker'); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->never()) - ->method('extend'); - - $this->map->addMarker($marker); - - $this->assertSame(array($marker), $this->map->getMarkers()); - } - - public function testInfoWindowWithAutoZoom() - { - $infoWindow = $this->getMock('Ivory\GoogleMap\Overlays\InfoWindow'); - $this->map->setAutoZoom(true); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->once()) - ->method('extend') - ->with($this->equalTo($infoWindow)); - - $this->map->addInfoWindow($infoWindow); - - $this->assertSame(array($infoWindow), $this->map->getInfoWindows()); - } - - public function testInfoWindowWithoutAutoZoom() - { - $infoWindow = $this->getMock('Ivory\GoogleMap\Overlays\InfoWindow'); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->never()) - ->method('extend'); - - $this->map->addInfoWindow($infoWindow); - - $this->assertSame(array($infoWindow), $this->map->getInfoWindows()); - } - - public function testPolylineWithAutoZoom() + private function createLayerManagerMock() { - $polyline = $this->getMock('Ivory\GoogleMap\Overlays\Polyline'); - $this->map->setAutoZoom(true); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->once()) - ->method('extend') - ->with($this->equalTo($polyline)); - - $this->map->addPolyline($polyline); - - $this->assertSame(array($polyline), $this->map->getPolylines()); - } - - public function testPolylineWithoutAutoZoom() - { - $polyline = $this->getMock('Ivory\GoogleMap\Overlays\Polyline'); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->never()) - ->method('extend'); - - $this->map->addPolyline($polyline); - - $this->assertSame(array($polyline), $this->map->getPolylines()); - } - - public function testEncodedPolylineWithAutoZoom() - { - $encodedPolyline = $this->getMock('Ivory\GoogleMap\Overlays\EncodedPolyline'); - $this->map->setAutoZoom(true); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->once()) - ->method('extend') - ->with($this->equalTo($encodedPolyline)); - - $this->map->addEncodedPolyline($encodedPolyline); - - $this->assertSame(array($encodedPolyline), $this->map->getEncodedPolylines()); + return $this->createMock(LayerManager::class); } - public function testEncodedPolylineWithoutAutoZoom() - { - $encodedPolyline = $this->getMock('Ivory\GoogleMap\Overlays\EncodedPolyline'); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->never()) - ->method('extend'); - - $this->map->addEncodedPolyline($encodedPolyline); - - $this->assertSame(array($encodedPolyline), $this->map->getEncodedPolylines()); - } - - public function testPolygonWithAutoZoom() - { - $polygon = $this->getMock('Ivory\GoogleMap\Overlays\Polygon'); - $this->map->setAutoZoom(true); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->once()) - ->method('extend') - ->with($this->equalTo($polygon)); - - $this->map->addPolygon($polygon); - - $this->assertSame(array($polygon), $this->map->getPolygons()); - } - - public function testPolygonWithoutAutoZoom() - { - $polygon = $this->getMock('Ivory\GoogleMap\Overlays\Polygon'); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->never()) - ->method('extend'); - - $this->map->addPolygon($polygon); - - $this->assertSame(array($polygon), $this->map->getPolygons()); - } - - public function testRectangleWithAutoZoom() - { - $rectangle = $this->getMock('Ivory\GoogleMap\Overlays\Rectangle'); - $this->map->setAutoZoom(true); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->once()) - ->method('extend') - ->with($this->equalTo($rectangle)); - - $this->map->addRectangle($rectangle); - - $this->assertSame(array($rectangle), $this->map->getRectangles()); - } - - public function testRectangleWithoutAutoZoom() - { - $rectangle = $this->getMock('Ivory\GoogleMap\Overlays\Rectangle'); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->never()) - ->method('extend'); - - $this->map->addRectangle($rectangle); - - $this->assertSame(array($rectangle), $this->map->getRectangles()); - } - - public function testCircleWithAutoZoom() - { - $circle = $this->getMock('Ivory\GoogleMap\Overlays\Circle'); - $this->map->setAutoZoom(true); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->once()) - ->method('extend') - ->with($this->equalTo($circle)); - - $this->map->addCircle($circle); - - $this->assertSame(array($circle), $this->map->getCircles()); - } - - public function testCircleWithoutAutoZoom() - { - $circle = $this->getMock('Ivory\GoogleMap\Overlays\Circle'); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->never()) - ->method('extend'); - - $this->map->addCircle($circle); - - $this->assertSame(array($circle), $this->map->getCircles()); - } - - public function testGroundOverlayWithAutoZoom() - { - $groundOverlay = $this->getMock('Ivory\GoogleMap\Overlays\GroundOverlay'); - $this->map->setAutoZoom(true); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->once()) - ->method('extend') - ->with($this->equalTo($groundOverlay)); - - $this->map->addGroundOverlay($groundOverlay); - - $this->assertSame(array($groundOverlay), $this->map->getGroundOverlays()); - } - - public function testGroundOverlayWithoutAutoZoom() - { - $groundOverlay = $this->getMock('Ivory\GoogleMap\Overlays\GroundOverlay'); - - $this->setUpBound(); - $this->map->getBound() - ->expects($this->never()) - ->method('extend'); - - $this->map->addGroundOverlay($groundOverlay); - - $this->assertSame(array($groundOverlay), $this->map->getGroundOverlays()); - } - - public function testKmlLayer() - { - $kmlLayer = $this->getMock('Ivory\GoogleMap\Layers\KMLLayer'); - $this->map->addKMLLayer($kmlLayer); - - $this->assertSame(array($kmlLayer), $this->map->getKMLLayers()); - } - - public function testLibraries() - { - $this->map->setLibraries(array('foo')); - - $this->assertTrue($this->map->hasLibraries()); - $this->assertSame(array('foo'), $this->map->getLibraries()); - } - - public function testLanguage() + /** + * @return \PHPUnit_Framework_MockObject_MockObject|OverlayManager + */ + private function createOverlayManagerMock() { - $this->map->setLanguage('fr'); - - $this->assertSame('fr', $this->map->getLanguage()); + return $this->createMock(OverlayManager::class); } } diff --git a/tests/MapTypeIdTest.php b/tests/MapTypeIdTest.php deleted file mode 100644 index d92b723e..00000000 --- a/tests/MapTypeIdTest.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap; - -use Ivory\GoogleMap\MapTypeId; - -/** - * Map type ID test. - * - * @author GeLo - */ -class MapTypeIdTest extends \PHPUnit_Framework_TestCase -{ - public function testMapTypeIds() - { - $expected = array( - MapTypeId::HYBRID, - MapTypeId::ROADMAP, - MapTypeId::SATELLITE, - MapTypeId::TERRAIN - ); - - $this->assertSame($expected, MapTypeId::getMapTypeIds()); - } -} diff --git a/tests/Overlay/CircleTest.php b/tests/Overlay/CircleTest.php new file mode 100644 index 00000000..1dafa473 --- /dev/null +++ b/tests/Overlay/CircleTest.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Circle; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class CircleTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Ivory\GoogleMap\Overlay\Circle + */ + private $circle; + + /** + * @var Coordinate|\PHPUnit_Framework_MockObject_MockObject + */ + private $center; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->circle = new Circle($this->center = $this->createCoordinateMock()); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableInterface::class, $this->circle); + $this->assertInstanceOf(OptionsAwareInterface::class, $this->circle); + $this->assertInstanceOf(VariableAwareInterface::class, $this->circle); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('circle', $this->circle->getVariable()); + $this->assertSame($this->center, $this->circle->getCenter()); + $this->assertSame(1.0, $this->circle->getRadius()); + $this->assertFalse($this->circle->hasOptions()); + } + + public function testInitialState() + { + $this->circle = new Circle($this->center, $radius = 2.1, $options = ['foo' => 'bar']); + + $this->assertStringStartsWith('circle', $this->circle->getVariable()); + $this->assertSame($this->center, $this->circle->getCenter()); + $this->assertSame($radius, $this->circle->getRadius()); + $this->assertSame($options, $this->circle->getOptions()); + } + + public function testCenter() + { + $this->circle->setCenter($center = $this->createCoordinateMock()); + + $this->assertSame($center, $this->circle->getCenter()); + } + + public function testRadius() + { + $this->circle->setRadius($radius = 2.1); + + $this->assertSame($radius, $this->circle->getRadius()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } +} diff --git a/tests/Overlay/EncodedPolylineTest.php b/tests/Overlay/EncodedPolylineTest.php new file mode 100644 index 00000000..69604201 --- /dev/null +++ b/tests/Overlay/EncodedPolylineTest.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class EncodedPolylineTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EncodedPolyline + */ + private $encodedPolyline; + + /** + * @var string + */ + private $value; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->encodedPolyline = new EncodedPolyline($this->value = '_p~iF~ps|U_ulLnnqC_mqNvxq`@'); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableInterface::class, $this->encodedPolyline); + $this->assertInstanceOf(OptionsAwareInterface::class, $this->encodedPolyline); + $this->assertInstanceOf(VariableAwareInterface::class, $this->encodedPolyline); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('encoded_polyline', $this->encodedPolyline->getVariable()); + $this->assertSame($this->value, $this->encodedPolyline->getValue()); + $this->assertFalse($this->encodedPolyline->hasOptions()); + } + + public function testInitialState() + { + $this->encodedPolyline = new EncodedPolyline($this->value, $options = ['foo' => 'bar']); + + $this->assertStringStartsWith('encoded_polyline', $this->encodedPolyline->getVariable()); + $this->assertSame($this->value, $this->encodedPolyline->getValue()); + $this->assertSame($options, $this->encodedPolyline->getOptions()); + } + + public function testValue() + { + $this->encodedPolyline->setValue($value = 'foo'); + + $this->assertSame($value, $this->encodedPolyline->getValue()); + } +} diff --git a/tests/Overlay/GroundOverlayTest.php b/tests/Overlay/GroundOverlayTest.php new file mode 100644 index 00000000..19740c2c --- /dev/null +++ b/tests/Overlay/GroundOverlayTest.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Overlay\GroundOverlay; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class GroundOverlayTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var GroundOverlay + */ + private $groundOverlay; + + /** + * @var string + */ + private $url; + + /** + * @var Bound + */ + private $bound; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->groundOverlay = new GroundOverlay( + $this->url = 'https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', + $this->bound = $this->createBoundMock() + ); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableInterface::class, $this->groundOverlay); + $this->assertInstanceOf(OptionsAwareInterface::class, $this->groundOverlay); + $this->assertInstanceOf(VariableAwareInterface::class, $this->groundOverlay); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('ground_overlay', $this->groundOverlay->getVariable()); + $this->assertSame($this->url, $this->groundOverlay->getUrl()); + $this->assertSame($this->bound, $this->groundOverlay->getBound()); + $this->assertFalse($this->groundOverlay->hasOptions()); + } + + public function testInitialState() + { + $this->groundOverlay = new GroundOverlay($this->url, $this->bound, $options = ['foo' => 'bar']); + + $this->assertStringStartsWith('ground_overlay', $this->groundOverlay->getVariable()); + $this->assertSame($this->url, $this->groundOverlay->getUrl()); + $this->assertSame($this->bound, $this->groundOverlay->getBound()); + $this->assertSame($options, $this->groundOverlay->getOptions()); + } + + public function testUrl() + { + $this->groundOverlay->setUrl($url = 'foo'); + + $this->assertSame($url, $this->groundOverlay->getUrl()); + } + + public function testBound() + { + $this->groundOverlay->setBound($bound = $this->createBoundMock()); + + $this->assertSame($bound, $this->groundOverlay->getBound()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Overlay/IconTest.php b/tests/Overlay/IconTest.php new file mode 100644 index 00000000..b324b667 --- /dev/null +++ b/tests/Overlay/IconTest.php @@ -0,0 +1,157 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Point; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Overlay\Icon; + +/** + * @author GeLo + */ +class IconTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Ivory\GoogleMap\Overlay\Icon + */ + private $icon; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->icon = new Icon(); + } + + public function testDefaultState() + { + $this->assertSame('https://maps.gstatic.com/mapfiles/markers/marker.png', $this->icon->getUrl()); + $this->assertFalse($this->icon->hasAnchor()); + $this->assertNull($this->icon->getAnchor()); + $this->assertFalse($this->icon->hasOrigin()); + $this->assertNull($this->icon->getOrigin()); + $this->assertFalse($this->icon->hasScaledSize()); + $this->assertNull($this->icon->getScaledSize()); + $this->assertFalse($this->icon->hasSize()); + $this->assertNull($this->icon->getSize()); + } + + public function testInitialState() + { + $this->icon = new Icon( + $url = 'foo', + $anchor = $this->createPointMock(), + $origin = $this->createPointMock(), + $scaledSize = $this->createSizeMock(), + $size = $this->createSizeMock() + ); + + $this->assertSame($url, $this->icon->getUrl()); + $this->assertTrue($this->icon->hasAnchor()); + $this->assertSame($anchor, $this->icon->getAnchor()); + $this->assertTrue($this->icon->hasOrigin()); + $this->assertSame($origin, $this->icon->getOrigin()); + $this->assertTrue($this->icon->hasScaledSize()); + $this->assertSame($scaledSize, $this->icon->getScaledSize()); + $this->assertTrue($this->icon->hasSize()); + $this->assertSame($size, $this->icon->getSize()); + } + + public function testUrl() + { + $this->icon->setUrl($url = 'foo'); + + $this->assertSame($url, $this->icon->getUrl()); + } + + public function testAnchor() + { + $this->icon->setAnchor($point = $this->createPointMock()); + + $this->assertTrue($this->icon->hasAnchor()); + $this->assertSame($point, $this->icon->getAnchor()); + } + + public function testResetAnchor() + { + $this->icon->setAnchor($this->createPointMock()); + $this->icon->setAnchor(null); + + $this->assertFalse($this->icon->hasAnchor()); + $this->assertNull($this->icon->getAnchor()); + } + + public function testOrigin() + { + $this->icon->setOrigin($point = $this->createPointMock()); + + $this->assertSame($point, $this->icon->getOrigin()); + } + + public function testResetOrigin() + { + $this->icon->setOrigin($this->createPointMock()); + $this->icon->setOrigin(null); + + $this->assertFalse($this->icon->hasOrigin()); + $this->assertNull($this->icon->getOrigin()); + } + + public function testScaledSize() + { + $this->icon->setScaledSize($size = $this->createSizeMock()); + + $this->assertSame($size, $this->icon->getScaledSize()); + } + + public function testResetScaledSize() + { + $this->icon->setScaledSize($this->createSizeMock()); + $this->icon->setScaledSize(null); + + $this->assertFalse($this->icon->hasScaledSize()); + $this->assertNull($this->icon->getScaledSize()); + } + + public function testSize() + { + $this->icon->setSize($size = $this->createSizeMock()); + + $this->assertSame($size, $this->icon->getSize()); + } + + public function testResetSize() + { + $this->icon->setSize($this->createSizeMock()); + $this->icon->setSize(null); + + $this->assertFalse($this->icon->hasSize()); + $this->assertNull($this->icon->getSize()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Point + */ + private function createPointMock() + { + return $this->createMock(Point::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Size + */ + private function createSizeMock() + { + return $this->createMock(Size::class); + } +} diff --git a/tests/Overlay/InfoWindowTest.php b/tests/Overlay/InfoWindowTest.php new file mode 100644 index 00000000..ed77ac2d --- /dev/null +++ b/tests/Overlay/InfoWindowTest.php @@ -0,0 +1,167 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Base\Size; +use Ivory\GoogleMap\Event\MouseEvent; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\InfoWindowType; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class InfoWindowTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var InfoWindow + */ + private $infoWindow; + + /** + * @var string + */ + private $content; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->infoWindow = new InfoWindow($this->content = '

content

'); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableInterface::class, $this->infoWindow); + $this->assertInstanceOf(OptionsAwareInterface::class, $this->infoWindow); + $this->assertInstanceOf(VariableAwareInterface::class, $this->infoWindow); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('info_window', $this->infoWindow->getVariable()); + $this->assertSame($this->content, $this->infoWindow->getContent()); + $this->assertSame(InfoWindowType::DEFAULT_, $this->infoWindow->getType()); + $this->assertNull($this->infoWindow->getPosition()); + $this->assertFalse($this->infoWindow->hasPixelOffset()); + $this->assertFalse($this->infoWindow->isOpen()); + $this->assertTrue($this->infoWindow->isAutoOpen()); + $this->assertSame(MouseEvent::CLICK, $this->infoWindow->getOpenEvent()); + $this->assertTrue($this->infoWindow->isAutoClose()); + $this->assertFalse($this->infoWindow->hasOptions()); + } + + public function testInitialState() + { + $this->infoWindow = new InfoWindow( + $this->content, + $type = InfoWindowType::INFO_BOX, + $position = $this->createCoordinateMock() + ); + + $this->assertStringStartsWith('info_window', $this->infoWindow->getVariable()); + $this->assertSame($this->content, $this->infoWindow->getContent()); + $this->assertSame($type, $this->infoWindow->getType()); + $this->assertSame($position, $this->infoWindow->getPosition()); + $this->assertFalse($this->infoWindow->hasPixelOffset()); + $this->assertFalse($this->infoWindow->isOpen()); + $this->assertTrue($this->infoWindow->isAutoOpen()); + $this->assertSame(MouseEvent::CLICK, $this->infoWindow->getOpenEvent()); + $this->assertTrue($this->infoWindow->isAutoClose()); + $this->assertFalse($this->infoWindow->hasOptions()); + } + + public function testContent() + { + $this->infoWindow->setContent($content = 'foo'); + + $this->assertSame($content, $this->infoWindow->getContent()); + } + + public function testPosition() + { + $this->infoWindow->setPosition($position = $this->createCoordinateMock()); + + $this->assertSame($position, $this->infoWindow->getPosition()); + } + + public function testResetPosition() + { + $this->infoWindow->setPosition($this->createCoordinateMock()); + $this->infoWindow->setPosition(null); + + $this->assertFalse($this->infoWindow->hasPosition()); + } + + public function testPixedOffset() + { + $this->infoWindow->setPixelOffset($size = $this->createSizeMock()); + + $this->assertSame($size, $this->infoWindow->getPixelOffset()); + } + + public function testResetPixedOffset() + { + $this->infoWindow->setPixelOffset($this->createSizeMock()); + $this->infoWindow->setPixelOffset(null); + + $this->assertFalse($this->infoWindow->hasPixelOffset()); + } + + public function testOpen() + { + $this->infoWindow->setOpen(true); + + $this->assertTrue($this->infoWindow->isOpen()); + } + + public function testAutoOpen() + { + $this->infoWindow->setAutoOpen(false); + + $this->assertFalse($this->infoWindow->isAutoOpen()); + } + + public function testOpenEvent() + { + $this->infoWindow->setOpenEvent($openEvent = MouseEvent::MOUSEDOWN); + + $this->assertSame($openEvent, $this->infoWindow->getOpenEvent()); + } + + public function testAutoClose() + { + $this->infoWindow->setAutoClose(false); + + $this->assertFalse($this->infoWindow->isAutoClose()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Size + */ + private function createSizeMock() + { + return $this->createMock(Size::class); + } +} diff --git a/tests/Overlay/MarkerClusterTest.php b/tests/Overlay/MarkerClusterTest.php new file mode 100644 index 00000000..2236021a --- /dev/null +++ b/tests/Overlay/MarkerClusterTest.php @@ -0,0 +1,288 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\MarkerCluster; +use Ivory\GoogleMap\Overlay\MarkerClusterType; +use Ivory\GoogleMap\Overlay\OverlayManager; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class MarkerClusterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MarkerCluster + */ + private $markerCluster; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|OverlayManager + */ + private $overlayManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|Map + */ + private $map; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private $bound; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->bound = $this->createBoundMock(); + $this->map = $this->createMapMock($this->bound); + $this->overlayManager = $this->createOverlayManagerMock($this->map); + + $this->markerCluster = new MarkerCluster(); + $this->markerCluster->setOverlayManager($this->overlayManager); + } + + public function testInheritance() + { + $this->assertInstanceOf(OptionsAwareInterface::class, $this->markerCluster); + $this->assertInstanceOf(VariableAwareInterface::class, $this->markerCluster); + } + + public function testDefaultState() + { + $this->markerCluster = new MarkerCluster(); + + $this->assertStringStartsWith('marker_cluster', $this->markerCluster->getVariable()); + $this->assertFalse($this->markerCluster->hasOverlayManager()); + $this->assertNull($this->markerCluster->getOverlayManager()); + $this->assertSame(MarkerClusterType::DEFAULT_, $this->markerCluster->getType()); + $this->assertFalse($this->markerCluster->hasMarkers()); + $this->assertEmpty($this->markerCluster->getMarkers()); + $this->assertFalse($this->markerCluster->hasOptions()); + } + + public function testOverlayManager() + { + $overlayManager = $this->createOverlayManagerMock(); + $overlayManager + ->expects($this->once()) + ->method('getMarkerCluster') + ->will($this->returnValue(null)); + + $overlayManager + ->expects($this->once()) + ->method('setMarkerCluster') + ->with($this->identicalTo($this->markerCluster)); + + $this->markerCluster->setOverlayManager($overlayManager); + + $this->assertTrue($this->markerCluster->hasOverlayManager()); + $this->assertSame($overlayManager, $this->markerCluster->getOverlayManager()); + } + + public function testType() + { + $this->markerCluster->setType($type = MarkerClusterType::MARKER_CLUSTERER); + + $this->assertSame($type, $this->markerCluster->getType()); + } + + public function testSetMarkers() + { + $this->markerCluster->setMarkers($markers = [$marker = $this->createMarkerMock()]); + $this->markerCluster->setMarkers($markers); + + $this->assertTrue($this->markerCluster->hasMarkers()); + $this->assertTrue($this->markerCluster->hasMarker($marker)); + $this->assertSame($markers, $this->markerCluster->getMarkers()); + } + + public function testSetMarkersWithAutoZoom() + { + $this->map + ->expects($this->exactly(3)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->with($this->identicalTo($marker = $this->createMarkerMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($marker)); + + $this->markerCluster->setOverlayManager($this->overlayManager); + $this->markerCluster->setMarkers($markers = [$marker]); + $this->markerCluster->setMarkers($markers); + + $this->assertTrue($this->markerCluster->hasMarkers()); + $this->assertTrue($this->markerCluster->hasMarker($marker)); + $this->assertSame($markers, $this->markerCluster->getMarkers()); + } + + public function testAddMarkers() + { + $this->markerCluster->setMarkers($firstMarkers = [$this->createMarkerMock()]); + $this->markerCluster->addMarkers($secondMarkers = [$this->createMarkerMock()]); + + $this->assertTrue($this->markerCluster->hasMarkers()); + $this->assertSame(array_merge($firstMarkers, $secondMarkers), $this->markerCluster->getMarkers()); + } + + public function testAddMarkersWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->withConsecutive( + [$firstMarker = $this->createMarkerMock()], + [$secondMarker = $this->createMarkerMock()] + ); + + $this->markerCluster->setMarkers($firstMarkers = [$firstMarker]); + $this->markerCluster->addMarkers($secondMarkers = [$secondMarker]); + + $this->assertTrue($this->markerCluster->hasMarkers()); + $this->assertSame(array_merge($firstMarkers, $secondMarkers), $this->markerCluster->getMarkers()); + } + + public function testAddMarker() + { + $this->markerCluster->addMarker($marker = $this->createMarkerMock()); + + $this->assertTrue($this->markerCluster->hasMarkers()); + $this->assertTrue($this->markerCluster->hasMarker($marker)); + $this->assertSame([$marker], $this->markerCluster->getMarkers()); + } + + public function testAddMarkerWithAutoZoom() + { + $this->map + ->expects($this->once()) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($marker = $this->createMarkerMock())); + + $this->markerCluster->addMarker($marker); + + $this->assertTrue($this->markerCluster->hasMarkers()); + $this->assertTrue($this->markerCluster->hasMarker($marker)); + $this->assertSame([$marker], $this->markerCluster->getMarkers()); + } + + public function testRemoveMarker() + { + $this->markerCluster->addMarker($marker = $this->createMarkerMock()); + $this->markerCluster->removeMarker($marker); + + $this->assertFalse($this->markerCluster->hasMarkers()); + $this->assertFalse($this->markerCluster->hasMarker($marker)); + $this->assertEmpty($this->markerCluster->getMarkers()); + } + + public function testRemoveMarkerWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($marker = $this->createMarkerMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($marker)); + + $this->markerCluster->addMarker($marker); + $this->markerCluster->removeMarker($marker); + + $this->assertFalse($this->markerCluster->hasMarkers()); + $this->assertFalse($this->markerCluster->hasMarker($marker)); + $this->assertEmpty($this->markerCluster->getMarkers()); + } + + /** + * @param Map|null $map + * + * @return \PHPUnit_Framework_MockObject_MockObject|OverlayManager + */ + private function createOverlayManagerMock(Map $map = null) + { + $overlayManager = $this->createMock(OverlayManager::class); + $overlayManager + ->expects($this->any()) + ->method('hasMap') + ->will($this->returnValue($map !== null)); + + $overlayManager + ->expects($this->any()) + ->method('getMap') + ->will($this->returnValue($map)); + + return $overlayManager; + } + + /** + * @param Bound|null $bound + * + * @return \PHPUnit_Framework_MockObject_MockObject|Map + */ + private function createMapMock(Bound $bound = null) + { + $map = $this->createMock(Map::class); + $map + ->expects($this->any()) + ->method('getBound') + ->will($this->returnValue($bound ?: $this->createBoundMock())); + + return $map; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Marker + */ + private function createMarkerMock() + { + return $this->createMock(Marker::class); + } +} diff --git a/tests/Overlay/MarkerShapeTest.php b/tests/Overlay/MarkerShapeTest.php new file mode 100644 index 00000000..e0f55bed --- /dev/null +++ b/tests/Overlay/MarkerShapeTest.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Overlay\MarkerShapeType; + +/** + * @author GeLo + */ +class MarkerShapeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MarkerShape + */ + private $markerShape; + + /** + * @var string + */ + private $type; + + /** + * @var float[] + */ + private $coordinates; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->markerShape = new MarkerShape( + $this->type = MarkerShapeType::CIRCLE, + $this->coordinates = [1.2, 2.3, 3.2] + ); + } + + public function testDefaultState() + { + $this->assertSame($this->type, $this->markerShape->getType()); + $this->assertTrue($this->markerShape->hasCoordinates()); + $this->assertSame($this->coordinates, $this->markerShape->getCoordinates()); + } + + /** + * @param string $type + * @param float[] $coordinates + * + * @dataProvider coordinatesProvider + */ + public function testCoordinates($type, array $coordinates) + { + $this->markerShape->setType($type); + $this->markerShape->setCoordinates($coordinates); + + $this->assertSame($type, $this->markerShape->getType()); + $this->assertTrue($this->markerShape->hasCoordinates()); + $this->assertSame($coordinates, $this->markerShape->getCoordinates()); + + foreach ($coordinates as $coordinate) { + $this->assertTrue($this->markerShape->hasCoordinate($coordinate)); + } + } + + /** + * @return mixed[][] + */ + public function coordinatesProvider() + { + return [ + [MarkerShapeType::RECTANGLE, [1.2, 2.3]], + [MarkerShapeType::CIRCLE, [1.2, 2.3, 3.3]], + [MarkerShapeType::POLY, [1.2, 2.3, 3.4, 4.5, 5.5, 6.7]], + ]; + } +} diff --git a/tests/Overlay/MarkerTest.php b/tests/Overlay/MarkerTest.php new file mode 100644 index 00000000..63ff4d7b --- /dev/null +++ b/tests/Overlay/MarkerTest.php @@ -0,0 +1,198 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\Animation; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Overlay\Icon; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\MarkerShape; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class MarkerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Marker + */ + private $marker; + + /** + * @var Coordinate|\PHPUnit_Framework_MockObject_MockObject + */ + private $position; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->marker = new Marker($this->position = $this->createCoordinateMock()); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableInterface::class, $this->marker); + $this->assertInstanceOf(OptionsAwareInterface::class, $this->marker); + $this->assertInstanceOf(VariableAwareInterface::class, $this->marker); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('marker', $this->marker->getVariable()); + $this->assertSame($this->position, $this->marker->getPosition()); + $this->assertFalse($this->marker->hasAnimation()); + $this->assertNull($this->marker->getAnimation()); + $this->assertFalse($this->marker->hasIcon()); + $this->assertNull($this->marker->getIcon()); + $this->assertFalse($this->marker->hasShape()); + $this->assertNull($this->marker->getShape()); + $this->assertFalse($this->marker->hasInfoWindow()); + $this->assertNull($this->marker->getInfoWindow()); + $this->assertFalse($this->marker->hasOptions()); + } + + public function testInitialState() + { + $this->marker = new Marker( + $position = $this->createCoordinateMock(), + $animation = Animation::BOUNCE, + $icon = $this->createIconMock(), + $shape = $this->createMarkerShapeMock(), + $options = ['foo' => 'bar'] + ); + + $this->assertStringStartsWith('marker', $this->marker->getVariable()); + $this->assertSame($position, $this->marker->getPosition()); + $this->assertTrue($this->marker->hasAnimation()); + $this->assertSame($animation, $this->marker->getAnimation()); + $this->assertTrue($this->marker->hasIcon()); + $this->assertSame($icon, $this->marker->getIcon()); + $this->assertTrue($this->marker->hasShape()); + $this->assertSame($shape, $this->marker->getShape()); + $this->assertFalse($this->marker->hasInfoWindow()); + $this->assertNull($this->marker->getInfoWindow()); + $this->assertSame($options, $this->marker->getOptions()); + } + + public function testPosition() + { + $this->marker->setPosition($position = $this->createCoordinateMock()); + + $this->assertSame($position, $this->marker->getPosition()); + } + + public function testAnimation() + { + $this->marker->setAnimation($animation = Animation::DROP); + + $this->assertTrue($this->marker->hasAnimation()); + $this->assertSame($animation, $this->marker->getAnimation()); + } + + public function testResetAnimation() + { + $this->marker->setAnimation(Animation::DROP); + $this->marker->setAnimation(null); + + $this->assertFalse($this->marker->hasAnimation()); + $this->assertNull($this->marker->getAnimation()); + } + + public function testIcon() + { + $this->marker->setIcon($icon = $this->createIconMock()); + + $this->assertTrue($this->marker->hasIcon()); + $this->assertSame($icon, $this->marker->getIcon()); + } + + public function testResetIcon() + { + $this->marker->setIcon($this->createIconMock()); + $this->marker->setIcon(null); + + $this->assertFalse($this->marker->hasIcon()); + $this->assertNull($this->marker->getIcon()); + } + + public function testShape() + { + $this->marker->setShape($shape = $this->createMarkerShapeMock()); + + $this->assertTrue($this->marker->hasShape()); + $this->assertSame($shape, $this->marker->getShape()); + } + + public function testResetShape() + { + $this->marker->setShape($this->createMarkerShapeMock()); + $this->marker->setShape(null); + + $this->assertFalse($this->marker->hasShape()); + $this->assertNull($this->marker->getShape()); + } + + public function testInfoWindow() + { + $this->marker->setInfoWindow($infoWindow = $this->createInfoWindowMock()); + + $this->assertTrue($this->marker->hasInfoWindow()); + $this->assertSame($infoWindow, $this->marker->getInfoWindow()); + } + + public function testResetInfoWindow() + { + $this->marker->setInfoWindow($this->createInfoWindowMock()); + $this->marker->setInfoWindow(null); + + $this->assertFalse($this->marker->hasInfoWindow()); + $this->assertNull($this->marker->getInfoWindow()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Icon + */ + private function createIconMock() + { + return $this->createMock(Icon::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MarkerShape + */ + private function createMarkerShapeMock() + { + return $this->createMock(MarkerShape::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|InfoWindow + */ + private function createInfoWindowMock() + { + return $this->createMock(InfoWindow::class); + } +} diff --git a/tests/Overlay/OverlayManagerTest.php b/tests/Overlay/OverlayManagerTest.php new file mode 100644 index 00000000..935e4533 --- /dev/null +++ b/tests/Overlay/OverlayManagerTest.php @@ -0,0 +1,1196 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Map; +use Ivory\GoogleMap\Overlay\Circle; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\GoogleMap\Overlay\GroundOverlay; +use Ivory\GoogleMap\Overlay\InfoWindow; +use Ivory\GoogleMap\Overlay\Marker; +use Ivory\GoogleMap\Overlay\MarkerCluster; +use Ivory\GoogleMap\Overlay\OverlayManager; +use Ivory\GoogleMap\Overlay\Polygon; +use Ivory\GoogleMap\Overlay\Polyline; +use Ivory\GoogleMap\Overlay\Rectangle; + +/** + * @author GeLo + */ +class OverlayManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var OverlayManager + */ + private $overlayManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|Map + */ + private $map; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private $bound; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->bound = $this->createBoundMock(); + $this->map = $this->createMapMock($this->bound); + + $this->overlayManager = new OverlayManager(); + $this->overlayManager->setMap($this->map); + } + + public function testDefaultState() + { + $this->overlayManager = new OverlayManager(); + + $this->assertFalse($this->overlayManager->hasMap()); + $this->assertNull($this->overlayManager->getMap()); + $this->assertInstanceOf(MarkerCluster::class, $this->overlayManager->getMarkerCluster()); + $this->assertFalse($this->overlayManager->hasMarkers()); + $this->assertEmpty($this->overlayManager->getMarkers()); + } + + public function testMap() + { + $map = $this->createMapMock(); + $map + ->expects($this->once()) + ->method('getOverlayManager') + ->will($this->returnValue(null)); + + $map + ->expects($this->once()) + ->method('setOverlayManager') + ->with($this->identicalTo($this->overlayManager)); + + $this->overlayManager->setMap($map); + + $this->assertTrue($this->overlayManager->hasMap()); + $this->assertSame($map, $this->overlayManager->getMap()); + } + + public function testMarkerCluster() + { + $this->overlayManager->setMarkerCluster($markerCluster = $this->createMarkerClusterMock()); + + $this->assertSame($markerCluster, $this->overlayManager->getMarkerCluster()); + } + + public function testHasMarkers() + { + $markerCluster = $this->createMarkerClusterMock(); + $markerCluster + ->expects($this->once()) + ->method('hasMarkers') + ->will($this->returnValue(true)); + + $this->overlayManager->setMarkerCluster($markerCluster); + + $this->assertTrue($this->overlayManager->hasMarkers()); + } + + public function testGetMarkers() + { + $markerCluster = $this->createMarkerClusterMock(); + $markerCluster + ->expects($this->once()) + ->method('getMarkers') + ->will($this->returnValue($markers = [$this->createMarkerMock()])); + + $this->overlayManager->setMarkerCluster($markerCluster); + + $this->assertSame($markers, $this->overlayManager->getMarkers()); + } + + public function testSetMarkers() + { + $markerCluster = $this->createMarkerClusterMock(); + $markerCluster + ->expects($this->once()) + ->method('setMarkers') + ->with($this->identicalTo($markers = [$this->createMarkerMock()])); + + $this->overlayManager->setMarkerCluster($markerCluster); + $this->overlayManager->setMarkers($markers); + } + + public function testAddMarkers() + { + $markerCluster = $this->createMarkerClusterMock(); + $markerCluster + ->expects($this->once()) + ->method('addMarkers') + ->with($this->identicalTo($markers = [$this->createMarkerMock()])); + + $this->overlayManager->setMarkerCluster($markerCluster); + $this->overlayManager->addMarkers($markers); + } + + public function testHasMarker() + { + $markerCluster = $this->createMarkerClusterMock(); + $markerCluster + ->expects($this->once()) + ->method('hasMarker') + ->with($this->identicalTo($marker = $this->createMarkerMock())) + ->will($this->returnValue(true)); + + $this->overlayManager->setMarkerCluster($markerCluster); + + $this->assertTrue($this->overlayManager->hasMarker($marker)); + } + + public function testAddMarker() + { + $markerCluster = $this->createMarkerClusterMock(); + $markerCluster + ->expects($this->once()) + ->method('addMarker') + ->with($this->identicalTo($marker = $this->createMarkerMock())); + + $this->overlayManager->setMarkerCluster($markerCluster); + $this->overlayManager->addMarker($marker); + } + + public function testRemoveMarker() + { + $markerCluster = $this->createMarkerClusterMock(); + $markerCluster + ->expects($this->once()) + ->method('removeMarker') + ->with($this->identicalTo($marker = $this->createMarkerMock())); + + $this->overlayManager->setMarkerCluster($markerCluster); + $this->overlayManager->removeMarker($marker); + } + + public function testSetInfoWindows() + { + $this->overlayManager->setInfoWindows($infoWindows = [$infoWindow = $this->createInfoWindowMock()]); + $this->overlayManager->setInfoWindows($infoWindows); + + $this->assertTrue($this->overlayManager->hasInfoWindows()); + $this->assertTrue($this->overlayManager->hasInfoWindow($infoWindow)); + $this->assertSame($infoWindows, $this->overlayManager->getInfoWindows()); + } + + public function testSetInfoWindowsWithAutoZoom() + { + $this->map + ->expects($this->exactly(3)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->with($this->identicalTo($infoWindow = $this->createInfoWindowMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($infoWindow)); + + $this->overlayManager->setInfoWindows($infoWindows = [$infoWindow]); + $this->overlayManager->setInfoWindows($infoWindows); + + $this->assertTrue($this->overlayManager->hasInfoWindows()); + $this->assertTrue($this->overlayManager->hasInfoWindow($infoWindow)); + $this->assertSame($infoWindows, $this->overlayManager->getInfoWindows()); + } + + public function testAddInfoWindows() + { + $this->overlayManager->setInfoWindows($firstInfoWindows = [$this->createInfoWindowMock()]); + $this->overlayManager->addInfoWindows($secondInfoWindows = [$this->createInfoWindowMock()]); + + $this->assertTrue($this->overlayManager->hasInfoWindows()); + $this->assertSame(array_merge($firstInfoWindows, $secondInfoWindows), $this->overlayManager->getInfoWindows()); + } + + public function testAddInfoWindowsWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->withConsecutive( + [$firstInfoWindow = $this->createInfoWindowMock()], + [$secondInfoWindow = $this->createInfoWindowMock()] + ); + + $this->overlayManager->setInfoWindows($firstInfoWindows = [$firstInfoWindow]); + $this->overlayManager->addInfoWindows($secondInfoWindows = [$secondInfoWindow]); + + $this->assertTrue($this->overlayManager->hasInfoWindows()); + $this->assertSame(array_merge($firstInfoWindows, $secondInfoWindows), $this->overlayManager->getInfoWindows()); + } + + public function testAddInfoWindow() + { + $this->overlayManager->addInfoWindow($infoWindow = $this->createInfoWindowMock()); + + $this->assertTrue($this->overlayManager->hasInfoWindows()); + $this->assertTrue($this->overlayManager->hasInfoWindow($infoWindow)); + $this->assertSame([$infoWindow], $this->overlayManager->getInfoWindows()); + } + + public function testAddInfoWindowWithAutoZoom() + { + $this->map + ->expects($this->once()) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($infoWindow = $this->createInfoWindowMock())); + + $this->overlayManager->addInfoWindow($infoWindow); + + $this->assertTrue($this->overlayManager->hasInfoWindows()); + $this->assertTrue($this->overlayManager->hasInfoWindow($infoWindow)); + $this->assertSame([$infoWindow], $this->overlayManager->getInfoWindows()); + } + + public function testRemoveInfoWindow() + { + $this->overlayManager->addInfoWindow($infoWindow = $this->createInfoWindowMock()); + $this->overlayManager->removeInfoWindow($infoWindow); + + $this->assertFalse($this->overlayManager->hasInfoWindows()); + $this->assertFalse($this->overlayManager->hasInfoWindow($infoWindow)); + $this->assertEmpty($this->overlayManager->getInfoWindows()); + } + + public function testRemoveInfoWindowWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($infoWindow = $this->createInfoWindowMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($infoWindow)); + + $this->overlayManager->addInfoWindow($infoWindow); + $this->overlayManager->removeInfoWindow($infoWindow); + + $this->assertFalse($this->overlayManager->hasInfoWindows()); + $this->assertFalse($this->overlayManager->hasInfoWindow($infoWindow)); + $this->assertEmpty($this->overlayManager->getInfoWindows()); + } + + public function testSetPolylines() + { + $this->overlayManager->setPolylines($polylines = [$polyline = $this->createPolylineMock()]); + $this->overlayManager->setPolylines($polylines); + + $this->assertTrue($this->overlayManager->hasPolylines()); + $this->assertTrue($this->overlayManager->hasPolyline($polyline)); + $this->assertSame($polylines, $this->overlayManager->getPolylines()); + } + + public function testSetPolylinesWithAutoZoom() + { + $this->map + ->expects($this->exactly(3)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->with($this->identicalTo($polyline = $this->createPolylineMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($polyline)); + + $this->overlayManager->setPolylines($polylines = [$polyline]); + $this->overlayManager->setPolylines($polylines); + + $this->assertTrue($this->overlayManager->hasPolylines()); + $this->assertTrue($this->overlayManager->hasPolyline($polyline)); + $this->assertSame($polylines, $this->overlayManager->getPolylines()); + } + + public function testAddPolylines() + { + $this->overlayManager->setPolylines($firstPolylines = [$this->createPolylineMock()]); + $this->overlayManager->addPolylines($secondPolylines = [$this->createPolylineMock()]); + + $this->assertTrue($this->overlayManager->hasPolylines()); + $this->assertSame(array_merge($firstPolylines, $secondPolylines), $this->overlayManager->getPolylines()); + } + + public function testAddPolylinesWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->withConsecutive( + [$firstPolyline = $this->createPolylineMock()], + [$secondPolyline = $this->createPolylineMock()] + ); + + $this->overlayManager->setPolylines($firstPolylines = [$firstPolyline]); + $this->overlayManager->addPolylines($secondPolylines = [$secondPolyline]); + + $this->assertTrue($this->overlayManager->hasPolylines()); + $this->assertSame(array_merge($firstPolylines, $secondPolylines), $this->overlayManager->getPolylines()); + } + + public function testAddPolyline() + { + $this->overlayManager->addPolyline($polyline = $this->createPolylineMock()); + + $this->assertTrue($this->overlayManager->hasPolylines()); + $this->assertTrue($this->overlayManager->hasPolyline($polyline)); + $this->assertSame([$polyline], $this->overlayManager->getPolylines()); + } + + public function testAddPolylineWithAutoZoom() + { + $this->map + ->expects($this->once()) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($polyline = $this->createPolylineMock())); + + $this->overlayManager->addPolyline($polyline); + + $this->assertTrue($this->overlayManager->hasPolylines()); + $this->assertTrue($this->overlayManager->hasPolyline($polyline)); + $this->assertSame([$polyline], $this->overlayManager->getPolylines()); + } + + public function testRemovePolyline() + { + $this->overlayManager->addPolyline($polyline = $this->createPolylineMock()); + $this->overlayManager->removePolyline($polyline); + + $this->assertFalse($this->overlayManager->hasPolylines()); + $this->assertFalse($this->overlayManager->hasPolyline($polyline)); + $this->assertEmpty($this->overlayManager->getPolylines()); + } + + public function testRemovePolylineWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($polyline = $this->createPolylineMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($polyline)); + + $this->overlayManager->addPolyline($polyline); + $this->overlayManager->removePolyline($polyline); + + $this->assertFalse($this->overlayManager->hasPolylines()); + $this->assertFalse($this->overlayManager->hasPolyline($polyline)); + $this->assertEmpty($this->overlayManager->getPolylines()); + } + + public function testSetEncodedPolylines() + { + $encodedPolylines = [$encodedPolyline = $this->createEncodedPolylineMock()]; + + $this->overlayManager->setEncodedPolylines($encodedPolylines); + $this->overlayManager->setEncodedPolylines($encodedPolylines); + + $this->assertTrue($this->overlayManager->hasEncodedPolylines()); + $this->assertTrue($this->overlayManager->hasEncodedPolyline($encodedPolyline)); + $this->assertSame($encodedPolylines, $this->overlayManager->getEncodedPolylines()); + } + + public function testSetEncodedPolylinesWithAutoZoom() + { + $this->map + ->expects($this->exactly(3)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->with($this->identicalTo($encodedPolyline = $this->createEncodedPolylineMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($encodedPolyline)); + + $this->overlayManager->setEncodedPolylines($encodedPolylines = [$encodedPolyline]); + $this->overlayManager->setEncodedPolylines($encodedPolylines); + + $this->assertTrue($this->overlayManager->hasEncodedPolylines()); + $this->assertTrue($this->overlayManager->hasEncodedPolyline($encodedPolyline)); + $this->assertSame($encodedPolylines, $this->overlayManager->getEncodedPolylines()); + } + + public function testAddEncodedPolylines() + { + $this->overlayManager->setEncodedPolylines($firstEncodedPolylines = [$this->createEncodedPolylineMock()]); + $this->overlayManager->addEncodedPolylines($secondEncodedPolylines = [$this->createEncodedPolylineMock()]); + + $this->assertTrue($this->overlayManager->hasEncodedPolylines()); + $this->assertSame( + array_merge($firstEncodedPolylines, $secondEncodedPolylines), + $this->overlayManager->getEncodedPolylines() + ); + } + + public function testAddEncodedPolylinesWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->withConsecutive( + [$firstEncodedPolyline = $this->createEncodedPolylineMock()], + [$secondEncodedPolyline = $this->createEncodedPolylineMock()] + ); + + $this->overlayManager->setEncodedPolylines($firstEncodedPolylines = [$firstEncodedPolyline]); + $this->overlayManager->addEncodedPolylines($secondEncodedPolylines = [$secondEncodedPolyline]); + + $this->assertTrue($this->overlayManager->hasEncodedPolylines()); + $this->assertSame( + array_merge($firstEncodedPolylines, $secondEncodedPolylines), + $this->overlayManager->getEncodedPolylines() + ); + } + + public function testAddEncodedPolyline() + { + $this->overlayManager->addEncodedPolyline($encodedPolyline = $this->createEncodedPolylineMock()); + + $this->assertTrue($this->overlayManager->hasEncodedPolylines()); + $this->assertTrue($this->overlayManager->hasEncodedPolyline($encodedPolyline)); + $this->assertSame([$encodedPolyline], $this->overlayManager->getEncodedPolylines()); + } + + public function testAddEncodedPolylineWithAutoZoom() + { + $this->map + ->expects($this->once()) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($encodedPolyline = $this->createEncodedPolylineMock())); + + $this->overlayManager->addEncodedPolyline($encodedPolyline); + + $this->assertTrue($this->overlayManager->hasEncodedPolylines()); + $this->assertTrue($this->overlayManager->hasEncodedPolyline($encodedPolyline)); + $this->assertSame([$encodedPolyline], $this->overlayManager->getEncodedPolylines()); + } + + public function testRemoveEncodedPolyline() + { + $this->overlayManager->addEncodedPolyline($encodedPolyline = $this->createEncodedPolylineMock()); + $this->overlayManager->removeEncodedPolyline($encodedPolyline); + + $this->assertFalse($this->overlayManager->hasEncodedPolylines()); + $this->assertFalse($this->overlayManager->hasEncodedPolyline($encodedPolyline)); + $this->assertEmpty($this->overlayManager->getEncodedPolylines()); + } + + public function testRemoveEncodedPolylineWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($encodedPolyline = $this->createEncodedPolylineMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($encodedPolyline)); + + $this->overlayManager->addEncodedPolyline($encodedPolyline); + $this->overlayManager->removeEncodedPolyline($encodedPolyline); + + $this->assertFalse($this->overlayManager->hasEncodedPolylines()); + $this->assertFalse($this->overlayManager->hasEncodedPolyline($encodedPolyline)); + $this->assertEmpty($this->overlayManager->getEncodedPolylines()); + } + + public function testSetPolygons() + { + $this->overlayManager->setPolygons($polygons = [$polygon = $this->createPolygonMock()]); + $this->overlayManager->setPolygons($polygons); + + $this->assertTrue($this->overlayManager->hasPolygons()); + $this->assertTrue($this->overlayManager->hasPolygon($polygon)); + $this->assertSame($polygons, $this->overlayManager->getPolygons()); + } + + public function testSetPolygonsWithAutoZoom() + { + $this->map + ->expects($this->exactly(3)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->with($this->identicalTo($polygon = $this->createPolygonMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($polygon)); + + $this->overlayManager->setPolygons($polygons = [$polygon]); + $this->overlayManager->setPolygons($polygons); + + $this->assertTrue($this->overlayManager->hasPolygons()); + $this->assertTrue($this->overlayManager->hasPolygon($polygon)); + $this->assertSame($polygons, $this->overlayManager->getPolygons()); + } + + public function testAddPolygons() + { + $this->overlayManager->setPolygons($firstPolygons = [$this->createPolygonMock()]); + $this->overlayManager->addPolygons($secondPolygons = [$this->createPolygonMock()]); + + $this->assertTrue($this->overlayManager->hasPolygons()); + $this->assertSame(array_merge($firstPolygons, $secondPolygons), $this->overlayManager->getPolygons()); + } + + public function testAddPolygonsWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->withConsecutive( + [$firstPolygon = $this->createPolygonMock()], + [$secondPolygon = $this->createPolygonMock()] + ); + + $this->overlayManager->setPolygons($firstPolygons = [$firstPolygon]); + $this->overlayManager->addPolygons($secondPolygons = [$secondPolygon]); + + $this->assertTrue($this->overlayManager->hasPolygons()); + $this->assertSame(array_merge($firstPolygons, $secondPolygons), $this->overlayManager->getPolygons()); + } + + public function testAddPolygon() + { + $this->overlayManager->addPolygon($polygon = $this->createPolygonMock()); + + $this->assertTrue($this->overlayManager->hasPolygons()); + $this->assertTrue($this->overlayManager->hasPolygon($polygon)); + $this->assertSame([$polygon], $this->overlayManager->getPolygons()); + } + + public function testAddPolygonWithAutoZoom() + { + $this->map + ->expects($this->once()) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($polygon = $this->createPolygonMock())); + + $this->overlayManager->addPolygon($polygon); + + $this->assertTrue($this->overlayManager->hasPolygons()); + $this->assertTrue($this->overlayManager->hasPolygon($polygon)); + $this->assertSame([$polygon], $this->overlayManager->getPolygons()); + } + + public function testRemovePolygon() + { + $this->overlayManager->addPolygon($polygon = $this->createPolygonMock()); + $this->overlayManager->removePolygon($polygon); + + $this->assertFalse($this->overlayManager->hasPolygons()); + $this->assertFalse($this->overlayManager->hasPolygon($polygon)); + $this->assertEmpty($this->overlayManager->getPolygons()); + } + + public function testRemovePolygonWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($polygon = $this->createPolygonMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($polygon)); + + $this->overlayManager->addPolygon($polygon); + $this->overlayManager->removePolygon($polygon); + + $this->assertFalse($this->overlayManager->hasPolygons()); + $this->assertFalse($this->overlayManager->hasPolygon($polygon)); + $this->assertEmpty($this->overlayManager->getPolygons()); + } + + public function testSetRectangles() + { + $this->overlayManager->setRectangles($rectangles = [$rectangle = $this->createRectangleMock()]); + $this->overlayManager->setRectangles($rectangles); + + $this->assertTrue($this->overlayManager->hasRectangles()); + $this->assertTrue($this->overlayManager->hasRectangle($rectangle)); + $this->assertSame($rectangles, $this->overlayManager->getRectangles()); + } + + public function testSetRectanglesWithAutoZoom() + { + $this->map + ->expects($this->exactly(3)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->with($this->identicalTo($rectangle = $this->createRectangleMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($rectangle)); + + $this->overlayManager->setRectangles($rectangles = [$rectangle]); + $this->overlayManager->setRectangles($rectangles); + + $this->assertTrue($this->overlayManager->hasRectangles()); + $this->assertTrue($this->overlayManager->hasRectangle($rectangle)); + $this->assertSame($rectangles, $this->overlayManager->getRectangles()); + } + + public function testAddRectangles() + { + $this->overlayManager->setRectangles($firstRectangles = [$this->createRectangleMock()]); + $this->overlayManager->addRectangles($secondRectangles = [$this->createRectangleMock()]); + + $this->assertTrue($this->overlayManager->hasRectangles()); + $this->assertSame(array_merge($firstRectangles, $secondRectangles), $this->overlayManager->getRectangles()); + } + + public function testAddRectanglesWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->withConsecutive( + [$firstRectangle = $this->createRectangleMock()], + [$secondRectangle = $this->createRectangleMock()] + ); + + $this->overlayManager->setRectangles($firstRectangles = [$firstRectangle]); + $this->overlayManager->addRectangles($secondRectangles = [$secondRectangle]); + + $this->assertTrue($this->overlayManager->hasRectangles()); + $this->assertSame(array_merge($firstRectangles, $secondRectangles), $this->overlayManager->getRectangles()); + } + + public function testAddRectangle() + { + $this->overlayManager->addRectangle($rectangle = $this->createRectangleMock()); + + $this->assertTrue($this->overlayManager->hasRectangles()); + $this->assertTrue($this->overlayManager->hasRectangle($rectangle)); + $this->assertSame([$rectangle], $this->overlayManager->getRectangles()); + } + + public function testAddRectangleWithAutoZoom() + { + $this->map + ->expects($this->once()) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($rectangle = $this->createRectangleMock())); + + $this->overlayManager->addRectangle($rectangle); + + $this->assertTrue($this->overlayManager->hasRectangles()); + $this->assertTrue($this->overlayManager->hasRectangle($rectangle)); + $this->assertSame([$rectangle], $this->overlayManager->getRectangles()); + } + + public function testRemoveRectangle() + { + $this->overlayManager->addRectangle($rectangle = $this->createRectangleMock()); + $this->overlayManager->removeRectangle($rectangle); + + $this->assertFalse($this->overlayManager->hasRectangles()); + $this->assertFalse($this->overlayManager->hasRectangle($rectangle)); + $this->assertEmpty($this->overlayManager->getRectangles()); + } + + public function testRemoveRectangleWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($rectangle = $this->createRectangleMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($rectangle)); + + $this->overlayManager->addRectangle($rectangle); + $this->overlayManager->removeRectangle($rectangle); + + $this->assertFalse($this->overlayManager->hasRectangles()); + $this->assertFalse($this->overlayManager->hasRectangle($rectangle)); + $this->assertEmpty($this->overlayManager->getRectangles()); + } + + public function testSetCircles() + { + $this->overlayManager->setCircles($circles = [$circle = $this->createCircleMock()]); + $this->overlayManager->setCircles($circles); + + $this->assertTrue($this->overlayManager->hasCircles()); + $this->assertTrue($this->overlayManager->hasCircle($circle)); + $this->assertSame($circles, $this->overlayManager->getCircles()); + } + + public function testSetCirclesWithAutoZoom() + { + $this->map + ->expects($this->exactly(3)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->with($this->identicalTo($circle = $this->createCircleMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($circle)); + + $this->overlayManager->setCircles($circles = [$circle]); + $this->overlayManager->setCircles($circles); + + $this->assertTrue($this->overlayManager->hasCircles()); + $this->assertTrue($this->overlayManager->hasCircle($circle)); + $this->assertSame($circles, $this->overlayManager->getCircles()); + } + + public function testAddCircles() + { + $this->overlayManager->setCircles($firstCircles = [$this->createCircleMock()]); + $this->overlayManager->addCircles($secondCircles = [$this->createCircleMock()]); + + $this->assertTrue($this->overlayManager->hasCircles()); + $this->assertSame(array_merge($firstCircles, $secondCircles), $this->overlayManager->getCircles()); + } + + public function testAddCirclesWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->withConsecutive( + [$firstCircle = $this->createCircleMock()], + [$secondCircle = $this->createCircleMock()] + ); + + $this->overlayManager->setCircles($firstCircles = [$firstCircle]); + $this->overlayManager->addCircles($secondCircles = [$secondCircle]); + + $this->assertTrue($this->overlayManager->hasCircles()); + $this->assertSame(array_merge($firstCircles, $secondCircles), $this->overlayManager->getCircles()); + } + + public function testAddCircle() + { + $this->overlayManager->addCircle($circle = $this->createCircleMock()); + + $this->assertTrue($this->overlayManager->hasCircles()); + $this->assertTrue($this->overlayManager->hasCircle($circle)); + $this->assertSame([$circle], $this->overlayManager->getCircles()); + } + + public function testAddCircleWithAutoZoom() + { + $this->map + ->expects($this->once()) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($circle = $this->createCircleMock())); + + $this->overlayManager->addCircle($circle); + + $this->assertTrue($this->overlayManager->hasCircles()); + $this->assertTrue($this->overlayManager->hasCircle($circle)); + $this->assertSame([$circle], $this->overlayManager->getCircles()); + } + + public function testRemoveCircle() + { + $this->overlayManager->addCircle($circle = $this->createCircleMock()); + $this->overlayManager->removeCircle($circle); + + $this->assertFalse($this->overlayManager->hasCircles()); + $this->assertFalse($this->overlayManager->hasCircle($circle)); + $this->assertEmpty($this->overlayManager->getCircles()); + } + + public function testRemoveCircleWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($circle = $this->createCircleMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($circle)); + + $this->overlayManager->addCircle($circle); + $this->overlayManager->removeCircle($circle); + + $this->assertFalse($this->overlayManager->hasCircles()); + $this->assertFalse($this->overlayManager->hasCircle($circle)); + $this->assertEmpty($this->overlayManager->getCircles()); + } + + public function testSetGroundOverlays() + { + $this->overlayManager->setGroundOverlays($groundOverlays = [$groundOverlay = $this->createGroundOverlayMock()]); + $this->overlayManager->setGroundOverlays($groundOverlays); + + $this->assertTrue($this->overlayManager->hasGroundOverlays()); + $this->assertTrue($this->overlayManager->hasGroundOverlay($groundOverlay)); + $this->assertSame($groundOverlays, $this->overlayManager->getGroundOverlays()); + } + + public function testSetGroundOverlaysWithAutoZoom() + { + $this->map + ->expects($this->exactly(3)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->with($this->identicalTo($groundOverlay = $this->createGroundOverlayMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($groundOverlay)); + + $this->overlayManager->setGroundOverlays($groundOverlays = [$groundOverlay]); + $this->overlayManager->setGroundOverlays($groundOverlays); + + $this->assertTrue($this->overlayManager->hasGroundOverlays()); + $this->assertTrue($this->overlayManager->hasGroundOverlay($groundOverlay)); + $this->assertSame($groundOverlays, $this->overlayManager->getGroundOverlays()); + } + + public function testAddGroundOverlays() + { + $this->overlayManager->setGroundOverlays($firstGroundOverlays = [$this->createGroundOverlayMock()]); + $this->overlayManager->addGroundOverlays($secondGroundOverlays = [$this->createGroundOverlayMock()]); + + $this->assertTrue($this->overlayManager->hasGroundOverlays()); + $this->assertSame( + array_merge($firstGroundOverlays, $secondGroundOverlays), + $this->overlayManager->getGroundOverlays() + ); + } + + public function testAddGroundOverlaysWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->exactly(2)) + ->method('addExtendable') + ->withConsecutive( + [$firstGroundOverlay = $this->createGroundOverlayMock()], + [$secondGroundOverlay = $this->createGroundOverlayMock()] + ); + + $this->overlayManager->setGroundOverlays($firstGroundOverlays = [$firstGroundOverlay]); + $this->overlayManager->addGroundOverlays($secondGroundOverlays = [$secondGroundOverlay]); + + $this->assertTrue($this->overlayManager->hasGroundOverlays()); + $this->assertSame( + array_merge($firstGroundOverlays, $secondGroundOverlays), + $this->overlayManager->getGroundOverlays() + ); + } + + public function testAddGroundOverlay() + { + $this->overlayManager->addGroundOverlay($groundOverlay = $this->createGroundOverlayMock()); + + $this->assertTrue($this->overlayManager->hasGroundOverlays()); + $this->assertTrue($this->overlayManager->hasGroundOverlay($groundOverlay)); + $this->assertSame([$groundOverlay], $this->overlayManager->getGroundOverlays()); + } + + public function testAddGroundOverlayWithAutoZoom() + { + $this->map + ->expects($this->once()) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($groundOverlay = $this->createGroundOverlayMock())); + + $this->overlayManager->addGroundOverlay($groundOverlay); + + $this->assertTrue($this->overlayManager->hasGroundOverlays()); + $this->assertTrue($this->overlayManager->hasGroundOverlay($groundOverlay)); + $this->assertSame([$groundOverlay], $this->overlayManager->getGroundOverlays()); + } + + public function testRemoveGroundOverlay() + { + $this->overlayManager->addGroundOverlay($groundOverlay = $this->createGroundOverlayMock()); + $this->overlayManager->removeGroundOverlay($groundOverlay); + + $this->assertFalse($this->overlayManager->hasGroundOverlays()); + $this->assertFalse($this->overlayManager->hasGroundOverlay($groundOverlay)); + $this->assertEmpty($this->overlayManager->getGroundOverlays()); + } + + public function testRemoveGroundOverlayWithAutoZoom() + { + $this->map + ->expects($this->exactly(2)) + ->method('isAutoZoom') + ->will($this->returnValue(true)); + + $this->bound + ->expects($this->once()) + ->method('addExtendable') + ->with($this->identicalTo($groundOverlay = $this->createGroundOverlayMock())); + + $this->bound + ->expects($this->once()) + ->method('removeExtendable') + ->with($this->identicalTo($groundOverlay)); + + $this->overlayManager->addGroundOverlay($groundOverlay); + $this->overlayManager->removeGroundOverlay($groundOverlay); + + $this->assertFalse($this->overlayManager->hasGroundOverlays()); + $this->assertFalse($this->overlayManager->hasGroundOverlay($groundOverlay)); + $this->assertEmpty($this->overlayManager->getGroundOverlays()); + } + + /** + * @param Bound|null $bound + * + * @return \PHPUnit_Framework_MockObject_MockObject|Map + */ + private function createMapMock(Bound $bound = null) + { + $map = $this->createMock(Map::class); + $map + ->expects($this->any()) + ->method('getBound') + ->will($this->returnValue($bound ?: $this->createBoundMock())); + + return $map; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MarkerCluster + */ + private function createMarkerClusterMock() + { + return $this->createMock(MarkerCluster::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Marker + */ + private function createMarkerMock() + { + return $this->createMock(Marker::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|InfoWindow + */ + private function createInfoWindowMock() + { + return $this->createMock(InfoWindow::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Polyline + */ + private function createPolylineMock() + { + return $this->createMock(Polyline::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|EncodedPolyline + */ + private function createEncodedPolylineMock() + { + return $this->createMock(EncodedPolyline::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Polygon + */ + private function createPolygonMock() + { + return $this->createMock(Polygon::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Rectangle + */ + private function createRectangleMock() + { + return $this->createMock(Rectangle::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Circle + */ + private function createCircleMock() + { + return $this->createMock(Circle::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|GroundOverlay + */ + private function createGroundOverlayMock() + { + return $this->createMock(GroundOverlay::class); + } +} diff --git a/tests/Overlay/PolygonTest.php b/tests/Overlay/PolygonTest.php new file mode 100644 index 00000000..a141c6d5 --- /dev/null +++ b/tests/Overlay/PolygonTest.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Overlay\Polygon; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class PolygonTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Polygon + */ + private $polygon; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->polygon = new Polygon(); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableInterface::class, $this->polygon); + $this->assertInstanceOf(OptionsAwareInterface::class, $this->polygon); + $this->assertInstanceOf(VariableAwareInterface::class, $this->polygon); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('polygon', $this->polygon->getVariable()); + $this->assertFalse($this->polygon->hasCoordinates()); + $this->assertEmpty($this->polygon->getCoordinates()); + $this->assertFalse($this->polygon->hasOptions()); + } + + public function testInitialState() + { + $this->polygon = new Polygon( + $coordinates = [$coordinate = $this->createCoordinateMock()], + $options = ['foo' => 'bar'] + ); + + $this->assertStringStartsWith('polygon', $this->polygon->getVariable()); + $this->assertTrue($this->polygon->hasCoordinates()); + $this->assertTrue($this->polygon->hasCoordinate($coordinate)); + $this->assertSame($coordinates, $this->polygon->getCoordinates()); + $this->assertSame($options, $this->polygon->getOptions()); + } + + public function testSetCoordinates() + { + $this->polygon->setCoordinates($coordinates = [$coordinate = $this->createCoordinateMock()]); + $this->polygon->setCoordinates($coordinates); + + $this->assertTrue($this->polygon->hasCoordinates()); + $this->assertTrue($this->polygon->hasCoordinate($coordinate)); + $this->assertSame($coordinates, $this->polygon->getCoordinates()); + } + + public function testAddCoordinates() + { + $this->polygon->setCoordinates($firstCoordinates = [$this->createCoordinateMock()]); + $this->polygon->addCoordinates($secondCoordinates = [$this->createCoordinateMock()]); + + $this->assertTrue($this->polygon->hasCoordinates()); + $this->assertSame(array_merge($firstCoordinates, $secondCoordinates), $this->polygon->getCoordinates()); + } + + public function testAddCoordinate() + { + $this->polygon->addCoordinate($coordinate = $this->createCoordinateMock()); + + $this->assertTrue($this->polygon->hasCoordinates()); + $this->assertTrue($this->polygon->hasCoordinate($coordinate)); + $this->assertSame([$coordinate], $this->polygon->getCoordinates()); + } + + public function testRemoveCoordinate() + { + $this->polygon->addCoordinate($coordinate = $this->createCoordinateMock()); + $this->polygon->removeCoordinate($coordinate); + + $this->assertFalse($this->polygon->hasCoordinates()); + $this->assertFalse($this->polygon->hasCoordinate($coordinate)); + $this->assertEmpty($this->polygon->getCoordinates()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } +} diff --git a/tests/Overlay/PolylineTest.php b/tests/Overlay/PolylineTest.php new file mode 100644 index 00000000..d9f531a2 --- /dev/null +++ b/tests/Overlay/PolylineTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Overlay\Polyline; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class PolylineTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Polyline + */ + private $polyline; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->polyline = new Polyline(); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableInterface::class, $this->polyline); + $this->assertInstanceOf(OptionsAwareInterface::class, $this->polyline); + $this->assertInstanceOf(VariableAwareInterface::class, $this->polyline); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('polyline', $this->polyline->getVariable()); + $this->assertFalse($this->polyline->hasCoordinates()); + $this->assertFalse($this->polyline->hasOptions()); + } + + public function testInitialState() + { + $this->polyline = new Polyline( + $coordinates = [$coordinate = $this->createCoordinateMock()], + $options = ['foo' => 'bar'] + ); + + $this->assertStringStartsWith('polyline', $this->polyline->getVariable()); + $this->assertTrue($this->polyline->hasCoordinates()); + $this->assertTrue($this->polyline->hasCoordinate($coordinate)); + $this->assertSame($coordinates, $this->polyline->getCoordinates()); + $this->assertSame($options, $this->polyline->getOptions()); + } + + public function testSetCoordinates() + { + $this->polyline->setCoordinates($coordinates = [$coordinate = $this->createCoordinateMock()]); + $this->polyline->setCoordinates($coordinates); + + $this->assertTrue($this->polyline->hasCoordinates()); + $this->assertTrue($this->polyline->hasCoordinate($coordinate)); + $this->assertSame($coordinates, $this->polyline->getCoordinates()); + } + + public function testAddCoordinates() + { + $this->polyline->setCoordinates($firstCoordinates = [$this->createCoordinateMock()]); + $this->polyline->addCoordinates($secondCoordinates = [$this->createCoordinateMock()]); + + $this->assertTrue($this->polyline->hasCoordinates()); + $this->assertSame(array_merge($firstCoordinates, $secondCoordinates), $this->polyline->getCoordinates()); + } + + public function testAddCoordinate() + { + $this->polyline->addCoordinate($coordinate = $this->createCoordinateMock()); + + $this->assertTrue($this->polyline->hasCoordinates()); + $this->assertTrue($this->polyline->hasCoordinate($coordinate)); + $this->assertSame([$coordinate], $this->polyline->getCoordinates()); + } + + public function testRemoveCoordinate() + { + $this->polyline->addCoordinate($coordinate = $this->createCoordinateMock()); + $this->polyline->removeCoordinate($coordinate); + + $this->assertFalse($this->polyline->hasCoordinates()); + $this->assertFalse($this->polyline->hasCoordinate($coordinate)); + $this->assertEmpty($this->polyline->getCoordinates()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } +} diff --git a/tests/Overlay/RectangleTest.php b/tests/Overlay/RectangleTest.php new file mode 100644 index 00000000..fad049cf --- /dev/null +++ b/tests/Overlay/RectangleTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Overlay; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Overlay\ExtendableInterface; +use Ivory\GoogleMap\Overlay\Rectangle; +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class RectangleTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Rectangle + */ + private $rectangle; + + /** + * @var Bound + */ + private $bound; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->rectangle = new Rectangle($this->bound = $this->createBoundMock()); + } + + public function testInheritance() + { + $this->assertInstanceOf(ExtendableInterface::class, $this->rectangle); + $this->assertInstanceOf(OptionsAwareInterface::class, $this->rectangle); + $this->assertInstanceOf(VariableAwareInterface::class, $this->rectangle); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('rectangle', $this->rectangle->getVariable()); + $this->assertSame($this->bound, $this->rectangle->getBound()); + $this->assertFalse($this->rectangle->hasOptions()); + } + + public function testInitialState() + { + $this->rectangle = new Rectangle($this->bound, $options = ['foo' => 'bar']); + + $this->assertStringStartsWith('rectangle', $this->rectangle->getVariable()); + $this->assertSame($this->bound, $this->rectangle->getBound()); + $this->assertSame($options, $this->rectangle->getOptions()); + } + + public function testBound() + { + $this->rectangle->setBound($bound = $this->createBoundMock()); + + $this->assertSame($bound, $this->rectangle->getBound()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Overlays/AnimationTest.php b/tests/Overlays/AnimationTest.php deleted file mode 100644 index 20e049ee..00000000 --- a/tests/Overlays/AnimationTest.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\Animation; - -/** - * Animation test. - * - * @author GeLo - */ -class AnimationTest extends \PHPUnit_Framework_TestCase -{ - public function testMapTypeControlStyles() - { - $expected = array( - Animation::BOUNCE, - Animation::DROP, - ); - - $this->assertSame($expected, Animation::getAnimations()); - } -} diff --git a/tests/Overlays/CircleTest.php b/tests/Overlays/CircleTest.php deleted file mode 100644 index 4beb4af9..00000000 --- a/tests/Overlays/CircleTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\Circle; - -/** - * Circle test. - * - * @author GeLo - */ -class CircleTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\Circle */ - protected $circle; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->circle = new Circle(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->circle); - } - - public function testDefaultState() - { - $this->assertInstanceOf('Ivory\GoogleMap\Base\Coordinate', $this->circle->getCenter()); - $this->assertSame(1, $this->circle->getRadius()); - } - - public function testInitialState() - { - $center = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $radius = 2; - - $this->circle = new Circle($center, $radius); - - $this->assertSame($center, $this->circle->getCenter()); - $this->assertSame($radius, $this->circle->getRadius()); - } - - public function testCenterWithCoordinate() - { - $center = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->circle->setCenter($center); - - $this->assertSame($center, $this->circle->getCenter()); - } - - public function testCenterWithLatitudeAndLongitude() - { - $latitude = 1; - $longitude = 2; - - $this->circle->setCenter($latitude, $longitude, true); - - $this->assertSame($latitude, $this->circle->getCenter()->getLatitude()); - $this->assertSame($longitude, $this->circle->getCenter()->getLongitude()); - $this->assertTrue($this->circle->getCenter()->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage - * The center setter arguments is invalid. - * The available prototypes are : - * - function setCenter(Ivory\GoogleMap\Base\Coordinate $center) - * - function setCenter(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testCenterWithInvalidValue() - { - $this->circle->setCenter('foo'); - } - - public function testRadiusWithValidValue() - { - $this->circle->setRadius(3); - - $this->assertSame(3, $this->circle->getRadius()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The radius of a circle must be a numeric value. - */ - public function testRadiusWithInvalidValue() - { - $this->circle->setRadius(true); - } -} diff --git a/tests/Overlays/EncodedPolylineTest.php b/tests/Overlays/EncodedPolylineTest.php deleted file mode 100644 index dc789ea2..00000000 --- a/tests/Overlays/EncodedPolylineTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\EncodedPolyline; - -/** - * Encoded polyline test. - * - * @author GeLo - */ -class EncodedPolylineTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\EncodedPolyline */ - protected $encodedPolyline; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->encodedPolyline = new EncodedPolyline(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->encodedPolyline); - } - - public function testDefaultState() - { - $this->assertNull($this->encodedPolyline->getValue()); - } - - public function testInitialState() - { - $this->encodedPolyline = new EncodedPolyline('foo'); - - $this->assertSame('foo', $this->encodedPolyline->getValue()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The encoded polyline value must be a string value. - */ - public function testValueWithInvalidValue() - { - $this->encodedPolyline->setValue(true); - } -} diff --git a/tests/Overlays/GroundOverlayTest.php b/tests/Overlays/GroundOverlayTest.php deleted file mode 100644 index 36bd0563..00000000 --- a/tests/Overlays/GroundOverlayTest.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\GroundOverlay; - -/** - * Ground overlay test. - * - * @author GeLo - */ -class GroundOverlayTest extends \PHPUnit_Framework_TestCase -{ - /** @vra \Ivory\GoogleMap\Overlays\GroundOverlay */ - protected $groundOverlay; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->groundOverlay = new GroundOverlay(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->groundOverlay); - } - - public function testDefaultState() - { - $this->assertSame(-1, $this->groundOverlay->getBound()->getSouthWest()->getLatitude()); - $this->assertSame(-1, $this->groundOverlay->getBound()->getSouthWest()->getLongitude()); - - $this->assertSame(1, $this->groundOverlay->getBound()->getNorthEast()->getLatitude()); - $this->assertSame(1, $this->groundOverlay->getBound()->getNorthEast()->getLongitude()); - - $this->assertNull($this->groundOverlay->getUrl()); - } - - public function testInitialState() - { - $url = 'foo'; - - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $bound - ->expects($this->once()) - ->method('hasCoordinates') - ->will($this->returnValue(true)); - - $this->groundOverlay = new GroundOverlay($url, $bound); - - $this->assertSame($url, $this->groundOverlay->getUrl()); - $this->assertSame($bound, $this->groundOverlay->getBound()); - } - - public function testUrlWithValidValue() - { - $this->groundOverlay->setUrl('foo'); - - $this->assertSame('foo', $this->groundOverlay->getUrl()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The url of a ground overlay must be a string value. - */ - public function testUrlWithInvalidValue() - { - $this->groundOverlay->setUrl(true); - } - - public function testBoundWithValidBound() - { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $bound - ->expects($this->any()) - ->method('hasCoordinates') - ->will($this->returnValue(true)); - - $this->groundOverlay->setBound($bound); - - $this->assertSame($bound, $this->groundOverlay->getBound()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage A ground overlay bound must have a south west & a north east coordinate. - */ - public function testBoundWithInvalidBound() - { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $bound - ->expects($this->any()) - ->method('hasCoordinates') - ->will($this->returnValue(false)); - - $this->groundOverlay->setBound($bound); - } - - public function testBoundWithSouthWestAndNorthEast() - { - $southWest = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $northEast = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->groundOverlay->setBound($southWest, $northEast); - - $this->assertSame($southWest, $this->groundOverlay->getBound()->getSouthWest()); - $this->assertSame($northEast, $this->groundOverlay->getBound()->getNorthEast()); - } - - public function testBoundWithLatitudesAndLongitudes() - { - $this->groundOverlay->setBound(-1, -2, 1, 2, true, false); - - $this->assertSame(-1, $this->groundOverlay->getBound()->getSouthWest()->getLatitude()); - $this->assertSame(-2, $this->groundOverlay->getBound()->getSouthWest()->getLongitude()); - $this->assertTrue($this->groundOverlay->getBound()->getSouthWest()->isNoWrap()); - - $this->assertSame(1, $this->groundOverlay->getBound()->getNorthEast()->getLatitude()); - $this->assertSame(2, $this->groundOverlay->getBound()->getNorthEast()->getLongitude()); - $this->assertFalse($this->groundOverlay->getBound()->getNorthEast()->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - */ - public function testBoundWithInvalidValue() - { - $this->groundOverlay->setBound('foo'); - } -} diff --git a/tests/Overlays/InfoWindowTest.php b/tests/Overlays/InfoWindowTest.php deleted file mode 100644 index 5ce9c5cb..00000000 --- a/tests/Overlays/InfoWindowTest.php +++ /dev/null @@ -1,235 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Events\MouseEvent; -use Ivory\GoogleMap\Overlays\InfoWindow; - -/** - * Info window test. - * - * @author GeLo - */ -class InfoWindowTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\InfoWindow */ - protected $infoWindow; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->infoWindow = new InfoWindow(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->infoWindow); - } - - public function testDefaultState() - { - $this->assertSame('

Default content

', $this->infoWindow->getContent()); - $this->assertNull($this->infoWindow->getPosition()); - $this->assertFalse($this->infoWindow->hasPixelOffset()); - $this->assertFalse($this->infoWindow->isOpen()); - $this->assertTrue($this->infoWindow->isAutoOpen()); - $this->assertSame(MouseEvent::CLICK, $this->infoWindow->getOpenEvent()); - $this->assertFalse($this->infoWindow->isAutoClose()); - } - - public function testInitialState() - { - $content = 'foo'; - $position = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $pixelOffset = $this->getMock('Ivory\GoogleMap\Base\Size'); - $opentEvent = MouseEvent::DBLCLICK; - - $this->infoWindow = new InfoWindow($content, $position, $pixelOffset, true, $opentEvent, false, true); - - $this->assertSame($content, $this->infoWindow->getContent()); - $this->assertSame($position, $this->infoWindow->getPosition()); - $this->assertSame($pixelOffset, $this->infoWindow->getPixelOffset()); - $this->assertTrue($this->infoWindow->isOpen()); - $this->assertFalse($this->infoWindow->isAutoOpen()); - $this->assertSame($opentEvent, $this->infoWindow->getOpenEvent()); - $this->assertTrue($this->infoWindow->isAutoClose()); - } - - public function testPositionWithCoordinate() - { - $position = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->infoWindow->setPosition($position); - - $this->assertSame($position, $this->infoWindow->getPosition()); - } - - public function testPositionWithLatitudeAndLongitude() - { - $latitude = 2; - $longitude = 3; - - $this->infoWindow->setPosition($latitude, $longitude, true); - - $this->assertSame($latitude, $this->infoWindow->getPosition()->getLatitude()); - $this->assertSame($longitude, $this->infoWindow->getPosition()->getLongitude()); - $this->assertTrue($this->infoWindow->getPosition()->isNoWrap()); - } - - public function testPositionWithNullValue() - { - $this->infoWindow->setPosition($this->getMock('Ivory\GoogleMap\Base\Coordinate')); - $this->infoWindow->setPosition(null); - - $this->assertNull($this->infoWindow->getPosition()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The position setter arguments is invalid. - * The available prototypes are : - * - function setPosition(Ivory\GoogleMap\Base\Coordinate $position) - * - function setPosition(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testPositionWithInvalidValue() - { - $this->infoWindow->setPosition('foo'); - } - - public function testPixedOffsetWithSize() - { - $size = $this->getMock('Ivory\GoogleMap\Base\Size'); - $this->infoWindow->setPixelOffset($size); - - $this->assertSame($size, $this->infoWindow->getPixelOffset()); - } - - public function testPixedOffsetWithWidthAndHeight() - { - $width = 2; - $widthUnit = 'px'; - $height = 3; - $heightUnit = '%'; - - $this->infoWindow->setPixelOffset($width, $height, $widthUnit, $heightUnit); - - $this->assertSame($width, $this->infoWindow->getPixelOffset()->getWidth()); - $this->assertSame($widthUnit, $this->infoWindow->getPixelOffset()->getWidthUnit()); - $this->assertSame($height, $this->infoWindow->getPixelOffset()->getHeight()); - $this->assertSame($heightUnit, $this->infoWindow->getPixelOffset()->getHeightUnit()); - } - - public function testPixelOffsetWithNullValue() - { - $this->infoWindow->setPixelOffset($this->getMock('Ivory\GoogleMap\Base\Size')); - $this->infoWindow->setPixelOffset(null); - - $this->assertNull($this->infoWindow->getPixelOffset()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The pixel offset setter arguments is invalid. - * The available prototypes are : - * - function setPixelOffset(Ivory\GoogleMap\Base\Size $scaledSize) - * - function setPixelOffset(double $width, double $height, string $widthUnit = null, string $heightUnit = null) - */ - public function testPixedOffsetWithInvalidValue() - { - $this->infoWindow->setPixelOffset('foo'); - } - - public function testContentWithValidValue() - { - $this->infoWindow->setContent('foo'); - - $this->assertSame('foo', $this->infoWindow->getContent()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The content of an info window must be a string value. - */ - public function testContentWithInvalidValue() - { - $this->infoWindow->setContent(true); - } - - public function testOpenWithValidValue() - { - $this->infoWindow->setOpen(true); - - $this->assertTrue($this->infoWindow->isOpen()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The open property of an info window must be a boolean value. - */ - public function testOpenWithInvalidValue() - { - $this->infoWindow->setOpen('foo'); - } - - public function testAutoOpenWithValidValue() - { - $this->infoWindow->setAutoOpen(true); - - $this->assertTrue($this->infoWindow->isAutoOpen()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The auto open property of an info window must be a boolean value. - */ - public function testAutoOpenWithInvalidValue() - { - $this->infoWindow->setAutoOpen('foo'); - } - - public function testOpenEventWithValidValue() - { - $this->infoWindow->setOpenEvent(MouseEvent::MOUSEDOWN); - - $this->assertSame(MouseEvent::MOUSEDOWN, $this->infoWindow->getOpenEvent()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The only available open event are : click, dblclick, mouseup, mousedown, mouseover, - * mouseout. - */ - public function testOpenEventWithInvalidValue() - { - $this->infoWindow->setOpenEvent('foo'); - } - - public function testAutoCloseWithValidValue() - { - $this->infoWindow->setAutoClose(true); - - $this->assertTrue($this->infoWindow->isAutoClose()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The info window auto close flag must be a boolean value. - */ - public function testAutoCloseWithInvalidValue() - { - $this->infoWindow->setAutoClose('foo'); - } -} diff --git a/tests/Overlays/MarkerClusterTest.php b/tests/Overlays/MarkerClusterTest.php deleted file mode 100644 index 905ba7ea..00000000 --- a/tests/Overlays/MarkerClusterTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\MarkerCluster; - -/** - * Marker cluster test. - * - * @author GeLo - */ -class MarkerClusterTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\MarkerCluster */ - protected $markerCluster; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->markerCluster = new MarkerCluster(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->markerCluster); - } - - public function testDefaultState() - { - $this->assertSame('marker_cluster_', substr($this->markerCluster->getJavascriptVariable(), 0, 15)); - $this->assertSame(MarkerCluster::_DEFAULT, $this->markerCluster->getType()); - $this->assertFalse($this->markerCluster->hasMarkers()); - $this->assertEmpty($this->markerCluster->getMarkers()); - } - - public function testType() - { - $this->markerCluster->setType(MarkerCluster::MARKER_CLUSTER); - - $this->assertSame(MarkerCluster::MARKER_CLUSTER, $this->markerCluster->getType()); - } - - public function testMarker() - { - $marker = $this->getMock('Ivory\GoogleMap\Overlays\Marker'); - $this->markerCluster->setMarkers(array($marker)); - - $this->assertTrue($this->markerCluster->hasMarkers()); - $this->assertSame(array($marker), $this->markerCluster->getMarkers()); - } -} diff --git a/tests/Overlays/MarkerImageTest.php b/tests/Overlays/MarkerImageTest.php deleted file mode 100644 index e68f73a2..00000000 --- a/tests/Overlays/MarkerImageTest.php +++ /dev/null @@ -1,249 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\MarkerImage; - -/** - * Marker image test. - * - * @author GeLo - */ -class MarkerImageTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\MarkerImage */ - protected $markerImage; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->markerImage = new MarkerImage(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->markerImage); - } - - public function testDefaultState() - { - $this->assertSame('//maps.gstatic.com/mapfiles/markers/marker.png', $this->markerImage->getUrl()); - $this->assertFalse($this->markerImage->hasAnchor()); - $this->assertFalse($this->markerImage->hasOrigin()); - $this->assertFalse($this->markerImage->hasScaledSize()); - $this->assertFalse($this->markerImage->hasSize()); - } - - public function testInitialState() - { - $url = 'foo'; - $anchor = $this->getMock('Ivory\GoogleMap\Base\Point'); - $origin = $this->getMock('Ivory\GoogleMap\Base\Point'); - $scaledSize = $this->getMock('Ivory\GoogleMap\Base\Size'); - $size = $this->getMock('Ivory\GoogleMap\Base\Size'); - - $this->markerImage = new MarkerImage($url, $anchor, $origin, $scaledSize, $size); - - $this->assertSame($url, $this->markerImage->getUrl()); - $this->assertSame($anchor, $this->markerImage->getAnchor()); - $this->assertSame($origin, $this->markerImage->getOrigin()); - $this->assertSame($scaledSize, $this->markerImage->getScaledSize()); - $this->assertSame($size, $this->markerImage->getSize()); - } - - public function testUrlWithValidValue() - { - $this->markerImage->setUrl('foo'); - - $this->assertSame('foo', $this->markerImage->getUrl()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The url of a maker image must be a string value. - */ - public function testUrlWithInvalidValue() - { - $this->markerImage->setUrl(true); - } - - public function testAnchorWithPoint() - { - $point = $this->getMock('Ivory\GoogleMap\Base\Point'); - $this->markerImage->setAnchor($point); - - $this->assertSame($point, $this->markerImage->getAnchor()); - } - - public function testAnchorWithXAndY() - { - $x = 2; - $y = 3; - - $this->markerImage->setAnchor($x, $y); - - $this->assertSame($x, $this->markerImage->getAnchor()->getX()); - $this->assertSame($y, $this->markerImage->getAnchor()->getY()); - } - - public function testAnchorWithNullValue() - { - $this->markerImage->setAnchor($this->getMock('Ivory\GoogleMap\Base\Point')); - $this->markerImage->setAnchor(null); - - $this->assertNull($this->markerImage->getAnchor()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The anchor setter arguments is invalid. - * The available prototypes are : - * - function setAnchor(Ivory\GoogleMap\Base\Point $anchor) - * - function setAnchor(double x, double y) - */ - public function testAnchorWithInvalidValue() - { - $this->markerImage->setAnchor(true); - } - - public function testOriginWithPoint() - { - $point = $this->getMock('Ivory\GoogleMap\Base\Point'); - $this->markerImage->setOrigin($point); - - $this->assertSame($point, $this->markerImage->getOrigin()); - } - - public function testOriginWithXAndY() - { - $x = 2; - $y = 3; - - $this->markerImage->setOrigin($x, $y); - - $this->assertSame($x, $this->markerImage->getOrigin()->getX()); - $this->assertSame($y, $this->markerImage->getOrigin()->getY()); - } - - public function testOriginWithNullValue() - { - $this->markerImage->setOrigin($this->getMock('Ivory\GoogleMap\Base\Point')); - $this->markerImage->setOrigin(null); - - $this->assertNull($this->markerImage->getOrigin()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The origin setter arguments is invalid. - * The available prototypes are : - * - function setOrigin(Ivory\GoogleMap\Base\Point $anchor) - * - function setOrigin(double x, double y) - */ - public function testOriginWithInvalidValue() - { - $this->markerImage->setOrigin(true); - } - - public function testScaledSizeWithSize() - { - $size = $this->getMock('Ivory\GoogleMap\Base\Size'); - $this->markerImage->setScaledSize($size); - - $this->assertSame($size, $this->markerImage->getScaledSize()); - } - - public function testScaledSizeWithWidthAndHeight() - { - $width = 2; - $widthUnit = 'px'; - - $height = 3; - $heightUnit = '%'; - - $this->markerImage->setScaledSize($width, $height, $widthUnit, $heightUnit); - - $this->assertSame($width, $this->markerImage->getScaledSize()->getWidth()); - $this->assertSame($height, $this->markerImage->getScaledSize()->getHeight()); - $this->assertSame($widthUnit, $this->markerImage->getScaledSize()->getWidthUnit()); - $this->assertSame($heightUnit, $this->markerImage->getScaledSize()->getHeightUnit()); - } - - public function testScaledSizeWithNullValue() - { - $this->markerImage->setScaledSize($this->getMock('Ivory\GoogleMap\Base\Size')); - $this->markerImage->setScaledSize(null); - - $this->assertNull($this->markerImage->getScaledSize()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The scaled size setter arguments is invalid. - * The available prototypes are : - * - function setScaledSize(Ivory\GoogleMap\Base\Size $scaledSize = null) - * - function setScaledSize(double $width, double $height, string $widthUnit = null, string $heightUnit = null) - */ - public function testScaledSizeWithInvalidValue() - { - $this->markerImage->setScaledSize('foo'); - } - - public function testSizeWithSize() - { - $size = $this->getMock('Ivory\GoogleMap\Base\Size'); - $this->markerImage->setSize($size); - - $this->assertSame($size, $this->markerImage->getSize()); - } - - public function testSizeWithWidthAndHeight() - { - $width = 2; - $widthUnit = 'px'; - - $height = 3; - $heightUnit = '%'; - - $this->markerImage->setSize($width, $height, $widthUnit, $heightUnit); - - $this->assertSame($width, $this->markerImage->getSize()->getWidth()); - $this->assertSame($height, $this->markerImage->getSize()->getHeight()); - $this->assertSame($widthUnit, $this->markerImage->getSize()->getWidthUnit()); - $this->assertSame($heightUnit, $this->markerImage->getSize()->getHeightUnit()); - } - - public function testSizeWithNullValue() - { - $this->markerImage->setSize($this->getMock('Ivory\GoogleMap\Base\Size')); - $this->markerImage->setSize(null); - - $this->assertNull($this->markerImage->getSize()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The size setter arguments is invalid. - * The available prototypes are : - * - function setSize(Ivory\GoogleMap\Base\Size $scaledSize = null) - * - function setSize(double $width, double $height, string $widthUnit = null, string $heightUnit = null) - */ - public function testSizeWithInvalidValue() - { - $this->markerImage->setSize('foo'); - } -} diff --git a/tests/Overlays/MarkerShapeTest.php b/tests/Overlays/MarkerShapeTest.php deleted file mode 100644 index 8de2bfba..00000000 --- a/tests/Overlays/MarkerShapeTest.php +++ /dev/null @@ -1,175 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\MarkerShape; - -/** - * Marker shape test. - * - * @author GeLo - */ -class MarkerShapeTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\MarkerShape */ - protected $markerShape; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->markerShape = new MarkerShape(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->markerShape); - } - - public function testDefaultState() - { - $this->assertSame('poly', $this->markerShape->getType()); - $this->assertTrue($this->markerShape->hasCoordinates()); - $this->assertSame(array(1, 1, 1, -1, -1, -1, -1, 1), $this->markerShape->getCoordinates()); - } - - public function testInitialState() - { - $type = 'rect'; - $coordinates = array(1, 1, -1, -1); - - $this->markerShape = new MarkerShape($type, $coordinates); - - $this->assertSame($type, $this->markerShape->getType()); - $this->assertSame($coordinates, $this->markerShape->getCoordinates()); - } - - public function testTypeWithValidValue() - { - $this->markerShape->setType('rect'); - - $this->assertSame('rect', $this->markerShape->getType()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The type of a marker shape can only be : circle, poly, rect. - */ - public function testTypeWithInvalidValue() - { - $this->markerShape->setType('foo'); - } - - public function testCircleCoordinatesWithValidValue() - { - $this->markerShape->setType('circle'); - $this->markerShape->setCoordinates(array(1, 2, 3)); - - $this->assertSame(array(1, 2, 3), $this->markerShape->getCoordinates()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The coordinates setter arguments is invalid if the marker shape type is circle. - * The available prototype is : function setCoordinates(array(double $x, double $y, double $r)) - */ - public function testCircleCoordinatesWithInvalidValue() - { - $this->markerShape->setType('circle'); - $this->markerShape->setCoordinates(array(true)); - } - - public function testPolyCoordinatesWithValidValue() - { - $this->markerShape->setType('poly'); - $this->markerShape->setCoordinates(array(1, 2, 3, 4, 5, 6)); - - $this->assertSame(array(1, 2, 3, 4, 5, 6), $this->markerShape->getCoordinates()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The coordinates setter arguments is invalid if the marker shape type is poly. - * The available prototype is : function setCoordinates(array(double $x1, double $y1, ..., double $xn, double $yn)) - */ - public function testPolyCoordinatesWithInvalidParametersCount() - { - $this->markerShape->setType('poly'); - $this->markerShape->setCoordinates(array(1)); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The coordinates setter arguments is invalid if the marker shape type is poly. - * The available prototype is : function setCoordinates(array(double $x1, double $y1, ..., double $xn, double $yn)) - */ - public function testPolyCoordinatesWithInvalidValue() - { - $this->markerShape->setType('poly'); - $this->markerShape->setCoordinates(array(1, true)); - } - - public function testRectCoordinatesWithValidValue() - { - $this->markerShape->setType('rect'); - $this->markerShape->setCoordinates(array(1, 2, 3, 4)); - - $this->assertSame(array(1, 2, 3, 4), $this->markerShape->getCoordinates()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The coordinates setter arguments is invalid if the marker shape type is rect. - * The available prototype is : function setCoordinates(array(double $x1, double $y1, double $x2, double $y2)) - */ - public function testRectCoordinatesWithInvalidValue() - { - $this->markerShape->setType('rect'); - $this->markerShape->setCoordinates(array(true)); - } - - public function testAddPolyCoordinateWithValidValue() - { - $this->markerShape->resetCoordinates(); - $this->markerShape->setType('poly'); - - $this->markerShape->addPolyCoordinate(1, 2); - $this->markerShape->addPolyCoordinate(3, 4); - - $this->assertSame(array(1, 2, 3, 4), $this->markerShape->getCoordinates()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The MarkerShape::addPolyCoordinate($x, $y) method can only be use with a marker - * shape which has type poly. - */ - public function testAddPolyCoordinateWithInvalidType() - { - $this->markerShape->setType('rect'); - $this->markerShape->addPolyCoordinate(1, 2); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The x & y coordinates of a poly marker shape must be numeric values. - */ - public function testAddPolyCoordinateWithInvalidValue() - { - $this->markerShape->setType('poly'); - $this->markerShape->addPolyCoordinate(true, false); - } -} diff --git a/tests/Overlays/MarkerTest.php b/tests/Overlays/MarkerTest.php deleted file mode 100644 index 8058b56f..00000000 --- a/tests/Overlays/MarkerTest.php +++ /dev/null @@ -1,305 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\Animation; -use Ivory\GoogleMap\Overlays\Marker; - -/** - * Marker test. - * - * @author GeLo - */ -class MarkerTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\Marker */ - protected $marker; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->marker = new Marker(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->marker); - } - - public function testDefaultState() - { - $this->assertInstanceOf('Ivory\GoogleMap\Base\Coordinate', $this->marker->getPosition()); - $this->assertFalse($this->marker->hasAnimation()); - $this->assertFalse($this->marker->hasIcon()); - $this->assertFalse($this->marker->hasShadow()); - $this->assertFalse($this->marker->hasShape()); - $this->assertFalse($this->marker->hasInfoWindow()); - } - - public function testInitialState() - { - $position = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $animation = Animation::DROP; - - $icon = $this->getMock('Ivory\GoogleMap\Overlays\MarkerImage'); - $icon - ->expects($this->once()) - ->method('getUrl') - ->will($this->returnValue('foo')); - - $shadow = $this->getMock('Ivory\GoogleMap\Overlays\MarkerImage'); - $shadow - ->expects($this->once()) - ->method('getUrl') - ->will($this->returnValue('foo')); - - $shape = $this->getMock('Ivory\GoogleMap\Overlays\MarkerShape'); - $shape - ->expects($this->once()) - ->method('hasCoordinates') - ->will($this->returnValue(true)); - - $infoWindow = $this->getMock('Ivory\GoogleMap\Overlays\InfoWindow'); - - $this->marker = new Marker($position, $animation, $icon, $shadow, $shape, $infoWindow); - - $this->assertSame($position, $this->marker->getPosition()); - $this->assertSame($animation, $this->marker->getAnimation()); - $this->assertSame($icon, $this->marker->getIcon()); - $this->assertSame($shadow, $this->marker->getShadow()); - $this->assertSame($shape, $this->marker->getShape()); - $this->assertSame($infoWindow, $this->marker->getInfoWindow()); - } - - public function testPositionWithCoordinate() - { - $coordinate = $this->getMock('ivory\GoogleMap\Base\Coordinate'); - $this->marker->setPosition($coordinate); - - $this->assertSame($coordinate, $this->marker->getPosition()); - } - - public function testPositionWithLatitudeAndLongitude() - { - $latitude = 1; - $longitude = 2; - - $this->marker->setPosition($latitude, $longitude, true); - - $this->assertSame($latitude, $this->marker->getPosition()->getLatitude()); - $this->assertSame($longitude, $this->marker->getPosition()->getLongitude()); - $this->assertTrue($this->marker->getPosition()->isNoWrap()); - } - - public function testPositionWithNullValue() - { - $this->marker->setPosition($this->getMock('ivory\GoogleMap\Base\Coordinate')); - $this->marker->setPosition(null); - - $this->assertNull($this->marker->getPosition()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The position setter arguments is invalid. - * The available prototypes are : - * - function setPosition(Ivory\GoogleMap\Base\Coordinate $position) - * - function setPosition(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testPositionWithInvalidValue() - { - $this->marker->setPosition('foo'); - } - - public function testAnimationWithValidValue() - { - $this->marker->setAnimation(Animation::DROP); - - $this->assertSame(Animation::DROP, $this->marker->getAnimation()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The animation of a marker can only be : bounce, drop. - */ - public function testAnimationWithInvalidValue() - { - $this->marker->setAnimation('foo'); - } - - public function testIconWithValidMarkerImage() - { - $markerImage = $this->getMock('Ivory\GoogleMap\Overlays\MarkerImage'); - $markerImage - ->expects($this->once()) - ->method('getUrl') - ->will($this->returnValue('foo')); - - $this->marker->setIcon($markerImage); - - $this->assertSame($markerImage, $this->marker->getIcon()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage A marker image icon must have an url. - */ - public function testIconWithInvalidMarkerImage() - { - $markerImage = $this->getMock('Ivory\GoogleMap\Overlays\MarkerImage'); - $this->marker->setIcon($markerImage); - } - - public function testIconWithUrl() - { - $this->marker->setIcon('foo'); - - $this->assertSame('foo', $this->marker->getIcon()->getUrl()); - } - - public function testIconWithNullValue() - { - $this->marker->setIcon('foo'); - $this->marker->setIcon(null); - - $this->assertNull($this->marker->getIcon()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The icon setter arguments is invalid. - * The available prototypes are : - * - function setIcon(Ivory\GoogleMap\Overlays\MarkerImage $markerImage = null) - * - function setIcon(string $url = null) - */ - public function testIconWithInvalidValue() - { - $this->marker->setIcon(true); - } - - public function testShadowWithValidMarkerImage() - { - $markerImage = $this->getMock('Ivory\GoogleMap\Overlays\MarkerImage'); - $markerImage - ->expects($this->once()) - ->method('getUrl') - ->will($this->returnValue('foo')); - - $this->marker->setShadow($markerImage); - - $this->assertSame($markerImage, $this->marker->getShadow()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage A marker image shadow must have an url. - */ - public function testShadowWithInvalidMarkerImage() - { - $markerImage = $this->getMock('Ivory\GoogleMap\Overlays\MarkerImage'); - $this->marker->setShadow($markerImage); - } - - public function testShadowWithUrl() - { - $this->marker->setShadow('foo'); - - $this->assertSame('foo', $this->marker->getShadow()->getUrl()); - } - - public function testShadowWithNullValue() - { - $this->marker->setShadow('foo'); - $this->marker->setShadow(null); - - $this->assertNull($this->marker->getShadow()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The shadow setter arguments is invalid. - * The available prototypes are : - * - function setShadow(Ivory\GoogleMap\Overlays\MarkerImage $markerImage = null) - * - function setShadow(string $url = null) - */ - public function testShadowWithInvalidValue() - { - $this->marker->setShadow(true); - } - - public function testShapeWithValidMarkerShape() - { - $markerShape = $this->getMock('Ivory\GoogleMap\Overlays\MarkerShape'); - $markerShape - ->expects($this->once()) - ->method('hasCoordinates') - ->will($this->returnValue(true)); - - $this->marker->setShape($markerShape); - - $this->assertSame($markerShape, $this->marker->getShape()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage A marker shape must have coordinates. - */ - public function testShapeWithInvalidMarkerShape() - { - $markerShape = $this->getMock('Ivory\GoogleMap\Overlays\MarkerShape'); - $this->marker->setShape($markerShape); - } - - public function testShapeWithTypeAndCoordinates() - { - $type = 'poly'; - $coordinates = array(1, 2, 3, 4); - - $this->marker->setShape($type, $coordinates); - - $this->assertSame($type, $this->marker->getShape()->getType()); - $this->assertSame($coordinates, $this->marker->getShape()->getCoordinates()); - } - - public function testShapeWithNullValue() - { - $this->marker->setShape('poly', array(1, 2, 3, 4)); - $this->marker->setShape(null); - - $this->assertNull($this->marker->getShape()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The shape setter arguments is invalid. - * The available prototypes are : - * - function setShape(Ivory\GoogleMap\Overlays\MarkerShape $shape = null) - * - function setShape(string $type, array $coordinates) - */ - public function testShapeWithInvalidValue() - { - $this->marker->setShape(true); - } - - public function testInfoWindow() - { - $infoWindow = $this->getMock('Ivory\GoogleMap\Overlays\InfoWindow'); - $this->marker->setInfoWindow($infoWindow); - - $this->assertSame($infoWindow, $this->marker->getInfoWindow()); - } -} diff --git a/tests/Overlays/PolygonTest.php b/tests/Overlays/PolygonTest.php deleted file mode 100644 index 62ea9283..00000000 --- a/tests/Overlays/PolygonTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\Polygon; - -/** - * Polygon test. - * - * @author GeLo - */ -class PolygonTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\Polygon */ - protected $polygon; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->polygon = new Polygon(); - } - - /** - * {@in1, 2, 3, 4heritdoc} - */ - protected function tearDown() - { - unset($this->polygon); - } - - public function testDefaultState() - { - $this->assertFalse($this->polygon->hasCoordinates()); - } - - public function testInitialState() - { - $coordinates = array( - $this->getMock('Ivory\GoogleMap\Base\Coordinate'), - $this->getMock('Ivory\GoogleMap\Base\Coordinate'), - ); - - $this->polygon = new Polygon($coordinates); - - $this->assertTrue($this->polygon->hasCoordinates()); - $this->assertSame($coordinates, $this->polygon->getCoordinates()); - } - - public function testCoordinateWithLatitudeAndLongitude() - { - $latitude = 1; - $longitude = 2; - - $this->polygon->addCoordinate($latitude, $longitude, true); - - $coordinates = $this->polygon->getCoordinates(); - - $this->assertArrayHasKey(0, $coordinates); - $this->assertSame($latitude, $coordinates[0]->getLatitude()); - $this->assertSame($longitude, $coordinates[0]->getLongitude()); - $this->assertTrue($coordinates[0]->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The coordinate adder arguments is invalid. - * The available prototypes are : - * - function addCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate) - * - function addCoordinate(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testCoordinateWithInvalidValue() - { - $this->polygon->addCoordinate('foo'); - } -} diff --git a/tests/Overlays/PolylineTest.php b/tests/Overlays/PolylineTest.php deleted file mode 100644 index d7480451..00000000 --- a/tests/Overlays/PolylineTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\Polyline; - -/** - * Polyline test. - * - * @author GeLo - */ -class PolylineTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\Polyline */ - protected $polyline; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->polyline = new Polyline(); - } - - /** - * {@in1, 2, 3, 4heritdoc} - */ - protected function tearDown() - { - unset($this->polyline); - } - - public function testDefaultState() - { - $this->assertFalse($this->polyline->hasCoordinates()); - } - - public function testInitialState() - { - $coordinates = array( - $this->getMock('Ivory\GoogleMap\Base\Coordinate'), - $this->getMock('Ivory\GoogleMap\Base\Coordinate'), - ); - - $this->polyline = new Polyline($coordinates); - - $this->assertTrue($this->polyline->hasCoordinates()); - $this->assertSame($coordinates, $this->polyline->getCoordinates()); - } - - public function testCoordinateWithLatitudeAndLongitude() - { - $latitude = 1; - $longitude = 2; - - $this->polyline->addCoordinate($latitude, $longitude, true); - - $coordinates = $this->polyline->getCoordinates(); - - $this->assertArrayHasKey(0, $coordinates); - $this->assertSame($latitude, $coordinates[0]->getLatitude()); - $this->assertSame($longitude, $coordinates[0]->getLongitude()); - $this->assertTrue($coordinates[0]->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The coordinate adder arguments is invalid. - * The available prototypes are : - * - function addCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate) - * - function addCoordinate(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testCoordinateWithInvalidValue() - { - $this->polyline->addCoordinate('foo'); - } -} diff --git a/tests/Overlays/RectangleTest.php b/tests/Overlays/RectangleTest.php deleted file mode 100644 index 2372d4e1..00000000 --- a/tests/Overlays/RectangleTest.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Overlays; - -use Ivory\GoogleMap\Overlays\Rectangle; - -/** - * Rectangle test. - * - * @author GeLo - */ -class RectangleTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Overlays\Rectangle */ - protected $rectangle; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->rectangle = new Rectangle(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->rectangle); - } - - public function testDefaultState() - { - $this->assertSame(1, $this->rectangle->getBound()->getNorthEast()->getLatitude()); - $this->assertSame(1, $this->rectangle->getBound()->getNorthEast()->getLongitude()); - $this->assertTrue($this->rectangle->getBound()->getNorthEast()->isNoWrap()); - - $this->assertSame(-1, $this->rectangle->getBound()->getSouthWest()->getLatitude()); - $this->assertSame(-1, $this->rectangle->getBound()->getSouthWest()->getLongitude()); - $this->assertTrue($this->rectangle->getBound()->getSouthWest()->isNoWrap()); - } - - public function testInitialState() - { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $bound - ->expects($this->once()) - ->method('hasCoordinates') - ->will($this->returnValue(true)); - - $this->rectangle = new Rectangle($bound); - - $this->assertSame($bound, $this->rectangle->getBound()); - } - - public function testBoundWithValidBound() - { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $bound - ->expects($this->once()) - ->method('hasCoordinates') - ->will($this->returnValue(true)); - - $this->rectangle->setBound($bound); - - $this->assertSame($bound, $this->rectangle->getBound()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage A rectangle bound must have a south west & a north east coordinate. - */ - public function testBoundWithInvalidBound() - { - $this->rectangle->setBound($this->getMock('Ivory\GoogleMap\Base\Bound')); - } - - public function testBoundWithCoordinates() - { - $southWeestCoordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $northEastCoordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->rectangle->setBound($southWeestCoordinate, $northEastCoordinate); - - $this->assertSame($southWeestCoordinate, $this->rectangle->getBound()->getSouthWest()); - $this->assertSame($northEastCoordinate, $this->rectangle->getBound()->getNorthEast()); - } - - public function testBoundWithLatitudesAndLongitudes() - { - $southWestLatitude = 1; - $southWestLongitue = 2; - - $northEastLatitude = -1; - $northEastLongitude = -2; - - $this->rectangle->setBound( - $southWestLatitude, - $southWestLongitue, - $northEastLatitude, - $northEastLongitude, - true, - false - ); - - $this->assertSame($southWestLatitude, $this->rectangle->getBound()->getSouthWest()->getLatitude()); - $this->assertSame($southWestLongitue, $this->rectangle->getBound()->getSouthWest()->getLongitude()); - $this->assertTrue($this->rectangle->getBound()->getSouthWest()->isNoWrap()); - - $this->assertSame($northEastLatitude, $this->rectangle->getBound()->getNorthEast()->getLatitude()); - $this->assertSame($northEastLongitude, $this->rectangle->getBound()->getNorthEast()->getLongitude()); - $this->assertFalse($this->rectangle->getBound()->getNorthEast()->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\OverlayException - * @expectedExceptionMessage The bound setter arguments is invalid. - * The available prototypes are : - * - function setBound(Ivory\GoogleMap\Base\Bound $bound) - * - function setBount(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - */ - public function testBoundWithInvalidValue() - { - $this->rectangle->setBound('foo'); - } -} diff --git a/tests/Place/AutocompleteTest.php b/tests/Place/AutocompleteTest.php new file mode 100644 index 00000000..0dc8554a --- /dev/null +++ b/tests/Place/AutocompleteTest.php @@ -0,0 +1,269 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Place; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Place\Autocomplete; +use Ivory\GoogleMap\Place\AutocompleteComponentRestriction; +use Ivory\GoogleMap\Place\AutocompleteType; +use Ivory\GoogleMap\Utility\VariableAwareInterface; + +/** + * @author GeLo + */ +class AutocompleteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Autocomplete + */ + private $autocomplete; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->autocomplete = new Autocomplete(); + } + + public function testInheritance() + { + $this->assertInstanceOf(VariableAwareInterface::class, $this->autocomplete); + } + + public function testDefaultState() + { + $this->assertStringStartsWith('place_autocomplete', $this->autocomplete->getVariable()); + $this->assertSame('place_input', $this->autocomplete->getHtmlId()); + $this->assertFalse($this->autocomplete->hasBound()); + $this->assertNull($this->autocomplete->getBound()); + $this->assertFalse($this->autocomplete->hasTypes()); + $this->assertEmpty($this->autocomplete->getTypes()); + $this->assertFalse($this->autocomplete->hasComponentRestrictions()); + $this->assertEmpty($this->autocomplete->getComponentRestrictions()); + $this->assertFalse($this->autocomplete->hasValue()); + $this->assertNull($this->autocomplete->getValue()); + $this->assertFalse($this->autocomplete->hasInputAttributes()); + $this->assertEmpty($this->autocomplete->getInputAttributes()); + $this->assertFalse($this->autocomplete->hasLibraries()); + $this->assertEmpty($this->autocomplete->getLibraries()); + $this->assertSame('en', $this->autocomplete->getLanguage()); + } + + public function testInputId() + { + $this->autocomplete->setInputId($inputId = 'input'); + + $this->assertSame($inputId, $this->autocomplete->getHtmlId()); + } + + public function testBound() + { + $this->autocomplete->setBound($bound = $this->createBoundMock()); + + $this->assertTrue($this->autocomplete->hasBound()); + $this->assertSame($bound, $this->autocomplete->getBound()); + } + + public function testResetBound() + { + $this->autocomplete->setBound($this->createBoundMock()); + $this->autocomplete->setBound(null); + + $this->assertFalse($this->autocomplete->hasBound()); + $this->assertNull($this->autocomplete->getBound()); + } + + public function testSetTypes() + { + $this->autocomplete->setTypes($types = [$type = AutocompleteType::ESTABLISHMENT]); + $this->autocomplete->setTypes($types); + + $this->assertTrue($this->autocomplete->hasTypes()); + $this->assertTrue($this->autocomplete->hasType($type)); + $this->assertSame($types, $this->autocomplete->getTypes()); + } + + public function testAddTypes() + { + $this->autocomplete->setTypes($firstTypes = [AutocompleteType::ESTABLISHMENT]); + $this->autocomplete->addTypes($secondTypes = [AutocompleteType::CITIES]); + + $this->assertTrue($this->autocomplete->hasTypes()); + $this->assertSame(array_merge($firstTypes, $secondTypes), $this->autocomplete->getTypes()); + } + + public function testAddType() + { + $this->autocomplete->addType($type = AutocompleteType::ESTABLISHMENT); + + $this->assertTrue($this->autocomplete->hasTypes()); + $this->assertTrue($this->autocomplete->hasType($type)); + $this->assertSame([$type], $this->autocomplete->getTypes()); + } + + public function testRemoveType() + { + $this->autocomplete->addType($type = AutocompleteType::ESTABLISHMENT); + $this->autocomplete->removeType($type); + + $this->assertFalse($this->autocomplete->hasTypes()); + $this->assertFalse($this->autocomplete->hasType($type)); + $this->assertEmpty($this->autocomplete->getTypes()); + } + + public function testSetComponentRestrictions() + { + $componentRestrictions = [$type = AutocompleteComponentRestriction::COUNTRY => $value = 'fr']; + + $this->autocomplete->setComponentRestrictions($componentRestrictions); + $this->autocomplete->setComponentRestrictions($componentRestrictions); + + $this->assertTrue($this->autocomplete->hasComponentRestrictions()); + $this->assertTrue($this->autocomplete->hasComponentRestriction($type)); + $this->assertSame($componentRestrictions, $this->autocomplete->getComponentRestrictions()); + $this->assertSame($value, $this->autocomplete->getComponentRestriction($type)); + } + + public function testAddComponentRestrictions() + { + $firstComponentRestrictions = [AutocompleteComponentRestriction::COUNTRY => 'fr']; + $secondComponentRestrictions = [AutocompleteComponentRestriction::COUNTRY => 'en']; + + $this->autocomplete->setComponentRestrictions($firstComponentRestrictions); + $this->autocomplete->addComponentRestrictions($secondComponentRestrictions); + + $this->assertTrue($this->autocomplete->hasComponentRestrictions()); + $this->assertSame( + array_merge($firstComponentRestrictions, $secondComponentRestrictions), + $this->autocomplete->getComponentRestrictions() + ); + } + + public function testSetComponentRestriction() + { + $this->autocomplete->setComponentRestriction($type = AutocompleteComponentRestriction::COUNTRY, $value = 'fr'); + + $this->assertTrue($this->autocomplete->hasComponentRestrictions()); + $this->assertTrue($this->autocomplete->hasComponentRestriction($type)); + $this->assertSame([$type => $value], $this->autocomplete->getComponentRestrictions()); + $this->assertSame($value, $this->autocomplete->getComponentRestriction($type)); + } + + public function testRemoveComponentRestriction() + { + $this->autocomplete->setComponentRestriction($type = AutocompleteComponentRestriction::COUNTRY, 'fr'); + $this->autocomplete->removeComponentRestriction($type); + + $this->assertFalse($this->autocomplete->hasComponentRestrictions()); + $this->assertFalse($this->autocomplete->hasComponentRestriction($type)); + $this->assertEmpty($this->autocomplete->getComponentRestrictions()); + $this->assertNull($this->autocomplete->getComponentRestriction($type)); + } + + public function testSetInputAttributes() + { + $this->autocomplete->setInputAttributes($inputAttributes = [$name = 'foo' => $value = 'bar']); + $this->autocomplete->setInputAttributes($inputAttributes); + + $this->assertTrue($this->autocomplete->hasInputAttributes()); + $this->assertTrue($this->autocomplete->hasInputAttribute($name)); + $this->assertSame($inputAttributes, $this->autocomplete->getInputAttributes()); + $this->assertSame($value, $this->autocomplete->getInputAttribute($name)); + } + + public function testAddInputAttributes() + { + $this->autocomplete->setInputAttributes($firstInputAttributes = ['foo' => 'bar']); + $this->autocomplete->addInputAttributes($secondInputAttributes = ['baz' => 'bat']); + + $this->assertTrue($this->autocomplete->hasInputAttributes()); + $this->assertSame( + array_merge($firstInputAttributes, $secondInputAttributes), + $this->autocomplete->getInputAttributes() + ); + } + + public function testAddInputAttribute() + { + $this->autocomplete->setInputAttribute($name = 'foo', $value = 'bar'); + + $this->assertTrue($this->autocomplete->hasInputAttributes()); + $this->assertTrue($this->autocomplete->hasInputAttribute($name)); + $this->assertSame([$name => $value], $this->autocomplete->getInputAttributes()); + $this->assertSame($value, $this->autocomplete->getInputAttribute($name)); + } + + public function testRemoveInputAttribute() + { + $this->autocomplete->setInputAttribute($name = 'foo', 'bar'); + $this->autocomplete->removeInputAttribute($name); + + $this->assertFalse($this->autocomplete->hasInputAttributes()); + $this->assertFalse($this->autocomplete->hasInputAttribute($name)); + $this->assertEmpty($this->autocomplete->getInputAttributes()); + $this->assertNull($this->autocomplete->getInputAttribute($name)); + } + + public function testSetLibraries() + { + $this->autocomplete->setLibraries($libraries = [$library = 'geometry']); + $this->autocomplete->setLibraries($libraries); + + $this->assertTrue($this->autocomplete->hasLibraries()); + $this->assertTrue($this->autocomplete->hasLibrary($library)); + $this->assertSame($libraries, $this->autocomplete->getLibraries()); + } + + public function testAddLibraries() + { + $this->autocomplete->setLibraries($firstLibraries = ['geometry']); + $this->autocomplete->addLibraries($secondLibraries = ['places']); + + $this->assertTrue($this->autocomplete->hasLibraries()); + $this->assertSame(array_merge($firstLibraries, $secondLibraries), $this->autocomplete->getLibraries()); + } + + public function testAddLibrary() + { + $this->autocomplete->addLibrary($library = 'geometry'); + + $this->assertTrue($this->autocomplete->hasLibraries()); + $this->assertTrue($this->autocomplete->hasLibrary($library)); + $this->assertSame([$library], $this->autocomplete->getLibraries()); + } + + public function testRemoveLibrary() + { + $this->autocomplete->addLibrary($library = 'geometry'); + $this->autocomplete->removeLibrary($library); + + $this->assertFalse($this->autocomplete->hasLibraries()); + $this->assertFalse($this->autocomplete->hasLibrary($library)); + $this->assertEmpty($this->autocomplete->getLibraries()); + } + + public function testLanguage() + { + $this->autocomplete->setLanguage($language = 'fr'); + + $this->assertSame($language, $this->autocomplete->getLanguage()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Places/AutocompleteComponentRestrictionTest.php b/tests/Places/AutocompleteComponentRestrictionTest.php deleted file mode 100644 index 324dcf10..00000000 --- a/tests/Places/AutocompleteComponentRestrictionTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Places; - -use Ivory\GoogleMap\Places\AutocompleteComponentRestriction; - -/** - * Autocomplete component restriction test. - * - * @author GeLo - */ -class AutocompleteComponentRestrictionTest extends \PHPUnit_Framework_TestCase -{ - public function testAutocompleteComponentRestrictions() - { - $this->assertSame( - array(AutocompleteComponentRestriction::COUNTRY), - AutocompleteComponentRestriction::getAvailableAutocompleteComponentRestrictions() - ); - } -} diff --git a/tests/Places/AutocompleteTest.php b/tests/Places/AutocompleteTest.php deleted file mode 100644 index bc912408..00000000 --- a/tests/Places/AutocompleteTest.php +++ /dev/null @@ -1,281 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Places; - -use Ivory\GoogleMap\Places\Autocomplete; -use Ivory\GoogleMap\Places\AutocompleteComponentRestriction; -use Ivory\GoogleMap\Places\AutocompleteType; - -/** - * Autocomplete test. - * - * @author GeLo - */ -class AutocompleteTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Places\Autocomplete */ - protected $autocomplete; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->autocomplete = new Autocomplete(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->autocomplete); - } - - public function testDefaultState() - { - $this->assertSame('place_input', $this->autocomplete->getInputId()); - $this->assertFalse($this->autocomplete->hasBound()); - $this->assertFalse($this->autocomplete->hasTypes()); - $this->assertFalse($this->autocomplete->hasComponentRestrictions()); - $this->assertFalse($this->autocomplete->hasValue()); - $this->assertSame(array('type' => 'text', 'placeholder' => 'off'), $this->autocomplete->getInputAttributes()); - $this->assertFalse($this->autocomplete->isAsync()); - $this->assertSame('en', $this->autocomplete->getLanguage()); - } - - public function testInputIdWithValidValue() - { - $this->autocomplete->setInputId('input'); - - $this->assertSame('input', $this->autocomplete->getInputId()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The place autocomplete input ID must be a string value. - */ - public function testInputIdWithInvalidValue() - { - $this->autocomplete->setInputId(true); - } - - public function testBoundWithBound() - { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $this->autocomplete->setBound($bound); - - $this->assertSame($bound, $this->autocomplete->getBound()); - } - - public function testBoundWithCoordinates() - { - $southWestCoordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $northEastCoordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->autocomplete->setBound($southWestCoordinate, $northEastCoordinate); - - $this->assertSame($southWestCoordinate, $this->autocomplete->getBound()->getSouthWest()); - $this->assertSame($northEastCoordinate, $this->autocomplete->getBound()->getNorthEast()); - } - - public function testBoundWithLatitudesAndLongitudes() - { - $this->autocomplete->setBound(1, 2, 3, 4, true, false); - - $this->assertSame(1, $this->autocomplete->getBound()->getSouthWest()->getLatitude()); - $this->assertSame(2, $this->autocomplete->getBound()->getSouthWest()->getLongitude()); - $this->assertTrue($this->autocomplete->getBound()->getSouthWest()->isNoWrap()); - - $this->assertEquals(3, $this->autocomplete->getBound()->getNorthEast()->getLatitude()); - $this->assertEquals(4, $this->autocomplete->getBound()->getNorthEast()->getLongitude()); - $this->assertFalse($this->autocomplete->getBound()->getNorthEast()->isNoWrap()); - } - - public function testBoundWithNullValue() - { - $this->autocomplete->setBound(1, 2, 3, 4); - $this->autocomplete->setBound(null); - - $this->assertNull($this->autocomplete->getBound()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The bound setter arguments is invalid. - * The available prototypes are : - * - function setBound(Ivory\GoogleMap\Base\Bound $bound) - * - function setBount(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - */ - public function testBoundWithInvalidValue() - { - $this->autocomplete->setBound('foo'); - } - - public function testTypesWithValidTypes() - { - $types = array(AutocompleteType::ESTABLISHMENT, AutocompleteType::GEOCODE); - $this->autocomplete->setTypes($types); - - $this->assertSame($types, $this->autocomplete->getTypes()); - - $this->assertTrue($this->autocomplete->hasTypes()); - $this->assertTrue($this->autocomplete->hasType(AutocompleteType::ESTABLISHMENT)); - } - - /** - * @expectedException Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The place autocomplete type can only be: establishment, geocode, (regions), (cities). - */ - public function testAddTypeWithInvalidType() - { - $this->autocomplete->addType('foo'); - } - - /** - * @expectedException Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The place autocomplete type "establishment" already exists. - */ - public function testAddTypeWithExistingType() - { - $this->autocomplete->addType(AutocompleteType::ESTABLISHMENT); - $this->autocomplete->addType(AutocompleteType::ESTABLISHMENT); - } - - public function testRemoveTypeWithValidType() - { - $this->autocomplete->addType(AutocompleteType::ESTABLISHMENT); - $this->autocomplete->removeType(AutocompleteType::ESTABLISHMENT); - - $this->assertFalse($this->autocomplete->hasType(AutocompleteType::ESTABLISHMENT)); - } - - /** - * @expectedException Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The place autocomplete type "establishment" does not exist. - */ - public function testRemoveTypeWithNonExistingType() - { - $this->autocomplete->removeType(AutocompleteType::ESTABLISHMENT); - } - - public function testComponentRestrictionsWithValidComponentRestrictions() - { - $componentRestrictions = array(AutocompleteComponentRestriction::COUNTRY => 'fr'); - $this->autocomplete->setComponentRestrictions($componentRestrictions); - - $this->assertSame($componentRestrictions, $this->autocomplete->getComponentRestrictions()); - - $this->assertTrue($this->autocomplete->hasComponentRestrictions()); - $this->assertSame($componentRestrictions, $this->autocomplete->getComponentRestrictions()); - - $this->assertTrue($this->autocomplete->hasComponentRestriction(AutocompleteComponentRestriction::COUNTRY)); - $this->assertSame( - $componentRestrictions[AutocompleteComponentRestriction::COUNTRY], - $this->autocomplete->getComponentRestriction(AutocompleteComponentRestriction::COUNTRY) - ); - } - - /** - * @expectedException Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The place autocomplete component restriction type "country" does not exist. - */ - public function testComponentRestrictionsWithInvalidComponentRestrictions() - { - $this->autocomplete->getComponentRestriction(AutocompleteComponentRestriction::COUNTRY); - } - - /** - * @expectedException Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The place autocomplete component restriction can only be: country. - */ - public function testAddComponentRestrictionWithInvalidComponentRestrictions() - { - $this->autocomplete->addComponentRestriction('foo', 'bar'); - } - - /** - * @expectedException Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The place autocomplete component restriction type "country" already exists. - */ - public function testAddComponentRestrictionWithExistingComponentRestriction() - { - $this->autocomplete->addComponentRestriction(AutocompleteComponentRestriction::COUNTRY, 'foo'); - $this->autocomplete->addComponentRestriction(AutocompleteComponentRestriction::COUNTRY, 'bar'); - } - - public function testRemoveComponentRestrictionWithValidComponentRestriction() - { - $this->autocomplete->addComponentRestriction(AutocompleteComponentRestriction::COUNTRY, 'foo'); - $this->autocomplete->removeComponentRestriction(AutocompleteComponentRestriction::COUNTRY); - - $this->assertFalse($this->autocomplete->hasComponentRestriction(AutocompleteComponentRestriction::COUNTRY)); - } - - /** - * @expectedException Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The place autocomplete component restriction type "country" does not exist. - */ - public function testRemoveComponentRestrictionWithNonExistingComponentRestriction() - { - $this->autocomplete->removeComponentRestriction(AutocompleteComponentRestriction::COUNTRY); - } - - public function testInputAttributesWithValidValue() - { - $this->autocomplete->setInputAttributes(array('foo' => 'bar')); - - $inputAttributes = $this->autocomplete->getInputAttributes(); - - $this->assertArrayHasKey('foo', $inputAttributes); - $this->assertSame('bar', $inputAttributes['foo']); - } - - public function testInputAttributesWithNullValue() - { - $this->autocomplete->setInputAttribute('foo', 'bar'); - $this->autocomplete->setInputAttribute('foo', null); - - $this->assertArrayNotHasKey('foo', $this->autocomplete->getInputAttributes()); - } - - public function testAsyncWithValidValue() - { - $this->autocomplete->setAsync(true); - - $this->assertTrue($this->autocomplete->isAsync()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\PlaceException - * @expectedExceptionMessage The asynchronous load of a place autocomplete must be a boolean value. - */ - public function testAsyncWithInvalidValue() - { - $this->autocomplete->setAsync('foo'); - } - - public function testLanguage() - { - $this->autocomplete->setLanguage('fr'); - - $this->assertSame('fr', $this->autocomplete->getLanguage()); - } -} diff --git a/tests/Places/AutocompleteTypeTest.php b/tests/Places/AutocompleteTypeTest.php deleted file mode 100644 index cd0f7710..00000000 --- a/tests/Places/AutocompleteTypeTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Places; - -use Ivory\GoogleMap\Places\AutocompleteType; - -/** - * Autocomplete type test. - * - * @author GeLo - */ -class AutocompleteTypeTest extends \PHPUnit_Framework_TestCase -{ - public function testAutocompleteTypes() - { - $this->assertSame( - array( - AutocompleteType::ESTABLISHMENT, - AutocompleteType::GEOCODE, - AutocompleteType::REGIONS, - AutocompleteType::CITIES, - ), - AutocompleteType::getAvailableAutocompleteTypes() - ); - } -} diff --git a/tests/Service/.cache/0/G/+GzvChCNKC3DaLz2oxPg b/tests/Service/.cache/0/G/+GzvChCNKC3DaLz2oxPg new file mode 100644 index 0000000000000000000000000000000000000000..b5e2f6bba6f8349a6d2321c3566a180ad8c7f4e7 GIT binary patch literal 2486 zcma)8*>2-D6rJaM1;J;jkwke34L`VPk`CG|h%1 zgmtKS!s+!N_JMWZqG=;cqfe_Gq=F|=WEt!&#!QM_DoqE1$BB&#|MavfjVw)g_oId* zSom|nov)ZvQP=Y#6Q-!j<9`t3fMheFv^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odZl)a-Gqi6+&< zeC)DwT-jr5gkvuA&XbN}ODTpTB*g_YnkgR2g#8lOBHEhj#{wh+p3XNWU2=NvS;0FI zGy^tq!PdSP^OKOrPn5aTHQX+1RFWR}KGfSz4OPTW>(^?^UTq^a=7|FDl#8$JUZu?m zyC1!puxrCv$l@x7hh0A})7GFkW@Ax1V-p@DW9^F>u@QtluIInmJ2c9Ir3@NkQ`%t}JmJh5~4sn^I@4tU456_ZB7V-|)gWn+jdIV+~s`Rmzb z%5FfHv(})(UV|d8_0{b7-bzk*5YK6>CY2yRJ`PJ!)pcBUsZvQRD5htVvw&4zw`$C) zLl&I9N=|2IPc1d%9WJC5U@lVI) zaUo@er4^pBCDyAO8Zf`qFiM%d1KZnfg_pHL_Nu3L! z`9NB8W+|hu^pgMdfuvr@=%sXCXD^NHZYgt*kJkV3{vYfA8XdkoT<=Yie%c$!Z2e#T p!_A%j&5iBtjjhe)$!^-~WIg|plRI3Qb*|U{)j8ZaeE0tS{{=z!$GHFi literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/6/W/0NC+6QA9PyiUswxLXrlg b/tests/Service/.cache/6/W/0NC+6QA9PyiUswxLXrlg new file mode 100644 index 0000000000000000000000000000000000000000..10a639b1159b60db9ce71119af592a580134baad GIT binary patch literal 2486 zcma)8TW{Mo6wY&g1;J-&kwp1M!w;U9WW|~b;fL^7AY$)GA0yEYJfSx*qWN0wsc ziPm?9A*6+-2U|7AS(Z>vJf#8hBM*|-n;WQp<*CW|6@ zaIltvT~uNz{hQK&c2f%jcphGz-`st;{BZ3c;Kp#FWtF3d)?1P6B?FB(X8gZ8ODqI+ z1HvCaV!73@7^wrSvhHTh^wQwOa&M9RB2*k#@D=C#;}Ii6xw| zZwco%_gJWK=BaAvWfyC%Ia;m!l~R7WMJu;|NH^?*Pb+_F`Bbd=B zI4U{GF_PIF0r8dLl3i_>1r#zCjuvQ}rG?wvPh1akDWxHqh6a z*)z_{wVB4p0$XcI`5-0>Xij+e6I~>b{;KZx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Vd8p!6?3 d8g!}07=FRp#SoJgUA$!xM;{JET%eby;lDvl8^Qnp literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/A/y/OYhD4u1fh4kR7UkMEE6A b/tests/Service/.cache/A/y/OYhD4u1fh4kR7UkMEE6A new file mode 100644 index 0000000000000000000000000000000000000000..0e50c82d1d8a695154c4d64c0a4fd145bf91fd04 GIT binary patch literal 2486 zcma)8U2oeq6zy|<1;J-&kwi&$X!ya)lC0SBfjBJ+ti?b}bgadeG?7Z(1o`hfBxToM z$>Ik?>sCt*L$`Yb(}W_gl? zM}jB(S@AxnjZ}42DoF>|Jc>EJXrG?u@^`K4uQ#gceZ5`Td1@F8ln<|AJ~UFOs=S#s z!Z=hs;`I6t^T5)#Xi5v+s?#b5so+r%7zTTbF_R*fjiLj=!^p&ie|lP#T9(?s`%%LY zEd06P)>p`>sOx!=30+j>@jnQ1K(d)=l+?pdcjtbe4qg;T`o9Ui&5cetJ#Pw+gb^9F z_aq9!6n{MI@vu)WF7GU}$LZO!E>O&^gAI8sG|21?a)?wp2HWP$Pz zC-W+MaJ0nG&Kt3i{&j6g+o^>CP99yJUEhAZ_;}?g(8g%4WmBSv_OvS7Nd|~GX8hl_ z$SehQ1H&IbV!6?<7J^AE--Nm98#${w$gwTjw&=x?}$dc8gkj-TJJ|s=O%g-6@Fst`Vi0%Etd` z*~kEZY}S?!G6w-&VAy#5-Z(j5q1HQ+&N@kJE9pZrx2nypYBvO|IL?zRMcUO`pYVbr zWma&;zZIO@+)<&zou{gkmtCy1=47?>mrD8dhOFHFzTB`6JuUsI)l;?7liS{t8MYx5 zv6hlK!AZ$k4vEa>2#T+amh5V+EU=KVaI!$#tSsE-j#g|5AFV9xqf-c=D5qXET&|_y z3DZ%v||!e>~)UPn6C>vsDaxZ!eeJe<1r2yZs(pOhxo8^<7Q)Y zXrQl<#S`wzm6^te0$ZV^d=Qg4kP{yM4;BgJ@5O#^3cZPq4qc%xhPEk8{mf9RXEi@Q z)^btXioTIv)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?EKGfSz4OGNV>sM;RUTs4);)w$9m5Zu@Qtls^>>oUVYEd7SnG&7dCI9^Zqhts#hZKStqHWV|~+Eho*L0Y}EMy?p1dZ`#5Kq;4pajoO{ z$CqZ*;;}6q6|pZBEBa1n$9^Md#jGS`%@aF!AA60A<$$+rTQP1VJZ52_QZ|OTkkevX zoxPc!r|brFK5g|Y>@_IjT2D<6@2upA2k{)oYFr8Oqr*RQPGRn``rONcr!vm;0t%fXWwnw2}n&q3r(uCz`=Byo8VA!A#pL%)s zcv|#$!q3T=U9OH?xQpG#QkgOitl)Z+U5E@?VKa&wHnf{n#|P=5-=OW$8<#W(NH%1z z690Hq9u-nnSX$u;TVlPwwjsH}$;20(lJ{2JS?T%699_c^FjQ6<)w9Etb&SX3<2%zk zy{n|4ZskU)qM^zT*y+f5&rXha*pEml zl00VOsy01&-}2t{@{!Z6xv6+-cg#ywW;b-}3$Xd+TA9`1?afVRA(2<*`j?P-^^R5e zJgIXoH1A1k&Mai~g7{nhR`>80JF t%vS&G?XPd`uCHxw@_@g^$;-6c$-4dnC%3pV>s+n=+1X#)fB)gb{{zt%$KL<| literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/L/B/IG6IT4HHJzhrGCF8jbEA b/tests/Service/.cache/L/B/IG6IT4HHJzhrGCF8jbEA new file mode 100644 index 0000000000000000000000000000000000000000..331342386fe61f9c555570b62f3bb82cdc59034e GIT binary patch literal 2536 zcma)8TW{Mo6z+3=1)*nY5k*P1Y52j*lC0QrL7WCH)?#2JI@WAUnn-y`pYC2zUR&t&i1Ow#5YdRkqDO6QnPa0ti zDjsp~>JPJE>02KbJl>=1pC=3mPy@i-ak;_JTeZgsD;=;doQk7bkI=KB&!w@9= zx!~3o<({bPS&<1{RORtM2(nMIiD;D6gHN|-LD%cQD30`h6M7pP^|*J|6h5I58MY53 z3TcWzPCJ}-$@#^tMRvG%x~K~jbIY*-kAw!8y#c03^+aS78JG;3YPM|y!Po6Qg7?W> zECTT$2i-IdL+coI9m(cVHd`1ZG8bbcf}|)^J_nyiqu{!!w9HHewv>%~+9z|Ae{esm zvZ;e526onnxeTsq1KLiFhVVSRIK8_0c>eLyLBNgSOv|Q35v{i>+ero*am@I?ZIM|B z>IOtGdc=04VKM4vbOs)Wx`*JzAWC{*M%X8h1COOXOMDjljQK3`8TDD{xfqblFw11E zgBwvk?DPY5DXY@e1?xM}{Mho#Q0pc7PoP`W+F$NZ%dE-Wad`4Y9>p>(#Sw6>H!M03m9+_H9qz>344Trtw_*8GGO6e+WW zGxjav+~E!j74E#Jmh`fl71tcC7QsTPpx&UBJKv`p&cUZeFt&WER(x{Ddo;r_h$7Zh zG9Db2oa7M6Y>t2g%5cf<*31G584E`Xw9V4O9qw?&mhjQi!Y&;{po((pRm0_)3Qll< z38v#9*y|nNOv&88U#K0Em}0MEl*W9W+d&Pz-61@3QZydpkl}Xj8FCsQR%YC6j1CR- zm1gmTyK-r!@u9$0T2fBM{S2D-oc@n463E}H`@JdjrfziT3N2%3o5Ix345fNf^W$SJ z=e4cq8|h`O($)MzYQ&_483ZAJelfQdt-G&s%m&4i6mFl72q9iBl`b&bFbn?{d5&SP za9;^0e-V%31tu4wnMzGY82BSm5)98WD^ynbRcs^3AsftEPA;_H9K; z(hD%|dgMzxtx9X}4yLLWbKWPvo{+ob3!yg*c14Nc*9M#Fy9>ye$Ir&?mY$r+IbO#t zxf5+@Ep_t(PjZ<_liZ#ZI-ZsbZG;~6lPD$Axo0zS@b$m-T@a?h%c=@^ewp`kyWjl9} pFGq$yc*&M?c&N?S4UIcAWDH+xPMG0JXqg`nf`p(Z9-JjF{{s?k>pcJf literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/M/X/Idjx5HZUUigUg2-PS0kQ b/tests/Service/.cache/M/X/Idjx5HZUUigUg2-PS0kQ new file mode 100644 index 0000000000000000000000000000000000000000..4072af09d646a395a37a23896622fd89ce553b32 GIT binary patch literal 89708 zcmeFa+g2jWw)gv8ucxrp&37}ZmUy;in~jLb14)vkm?9!t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ff_vPpGTY z&k0)$BJJ7S@G$$DsGkz{bE>XkCoD;y6L9~k_FMT|?NfaD=VeXLLp#!AmefAkmnR=C kPTrpZLh#4)i)y6Hi4N@14=;YenTc%HKFOEwFE?fRU$w4kEC2ui literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/N/G/WjiVLJAzRsi8tdJXKgow b/tests/Service/.cache/N/G/WjiVLJAzRsi8tdJXKgow new file mode 100644 index 0000000000000000000000000000000000000000..6493e72c7585f7ff20f6381e886a8e5abfe2c379 GIT binary patch literal 19019 zcmeHP>vGyk5B_B+-#{qmLxbmSj;RYG0QP z3E7(BD27OMVu`A4y|7Hh{1KVDSqVur4*ZBzUban1HY?|o`+JYPjpOm3mr@}#-$G(Vfqyv+Ey^%5C9~3gM}J^-6Im2n@g!;n4iLGfB#M**Z=x6y%OPP@ zd1;vlQ@Id4su}n(@#E^%-53}_i}}Mf886YSSmUwh+E(laer-1LUJCZm3L_GqTwk44 z^~%e?A``TKZN+I)$uKKtp?f4CNoY(4f+Qjp{+LKJB`ln`t{A0eR^H6UE{tXBxs^C$7y%sLEbk?M~s6n`9XVoAx=Wn9#if!dWMh0t*7nNtm8guzG}*BP<_be1xSV zjE=BaNn`+J=pc^cYRB>iYm*4$;s<^*F7W%472c(ui(y>n)bD|M0uyvJzkcJ}f#dpv z& zyiFyV8!5Y3SZrdPv+4|J$DDB{_p?R|_rWS>)f;A&!NMw&+Zkhp+hA_i(je&*5`#=y z@=TSD6p&OSYLV<}X`es^<3>jVj0+~88CP<1ZX*keV-qoD#>IXnb_QKxG~P|%S$6s{K!_@Ty2Rsb0R1FDMLH&1tD*?Q91pf2{ z=1Z&y3p+TeB5KX~0Yi1j0Wl8yyLNDn5O1mW~QL=h3r+5kxZ}DAiA> zdx1ab`QRegnb&KpCe||=24P&#m1|>t*$`zls^tptuxL!dO#;n3v5c=OMRG0=yiqnr7%qE?2A@IL$T9rCv*kUhji>IMKsuXpmXvJ`kyzPFo(O1~Ozlmn)V< zLrZa8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X7Y|!PV z8Qb0Uk+f5p6c;y~Gw2;#XUz>n$P{8+T<{zN=FFW4* AkpKVy literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/O/+/eEdAvTWtWvIQWFIstqLw b/tests/Service/.cache/O/+/eEdAvTWtWvIQWFIstqLw new file mode 100644 index 0000000000000000000000000000000000000000..0fb7cb81f3672e48dcf889f4321f0eed3d666081 GIT binary patch literal 5469 zcmd^D+j84B5Y4l{f`iA7=#T^{iS+nERqfPi9J`j>vD;)c5D81HDUu~YU*hpE^r!k` zJpgqfb+ObLCl8GtG$gQ#-90$F3&ONpv}rkpZR|B|ZrIE*hk3lQJaYDne4x#j)N;W@k#~~-N}*>NhSZ=hX^c4wc$Sj`=9yIb zWx`Z9i3N{^-hWK75N5om&{J!f9${%3g+3Eu62JWuP9A9fm}NN^hnM|hy-g0Da}VMF z#6(@!ay@dKg$>QLv`#V7EW>Q#&of(aRC{;YSDG!496h8Vz^oaT$~`8aOkYq&1fTOPHtOAgH#ZtMxVre

zv!D+uF-4BAEL2LonJrV6Woun8nMsCUkZ~VnBUtCyOp5bcHjE%S^vo@?2q4&1_C53Q%pq`O8jJLOUJ4A_O0NPR3Z98cz%(KWOB*{d=gBS6T^FYmN}2D8zuoN3?ip3 zB*D|3rfITG7m>(`=4pS(0sPcN`AAq0Kq4Rb$pqaTO|T|e3RUE%T2T^@1~CeVT$Y@( zEX+w`x_T*sf0B=rOl%jE)uyzn5i|rAh2oJkG?FHGLg$T$_PMt9bKTT8bdLp-Fb+XR z90%_BfPor=h~M#OV7;ct|NI?sJ>aq*#y;PU>{j_I#G7LIBus>c56jlR-E?vMa2HXPGE2mlrt_o_<9oi7>9*-OE&8%$ zoc>Lht{AQjEV-eQR-N-!P?H`;^U&K)vuWBZ_Q^bK>R6U#*2CUpY@iM)vix+;&o9od zPEI@hqa`YlyO7_f*qpWd^4)FQViT*Nk~CsIAB2GfiFC&&?|*9Dgg=hm!nyS?uHW}g z+38ugd;e<{TvE-@Ek%27tdcn2L*MzpCM?ssvV5U>Ex<2xdAU1ok*?ysxq`oH7wYo| zwnJO*U#$slH+NsP;atWc3cc3Dl>m+tTk*c^t&yp^{nh$T|Ei%~_BvJbU%l~Ay5FL0 z+G?9Cz^EEsHXhw|_HF9ejcXu1Nc#?crsYn5JDL5KZRmfri3@D2`?=bRCXac1Jo^2*mt0@;ZqEB3 ztn2p$?u;rd{!gt)+WoAQNqKjunjWqi_n!CUmlJM+ruP^fA+HooyJZ@b;)=AK^l{=x Sm02^1&o6wG;lgJ6MfNXwTzd@w literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/O/3/Z11lXG43qQ14lYU0JXtA b/tests/Service/.cache/O/3/Z11lXG43qQ14lYU0JXtA new file mode 100644 index 0000000000000000000000000000000000000000..1fb9ca6c9874f14d2f0657111b53ef5655930053 GIT binary patch literal 39659 zcmdVD*>>8>+VA}yudDFz$v&Bx%YC=T8dQ}U1O|*T#)Q~d$U+ua7K)HDA%y!`=ie24 z>&Eu4AjymqJJaNiGqMxYNhMYHH21QgYAR&!-Ktp)wDZI2Jx`F`mdvdjje;#{M}>{ zb)76r&a1<8_q_J${K1aCVv|e$=czLPlXg49L0k>fj=tgWVB=u*=um&z-1**R!>p6t z4UK`%MZJTKwKaXk=J&1$yB)uq4p;xxIauG&?c#ma7{pmO&R*5uCESQJ2k(0a^Lwoy ztag$l>RolR-XQ*GpGN*`|_tG-Pk`^wbR}oE9)C8 z^6q+NV{Lthw}bWFgSDNNe7Qcqa`#}>8Yevl^FhV>;*(Cs#hc%`c%7~qovX0>O7|cg zL=W#lwj#ntuER?XXMpYH_2YrI`Q>a^TD{p zgLpA6d~bBpcMs~_WUN14UE=CH#`=$szpeOc;P>L|MJ=?uo_6A4&`n?cb>@p6P~a-O zi*LF<7cdK(9C(^<7UW!EtiK}ZtB)j|%}M$(GM`heKd0I+2zYovecewKIsf&UKDi5n zbTub9eg8SZEe?J~g+q9Lb@-9I=085s+Jdacug1gStKmgc`cQx;dz6W;wy3X2n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`5C)Znf^t12z95`kVVb*DAY@{d~;ZuupG^twc`p58x-O*FYlgAiylw- zIUTdh)v*hAvHMsmQ^tW6TyL^VkwGhLMsdrAcC+gEFg@}cv^{#`lI8%(hU``1pNz_* zLdptDD?DXOtk*X-BsVyn_@Yzt-imuGy%?FJ8#n@n$||FJc9gP?@nn2*Z+d6iDi$?MEw&svSEYHq#Uvb$Z2rR29;biRM{ar9XapW$?+ch5h+EI$4p$; zrl;>)-kV-Na=JA)6>sg1d8NwihHiZUHosgevpT%Hz3nU{@~T|_5;CvevkIRlbZy~f2{s%c(8x4+8rmov^$j9>c4si o>s!0)Ynz*E8#{}WS82DCb^S+9ZgFMSxnBKO=V0yN{f7_#7o?-dB>(^b literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/O/v/P5LtIbOLpceRXfKhOCWw b/tests/Service/.cache/O/v/P5LtIbOLpceRXfKhOCWw new file mode 100644 index 0000000000000000000000000000000000000000..430f9e62f4d44346678c848ff4ba22e584d3078b GIT binary patch literal 3794 zcmd^?&2rl|5XW=&Q*dzXhz>zeU-0;#Dt79$j$F&_q|;>#Kj7qT_4R8ae^M&{cu^MJkC*Fx-q9KiDzEm* zyegz9v-DzK2z_A5eNIL{>j&0(POVfzRpl^?pcHcipf%WY8gnTkS(M~RaLTk_6sCq* zs${C%t1meY!VbTWxjBn+BJwKw;bv_gKFmZ9_`>Cr(Nz-=k58G(d=?^a+k+QX2Y;n9t#C!_KY$jAVU$(rK=+- zvZQ$ioX@LkINx#>;?5N_dEDy+o@WgEusjGuS(a;McaS96tvf2>S)4Xb!a+Y6C0xc> z7E4()wh{e8Oc6aYK_T+N{V*Q87e%IIsMFRE);`lCXMsCAzD~06#;Uco+G!yc(jDbm zshJPz!SdkzWORA<_Uye?0Z@ZP$s$GOjkPS?$N(gQfbq{&92ylJa-!Vv60fye4v=gu zb4)nI37iwhe!CBxyd!6MOjxJI+AS8e7;7=V#b}Fp#QK0>bP{vrUW#Y}!UmA89^19Og1=@PN31MiXRjXDTdb)ZZg?5YiedSpblPRdUr6$t6J@N@HCkAP`*li%*1j+^0&<)Ee{6Sw4>~bJjc*-f zC0?zMv2EGkHA~i#@mEybdp!ttIkuLP@DHFdbN>3Zl8fAA^qKI&s#MwHTq^jagl;Duzkkp*kE^@RB6Jvi!5&)6{ej~+dQ4Y| zDv86LKlK9s%!Yj=B8nhUPQq+~X^tV-khDTI`IT0ZrL#$j2BME87ovzu(psHvMev`L z^Q=%Wi|KA-tvUn)K_s#ILRt>VGdyAPCdB#FIQyY#>OXW(M2k3$0V6&KmU1G1#w3wT znN0le>G3~*C(@0io`-2DU(W1{^7Rz&kAZ&A7{1l_)5{(4)%^{#3RB|+BA)p8RD**| zvtl8XlF?+v`4g`#XWK(Eli5OQW5BwJ6>6(WBZFykLxY}za}3o|ZR@QIMwq>zci8uQ z8U+2Cmrn(gVBo{De;9Q7`26TUMP+3+z}KeBtWxt^`Aw#KwB7Eq=PmnwoA%k3;l{#- z8>VQ@civXkw1>%K=)HEQLxU~*P zm((ltg{J+W?S3-XPV5ghV+p_S4jvBlxWec6>f>>s^zS$tbg9P}ewW(K5N#GUykiqH M50emI$*VE=FU{f%vj6}9 literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/P/B/IavO8VJ5AzalRMSw6juA b/tests/Service/.cache/P/B/IavO8VJ5AzalRMSw6juA new file mode 100644 index 0000000000000000000000000000000000000000..809718a9b182e0dc8e77d3721a8408122a70a732 GIT binary patch literal 2486 zcma)8U2oeq6zy|<1;J-&kwnQ(X!ya)lC0SBfjBJ+ti?b}OsvJ0G?Gf)1o`hfBxToM z$>Ik?EQ7tpm`YJdrRhNMII(fzpPtl}k(CK=e>89e z3x6)T^A&R{nr2q!!jyG&_z!{{kbEkXmS*_r_AET2gBQ(_{%^u;a+70D&r}(ZI3c6< zo+MG+!yk|P2$Y;(+&X5T)6+#$qL>>8Tk=>Kkl7pL7^$9!d@4hmfvRVlJ`jAB~TRVbo6tpw_52FUQndm z3C{X=g7ceOD%801R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X1<)U2Mc>Uu=OOHh~27L)33)3_f5nG z#vK{5;GiSpd%mlz8L%f$C9BMuZY^QCP9bKshan~4CW^7Ju&Q236dfhL($FmZx@NufL6>~c|KaVehGavsgOJ}Zi zqxzSsf1^@1Xk;r6HX%B6OWB+3bVBhnk1eS>A|1#vdo{;Kp9S?SjX0XMC;9MNuOITo zt(mcBQ8OB=4r{|=@u4>H#8oMC#lYr_J-KCro^fo=4ue~(J-cRg&-9YbB59}+{7&vj`gBqW<+!NPyS(HXISY+db^uh8jMul)7M$NRNVutpu2-*P) zMM@znNvz}wpOni}70lor8?QxIA}t1Ny~{Qvt)wzNWq&hvwJU|}K2jO6M`t5qo2An! zn~$7wlNn>oYPwdRH0O(1BR+E3Ij-!nHNp{>d1pySv85D45t8D98O;#2$}(#xL|AFi`j9=<0r~o>Kg79YgCdh_&(IzP7PGVPV3id z!d`7dHR6c^@0E+M?OvtLF}okV91)ig7fxHw)<_(#*X!fm8?YBm%z*4k7@&S6@;vPP~L zo_VPl9zrQsM{%v=_$OCp)Z(!%9Tl-J6)XDAW+#3lXvM4~WX%&hcb|BTjOBoLY+EsI zBs^wepi(x5xRldkTAjU_UZm^>bTMu9E9^BW;#yBlkM6DHm8;0(HoaE2S_$#uM+=cR2~&lR#;l$DO+N_zOf;>!Rf>oos#!f+*|3z$Q<3k5inF% z8P&6+ly!_J<&F^_v5{6`oc(Vc`$Hwcz1i- zSxDqnx&Aq1UcF}(K2PeL3(W`8nllR-eW{oHrw=6cTt+XX^D293WOoahdvv(^j}QM? z{bP8rf3VseC%v>gl-cSZy@U0w-SxH2&9#mF#mTF*+sV5ABPX}GGV5Hg{?R#DJ9z)$ G!~X-hwZ)|X literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/Z/y/k-471oym0TOSmHsBQALQ b/tests/Service/.cache/Z/y/k-471oym0TOSmHsBQALQ new file mode 100644 index 0000000000000000000000000000000000000000..bb8ae916294ff4c6605feae03b1dddd011e56cf4 GIT binary patch literal 21854 zcme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tB3AqYxARdRynZd%I9Czf;9fZ4A{(DF0X7LLTS_x{ zc$9qrQg@X_&}C#AWjlV@F$_aa@<}2%G6Lgw`2c=uL0=*oMS$S_FdM_bhdEh6YETJ3 zlS;C5*iWIU$ZgR%aPObLP-C{e#=w8XM_D1Bfs;K*>opKe9Gb-94mAvvXK)4MIYGvk z%I1$%T|d-78ja&L213GH!<6+Y(4(KQDNFj+OWOSRp9wP~CP!`>vhBg$iZ2Iwy$|>$ zeNeW4rQ3}^>eOJ$28Y=MrpXpkJW=FJi63Z?6=Ny{i~2LNmq^<%YHUP9mW`QI2kfqL z3rcK~MvAM|1xfc5*beiSi&eRK-B7h=d%J$q!nW;~?0hPl1l|Qev$boxKD>$ePkw34 z68oiUo=wE)hCNHQhaIOyHfy#l2m542apl318LD#C+vG~rq=m`Cbrl?kPPzJ2<%cwH#bjuF)->d!ejUI4?DRVqUgNS4qwEsfB%m z3$^7}a%ZNvIvw8?^oom{%y>`7wAgOvR(#pu^^N>Rhf$ARbNY-J_bzJud!D^7I(WK* zrgz4tuPjQl@Lqn0t+tz`my?g(8cf;r?=pg7-Y|4<8^%VXzxzxgWVb~;((>?1s8svb zGs*OwU7I+z<2-ed+NzK;&mKyk+r`*(tc~+f>UOP`Z+R=aD-RZpW>Jp%fTzCu&*qXe z!EO4)TQy-mn52FOe%SJ7zh|lakrV1al*Fglmh-tfrN(zWJsN(x>}Hpp?%=%l-nu-Q zz@b%%#osigq~0$|80iB@H4ovua_4bJep|tL(d_i2E#$c*wp+MK2%NL(#Sp#+;9aw3 Q5kAo1vki`UX5Vc80=3_k4gdfE literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/g/i/R724U9mpkjhZuwoQvgHg b/tests/Service/.cache/g/i/R724U9mpkjhZuwoQvgHg new file mode 100644 index 0000000000000000000000000000000000000000..b02f53098d356e970e065b191eef08a8cbf9dade GIT binary patch literal 5519 zcmd^D&2rl|5YE|8!NIX3Is`#d6g@tuik;exBUMs5cAJa_A|Z)2|4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G0_d8LS*8ny_5D^fk_!-*fN S%$7;`{DO}%xUiXjk^Kvs{(O1> literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/n/u/wnUryzMtlAq1P2MDMNSw b/tests/Service/.cache/n/u/wnUryzMtlAq1P2MDMNSw new file mode 100644 index 0000000000000000000000000000000000000000..95ed6a0a92b5c829c8bbb77e2b64689f75996236 GIT binary patch literal 39659 zcmdVD*>>8>+VA}yudDFz$v&Bx%YC=T8dQ}U1O|*T#)Q~d$U+ua7K)HDA%y!`=ie24 z>&Eu4AjymqJJaNiGqMxYNhMYHH2L%yzX|exwW;nzP`KP+4sA9 zYrEV2#_rX+*YS7u{cUgCyYlvSgMV}mwh!J95B3gL)9x@C#KZ3Dzm5(zwhmVFcaurf zb+RluuMX4Q^V+BL2Rr(TO)mMLr^@_K+U*PnaWzak`i8@Ujf2&rL;YoQ=X;k8vrcw5 zGzLBw^$s@H*7Oyd-@790cKmKST>V$)V0}Zki}zJy5NF*udsTmza3jtfyzd>%@3nrg z+DVeAch$*ygZQ6)8u_o4tFV&}yV<`_>-MX?)qi~$9?*TWlRdn4WB*{)PJ4f>tZ%Hy zyX%#Wwe=m|4%T-LwzgOD<@)@}-GfzYob(vX2Nmm!PdXVFZ+_?Eb-HSFuEOps-Gg)x zJ-i2vPwqS#|HsO0XZ)&j-Tn98&eq!6ykf@nq??Yq>4R(N$ZaQ}BXo*}t~OsaPflJ{ z(?Qm~(j)Mou&#dnUn{o^|G&LxaCNh|Y+GMur=8pGtD{6;^ssB|Yt$^u)={mHFH{zn zKpQg3x@pWH&TAW7ebpICY;A2GyuIsP%`aixxZ>5xh@W3f*cRia%lv!wfa0q(uJiAW z?R_X??O!XSf3I%t{IR+H$L7`_o11@ZZv3&i{>SFp>Y@#FMqXWYlk8Qk6JLKdAB;;p zh!^9+_eLju_n_WQ#`@#cC9b|>tpE7<+lsFSelNaW)Iz)KX(t{A-SpL8XTInG1+K!o z_@?V~0kg2lfv5RqLCzJ%`YV#Y`bg5*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dUf z7b&{|T})g33VRKTxYkqCqkAhk=0Q9su^Lx`{OBkwMOD{v*`-P)t)Q5mj!y$tdEKfJ zs}5Ok_BuJ4o{sV}cBwM`i|`QYPOBk{n(a}jmuC6qury&gnmKF76&N-s#AjaKJ((6g zp73)zW|ymD7w%&Bu~epv11q@RWS1g?R@jW+1G2R##N7Pe%@s4_+ic1#@oMON1GaR&L)j)!Z>k07!1j! z)jwmI(#dV!ea#Zf9-E2!Cv0TH2AxScWDk(j;F=98xoD`eLv}iH-m{bAJ@z9~iX@Mj zxUNl4-?zLsy?o?!Yi=su+8y&smDvs5`T}fzxmIR%cz1i-SxDqnx&9?&UcF}(K2PeL z3(W`8nllR-eW{oHrw=6cTt+XX^D293WOoahdvv(^j}QM?{nzkd|6sK{PI_r~D6`dn q^$ymzcGuT7H`ms77bmaMZYS&dkDT1%%B*v}`mfHx+QIt|AO0^Dm&ZE* literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/q/T/qlAToFSNCJ-FOlkd4sNw b/tests/Service/.cache/q/T/qlAToFSNCJ-FOlkd4sNw new file mode 100644 index 0000000000000000000000000000000000000000..0fbd85ce0979755105346bd76ccbf0227b4dcd0f GIT binary patch literal 39659 zcmdVD*>>8>+VA}yudDFz$v&Bx%YC=T8dQ}U1O|*T#)Q~d$U+ua7K)HDA%y!`=ie24 z>&Eu4AjymqJJaNiGqMxYNhMYHH2j<_WjMBz1^#;JI9p6owe@T-k#s}w>$egJOAh$Y#+QI9_$^grrlvOh=<+Pe;plcY#prT?ttDSULB^p=e1Ag4|enwn_TigPnG$fwA&dD;%b<7^bLmx8waaLhx*Ir&i5`GW}WPA zXbgNV>K$yXt?4T^zjsC0?fBhvxcaZo!TN@77w@aaAkMmR_Nx9a;YOS}c;7pi-)sF~ zwUZ=K@2Zpa2Jt`pH1c07S79d|cC&w<*6mk&tN;2iJfQn#CwqA9#{R*oo%a4%S>ITZ zch@T$YwJ6_9jxyhZ0)b)%k}w{y9cY*IO#E%4=UCdpL8-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ECmwDQCsB zI)5{}NZAeOV%8c|*lSS4wZ57i-C4;o58^qA)ua;S$46l)s=AKLE>$XN1;zAqavHG8 z>qd=Pb;yFV*U8E3bex~FOO@$ggojXfS`As$Y>z{|G|M+fr76qN%y~Pmz_39fKJ)VK z$*kz{grCz1yIdW+a2LCer7~q4Si$usyA&C;!e$gVY-l&HP7c!}zd_rhH!f)okZj0a zCH~2{JT9cHu(ZNcw#0gUZ9{Uy)2S~yCGV}cv(k&PIlhJ?V5qDzu4hLn>ljZaCwHcI zc2`Nu9V0$sBdx;N;ei9kjR}OwzFs3Wsd{Yl^Cn}*4{Odg-u?wU+SHhHHfdxN#;Nnc zU`Q^l!5PbxPHyt8HJs s%vS%^KUm+|U0>VO4?|m??54d=*7F}Yxy6-P=W6v|orAT5_a8p|Unu3q>i_@% literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/r/+/W4JvLH5KNZM1m-qw2EUg b/tests/Service/.cache/r/+/W4JvLH5KNZM1m-qw2EUg new file mode 100644 index 0000000000000000000000000000000000000000..785457792851cf8c64631897e8fee873ef33ee0a GIT binary patch literal 39852 zcmdU&+j`nc`ltWLeHDIuGAGGu<9)oIeyA#K5EwAV7!zV+5JDDM7K)HDA%y$s^SOfQ z8=JQv$%+#@%cSE>CNVpyq}qL(-?yn!W_xdIcXMZBW9uJV?$&-M<97Z1?w;4(dDZLs zoz0BDN|4&S)4_f~2EwI6BxoSU)<{U$%C?ciAZIq_-nu z=y6g1U~^+bU$OPQD}r9f>m{T0KRXARP2Dcu*NtJ6_M-G$QN&Ca-p932C=UO-DB%@yXuhW|Sa)15L52FLRZ+6oA*KWQ#Shth@i?z(=n!LSQ z+uX?P@^+BfJ=oq{%av-2EB6l8tx4QxFz;2YFFxs{T)g$2i!*f9=yZeLOWlKH7~a1J zjgN0#8vkPLrZaijx$6CEe|LLhV^J~VdeTeAz2x3CbmXSv(-AsFL)RNG8z(0(E6FhJ zb@d3`E3B)}{JD0+@c+vVhu!PtWjp#ZJL%l?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(XiP^Ob*_nndGj7G)lXEt8VY3MKvSe4X8#QluwW!{H6S5<6M+U55 z=*Z}f?<#HhZ1Pi1%kxIN8ngbV?6a7j-6_~g~?I}v9$oln9u8sF;#}!Q4KCH- zS|#lG$lf08YIN8xrf<^IDaFrR_PFYZWGE+W{u~(tR_L?V;%MHQ=7KA|AjuOqX38c= zjc}qmEH;b8hw9W7-D27nLz^@9^oAXOCXqEi^lz-z{EFp5vrBfTn@nY=>;|$|3~t1` z!gww|uu)Nc=tT7oYI53apR~<3tK4V?t9G1#K3ML>I3EnfxRG>J#L&JKe#>X&Nikq) ziWPTpaxHjF+UD?o<)gE+eW*~qL;Xb!4T+utcEIN>-H-(W%IX@ z8uN&P_o|Ka?oK6*3EL^Xp0EwXX~1eNhKFrLFOueH;PT6DY^|cMj4Ns?@=oHADRqqKh@H9eV}~ag9M>lhCL4u~)TH9FZ_t~REkvw2`+|EHY>`uC z&e`>mT^*;+2ZJHGv<7FadpfzvwO_Mlv(N6N-U&P7u;XW33fNTS)W2fKOD-Cz^pLHS zocC-Ed51xYlpIet}-Ue5~I3==SEOvy{l| zGV>({U%z8nKac)g2+e!anlnooeW~{lNbX7Mg^XTG=XEycNN<-i_vmo_A0Pg){^#i6 z)xmmi68DqdNT%z5_75`Kdzp=`t&NSX<;iZ+>!dyJfs@-@nRc$$|Lh!W9K8SV;r{}C C#0pCQ literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/v/E/KKeEAYnZW+G+uOVxSZaA b/tests/Service/.cache/v/E/KKeEAYnZW+G+uOVxSZaA new file mode 100644 index 0000000000000000000000000000000000000000..e654f899e91fdad4c19b5d80456b6a01fd73a391 GIT binary patch literal 161261 zcmdSC>slJiw(!3{@2l|f%lI9buQls$x7Ih- zn(J@Zw_EGGyIY%ee`9yE-sHpP=GuSP-*3Oa8@_-0el=3hs~WIT{evC z@%7N^`&`t0zp=I^S8V?1icYKUx1!6+uU$y#S+zR72#oGZl;>`QI?)&+@ z*59wz2ZNy7tjFDc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|USRu!&c+zM;mz-vupFIzu5(#Aiwi(3)y>Ax;v^W*0J&cV(O zR1GMC&CTtdm+bfB_c!SB*&n`n``f#{F}e(n%|3opttz!CBot zosNX1wWWeo>+(hoA9elW;_+6+q@bBLX{nmiVfLeC#xopTRf^ z(@0llaHl#ABQCeEREKe*hMGJY!9aCD<~?cl)WDd8YEY>+^y5HzRJ_ydah#tsgK`+$ zsNVS;(5FC>z zF|Fz0+zc5g0`6w6Zd-cNRHG|BIlW~D<@6R7lxqLRm^`Rk@DA@)gNdqZHMGKeJwEop z6I1mEH9DJtyT8Qj;H$JQTO_~&y|kMT0?Wz!z(V28MTn3)=ur>=p07^p6fDb(G26^HsBY@utT24dE&YSm0`;%I73Jfn7-KXj{Pm)S%f|-z4MX=1D#60o4RPDG+4_3*{<3 zyCTUE*gl{_L*?~#^DJhh?WFET=e?8Od9S8?*cbaMs_6)zAXXEEr(x!D9jhX_PdFrI2UU^MA#)K}ck0GzRb0_a7QcVbS0KEdIscX(D(cI~f!`+d~>4b`90F3KNla9}H^GyVuxdo3g8u22I89q)8Cv_3^zQU6 zFoL)0F4+T0>vRT$SxrSurJl@g)WB_4AFR08J}*t~72+2Tji9e41Klq8Q*~!>mSOI4 zerFAzw!OQ?dIPY zj{5z^lO5a8+xv^L>YpCOmzjeQCQTW;1+1cFQeR}gMYBk~(08~G` UxyvWx#`VVE8ecZQJUl-BFL4SrjsO4v literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/v/v/bru-4eLCrJjT4fi3aj9w b/tests/Service/.cache/v/v/bru-4eLCrJjT4fi3aj9w new file mode 100644 index 0000000000000000000000000000000000000000..87599ba51b1e4147223c54b99258b80702e51e8b GIT binary patch literal 21596 zcmeHPYjWE-63*|Og2g{uwIwM8!MDpl93@UX6Ge_6dDKoyMN_cE2}Q~zB|lQR!klJr zFc;efD3Ks3iqeFRovh?4St1%hqtV@8Hvj=CI@V-WQt;EEVqD1TrFLmZ`sEO*=7nhz z8zJIg#nx4cNV-ilM}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Ysp((mBRIisto^kY>L?I7>(YIlty4@BndO8a^8^}( z`vXwE`_$YX(ue*U^Ol(lFVyl%(V=oXIWW$~>bY~`bU!S7Xzqs|xkGi^`3Q(fb4G#5BFvH|nRs;6v4|AcDC5r-n?4J~M5GYcc56ne6%z zxM}n0x2N>tFt`YDagEd^A+(`!a6)r9$`yX4z Bl+pkI literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/x/k/zk2vyqdID0wC23yca6vQ b/tests/Service/.cache/x/k/zk2vyqdID0wC23yca6vQ new file mode 100644 index 00000000..a794c6a4 --- /dev/null +++ b/tests/Service/.cache/x/k/zk2vyqdID0wC23yca6vQ @@ -0,0 +1,3 @@ +1502590605 +fabc79d6f5df08dd5636f3c8fbb79a18897ca71c +O:8:"DateTime":3:{s:4:"date";s:26:"2016-08-12 22:16:45.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:12:"Europe/Paris";} \ No newline at end of file diff --git a/tests/Service/.cache/y/P/lKyR4+cjcCGyJ49zN02A b/tests/Service/.cache/y/P/lKyR4+cjcCGyJ49zN02A new file mode 100644 index 0000000000000000000000000000000000000000..68d5a49c873622982db1cd1106c029f9e8fe8d1f GIT binary patch literal 39955 zcmdVD+jiQ@+Q0c7udDFz$#;^><-Hxxu?AJ84FUtk7-K?gEMy@IEDJ@*gb>2D^kJ{_ zzJi`N)=zYVU}Jk{Z*AM#>1=H7 zcD#+fy}<9R@A`Y)osHdB!P+Y}U9NZ5|JB*w-v2P%-`ihJyTfD<54)>>9`0{!?XTu< zCzGh_WLa`n9j3cywNLx^ck~gP9P&SpwfUd4+ZhhxYM6HP35WX|`>Tfs`pf3d_YNCo zo$PjK415mi?Qg8D=_5A3cSP9j_}z54`e$cqol6;mIP1pQ%li9-6R~IiLvMe6 zuJ!%ZPLf2u%TCrC#Q*No$v;;v!%jNvX8$><+b{Q4|NJ=I=l0D`cK_IoSNp4W+Iz9G zzOf>2uU0nJ)^}Fc_x3l}_qTRd^5y#c$ld)_Yn=2T=D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R(*Y-br{P_O?Jdi(U literal 0 HcmV?d00001 diff --git a/tests/Service/.cache/z/A/syfS2Tia0KK6N8wqlhRA b/tests/Service/.cache/z/A/syfS2Tia0KK6N8wqlhRA new file mode 100644 index 0000000000000000000000000000000000000000..e624afe4f9ae2a30752049ea3ad3d0ca95e85c60 GIT binary patch literal 5056 zcmds5+j81Q7|ykyLZizLGCG2g1sO_g*GU{)gFAL7Gt43_ps|otY4IVMyh2~9FV=5Y zl96oWB-6Un))yXj|HJ-=@Bel|GrLAdw^UQ#^Qmq0daAB_9;N!6cC3Z1&U;;3vliW+ z(Y0-DVJ|Fmk2sd|Idg1BPHC3JQAXv1v7?)ge7yPeDWpF!mV7+R((cFeQtouPg#nXS zO**eqO0qaQTcw0M%pBd3$M5(Dqw}0u#t7SFqu7U0;OMH#EsWxFYTvEH1Ib&FG^4D4F+Eaj`QS_DAp19j z)lK!DBOj$fOVV^{xLHcNs&(+s(YlVVOUI{EVcB)$!@DFvEo zE2{7W(m1U9&>T70%n^G_T9Z44ENS2Fn5rrc)^YL>&CasYSQ&<4e5;JpU>QU;PjK{u zFhVaTG`*o|O^ockS&zD%OXQ7yCi9%uhkw)09Nnf~Lw=Qpo@c-f9zF zQy&KCf`N_ZS<6S@18V(f47_3tm>7dyqamQ~3#eC6pE)>>mM|8p2T;QcisT8Da{mIQ z`R1q&T?{?kkQ|eRszL-N;{ubp3a?QkY%{QpoE0DyixROpIPa7@*d`Tl=KD`Ui+!N- zPFV<4#w9BA?I&QxHsD4c0Lf3t0hvp7K~+==CQ8N;DOL~ogca(>s{wGK`2t+|W`U6s zaiS470$k!_jx(sDnyiEkeE?K0*nuaG8^E*~H`SE*6z^+-puwNbHW>r6uf-Jsy~p%F z$)$h~h}gi4KXH_6yei$~tgP?4N=nV(6DIBhzXx^&R%%gtP39pq=Z^LjT_oUttL|+Y zu&ORcbW={7G~o5))RwFgr`=|BorsD)lb*N9SiC-^3^6gn=|putf8jHa*3Dxd41*!* zb+B?@$G@R+%;=Vx8fBYU&#i#s27TsyC?_Ftmd(kw$9{$le5WYpr z78_o?!Ch6s_V-tLN#iwzj}o)_6H=@IVZsKcy>DBcj%KPrFxLEZNTTIH-#08>*R>u5 zSc{x~27mq=-jC;p$%82nXP8@x&{>R%oWlb19Q7y_%gKo>`SF;kE9?ZP!9~=je-{ z{Rh+72JW`2$Z(U8cyt!{gVE~b?VIi*_;J2Q3hB`+8~ z>(wN_I-e}grtkHuw;S)efu7y=lczO*o#WSr;=A&Y@n5Ypv#Y6wfnVWrp@&x<24#m3 Ok9s`(@uNWT>i-k5g-Oo< literal 0 HcmV?d00001 diff --git a/tests/Service/AbstractServiceTest.php b/tests/Service/AbstractServiceTest.php new file mode 100644 index 00000000..2747b41c --- /dev/null +++ b/tests/Service/AbstractServiceTest.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service; + +use Http\Adapter\Guzzle6\Client; +use Http\Client\Common\Plugin\CachePlugin; +use Http\Client\Common\Plugin\ErrorPlugin; +use Http\Client\Common\PluginClient; +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Http\Message\MessageFactory\GuzzleMessageFactory; +use Http\Message\StreamFactory\GuzzleStreamFactory; +use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; + +/** + * @author GeLo + */ +abstract class AbstractServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var HttpClient + */ + private $client; + + /** + * @var MessageFactory + */ + private $messageFactory; + + /** + * @var CacheItemPoolInterface + */ + private $pool; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->pool = new FilesystemAdapter('', 0, __DIR__.'/.cache'); + $this->messageFactory = new GuzzleMessageFactory(); + + $this->client = new PluginClient(new Client(), [ + new ErrorPlugin(), + new CachePlugin( + $this->pool, + new GuzzleStreamFactory(), + ['respect_cache_headers' => false] + ), + ]); + } + + /** + * @return HttpClient + */ + protected function getClient() + { + return $this->client; + } + + /** + * @return MessageFactory + */ + protected function getMessageFactory() + { + return $this->messageFactory; + } + + /** + * @return CacheItemPoolInterface + */ + protected function getPool() + { + return $this->pool; + } +} diff --git a/tests/Service/Base/DistanceTest.php b/tests/Service/Base/DistanceTest.php new file mode 100644 index 00000000..5c873667 --- /dev/null +++ b/tests/Service/Base/DistanceTest.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Service; + +use Ivory\GoogleMap\Service\Base\Distance; + +/** + * @author GeLo + */ +class DistanceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Distance + */ + private $distance; + + /** + * @var string + */ + private $text; + + /** + * @var float + */ + private $value; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->distance = new Distance($this->text = 'foo', $this->value = 2.3); + } + + public function testInitialState() + { + $this->assertSame($this->text, $this->distance->getText()); + $this->assertSame($this->value, $this->distance->getValue()); + } + + public function testText() + { + $this->distance->setText($text = 'bar'); + + $this->assertSame($text, $this->distance->getText()); + } + + public function testValue() + { + $this->distance->setValue($value = 3.2); + + $this->assertSame($value, $this->distance->getValue()); + } +} diff --git a/tests/Service/Base/DurationTest.php b/tests/Service/Base/DurationTest.php new file mode 100644 index 00000000..ec135b59 --- /dev/null +++ b/tests/Service/Base/DurationTest.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Base; + +use Ivory\GoogleMap\Service\Base\Duration; + +/** + * @author GeLo + */ +class DurationTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Duration + */ + private $duration; + + /** + * @var string + */ + private $text; + + /** + * @var float + */ + private $value; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->duration = new Duration($this->text = 'foo', $this->value = 2.3); + } + + public function testInitialState() + { + $this->assertSame($this->text, $this->duration->getText()); + $this->assertSame($this->value, $this->duration->getValue()); + } + + public function testText() + { + $this->duration->setText($text = 'bar'); + + $this->assertSame($text, $this->duration->getText()); + } + + public function testValue() + { + $this->duration->setValue($value = 3.2); + + $this->assertSame($value, $this->duration->getValue()); + } +} diff --git a/tests/Service/BusinessAccountTest.php b/tests/Service/BusinessAccountTest.php new file mode 100644 index 00000000..9e75fe76 --- /dev/null +++ b/tests/Service/BusinessAccountTest.php @@ -0,0 +1,127 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service; + +use Ivory\GoogleMap\Service\BusinessAccount; + +/** + * @author GeLo + */ +class BusinessAccountTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var BusinessAccount + */ + private $businessAccount; + + /** + * @var string + */ + private $clientId; + + /** + * @var string + */ + private $secret; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->businessAccount = new BusinessAccount( + $this->clientId = 'client_id', + $this->secret = 'secret' + ); + } + + public function testDefaultState() + { + $this->assertSame($this->clientId, $this->businessAccount->getClientId()); + $this->assertSame($this->secret, $this->businessAccount->getSecret()); + $this->assertFalse($this->businessAccount->hasChannel()); + $this->assertNull($this->businessAccount->getChannel()); + } + + public function testInitialState() + { + $this->businessAccount = new BusinessAccount($this->clientId, $this->secret, $channel = 'channel'); + + $this->assertSame($this->clientId, $this->businessAccount->getClientId()); + $this->assertSame($this->secret, $this->businessAccount->getSecret()); + $this->assertTrue($this->businessAccount->hasChannel()); + $this->assertSame($channel, $this->businessAccount->getChannel()); + } + + public function testClientId() + { + $this->businessAccount->setClientId($clientId = 'foo'); + + $this->assertSame($clientId, $this->businessAccount->getClientId()); + } + + public function testSecret() + { + $this->businessAccount->setSecret($secret = 'foo'); + + $this->assertSame($secret, $this->businessAccount->getSecret()); + } + + public function testChannel() + { + $this->businessAccount->setChannel($channel = 'foo'); + + $this->assertTrue($this->businessAccount->hasChannel()); + $this->assertSame($channel, $this->businessAccount->getChannel()); + } + + public function testResetChannel() + { + $this->businessAccount->setChannel('foo'); + $this->businessAccount->setChannel(null); + + $this->assertFalse($this->businessAccount->hasChannel()); + $this->assertNull($this->businessAccount->getChannel()); + } + + /** + * @param string $url + * @param string $signature + * @param string|null $channel + * + * @dataProvider signatureProvider + */ + public function testSignature($url, $signature, $channel = null) + { + $expected = $url.'&client=gme-client_id'; + if ($channel !== null) { + $expected .= '&channel='.$channel; + } + + $this->businessAccount->setChannel($channel); + + $this->assertSame($expected.'&signature='.$signature, $this->businessAccount->signUrl($url)); + } + + /** + * @return string[][] + */ + public function signatureProvider() + { + $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; + + return [ + [$url, 'EO4W2ipM4YzwEIOM1pRZ5xbrl8k='], + [$url, 'e9BFlnQaKg-t3NIxKbilkQeTU1Y=', 'channel'], + ]; + } +} diff --git a/tests/Service/Directions/DirectionsLegTest.php b/tests/Service/Directions/DirectionsLegTest.php new file mode 100644 index 00000000..d4dfc79e --- /dev/null +++ b/tests/Service/Directions/DirectionsLegTest.php @@ -0,0 +1,237 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Base\Distance; +use Ivory\GoogleMap\Service\Base\Duration; +use Ivory\GoogleMap\Service\Directions\DirectionsLeg; +use Ivory\GoogleMap\Service\Directions\DirectionsStep; + +/** + * @author GeLo + */ +class DirectionsLegTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DirectionsLeg + */ + private $leg; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->leg = new DirectionsLeg(); + } + + public function testInitialState() + { + $this->assertFalse($this->leg->hasDuration()); + $this->assertNull($this->leg->getDuration()); + $this->assertFalse($this->leg->hasDistance()); + $this->assertNull($this->leg->getDistance()); + $this->assertFalse($this->leg->hasEndAddress()); + $this->assertNull($this->leg->getEndAddress()); + $this->assertFalse($this->leg->hasEndLocation()); + $this->assertNull($this->leg->getEndLocation()); + $this->assertFalse($this->leg->hasStartAddress()); + $this->assertNull($this->leg->getStartAddress()); + $this->assertFalse($this->leg->hasStartLocation()); + $this->assertNull($this->leg->getStartLocation()); + $this->assertFalse($this->leg->hasSteps()); + $this->assertEmpty($this->leg->getSteps()); + $this->assertFalse($this->leg->hasViaWaypoints()); + $this->assertEmpty($this->leg->getViaWaypoints()); + } + + public function testDuration() + { + $this->leg->setDuration($duration = $this->createDurationMock()); + + $this->assertTrue($this->leg->hasDuration()); + $this->assertSame($duration, $this->leg->getDuration()); + } + + public function testResetDuration() + { + $this->leg->setDuration($this->createDurationMock()); + $this->leg->setDuration(null); + + $this->assertFalse($this->leg->hasDuration()); + $this->assertNull($this->leg->getDuration()); + } + + public function testDistance() + { + $this->leg->setDistance($distance = $this->createDistanceMock()); + + $this->assertTrue($this->leg->hasDistance()); + $this->assertSame($distance, $this->leg->getDistance()); + } + + public function testResetDistance() + { + $this->leg->setDistance($this->createDistanceMock()); + $this->leg->setDistance(null); + + $this->assertFalse($this->leg->hasDistance()); + $this->assertNull($this->leg->getDistance()); + } + + public function testEndAddress() + { + $this->leg->setEndAddress($endAddress = 'address'); + + $this->assertTrue($this->leg->hasEndAddress()); + $this->assertSame($endAddress, $this->leg->getEndAddress()); + } + + public function testResetEndAddress() + { + $this->leg->setEndAddress('address'); + $this->leg->setEndAddress(null); + + $this->assertFalse($this->leg->hasEndAddress()); + $this->assertNull($this->leg->getEndAddress()); + } + + public function testEndLocation() + { + $this->leg->setEndLocation($endLocation = $this->createCoordinateMock()); + + $this->assertTrue($this->leg->hasEndLocation()); + $this->assertSame($endLocation, $this->leg->getEndLocation()); + } + + public function testResetEndLocation() + { + $this->leg->setEndLocation($this->createCoordinateMock()); + $this->leg->setEndLocation(null); + + $this->assertFalse($this->leg->hasEndLocation()); + $this->assertNull($this->leg->getEndLocation()); + } + + public function testStartAddress() + { + $this->leg->setStartAddress($startAddress = 'address'); + + $this->assertTrue($this->leg->hasStartAddress()); + $this->assertSame($startAddress, $this->leg->getStartAddress()); + } + + public function testResetStartAddress() + { + $this->leg->setStartAddress('address'); + $this->leg->setStartAddress(null); + + $this->assertFalse($this->leg->hasStartAddress()); + $this->assertNull($this->leg->getStartAddress()); + } + + public function testStartLocation() + { + $this->leg->setStartLocation($startLocation = $this->createCoordinateMock()); + + $this->assertTrue($this->leg->hasStartLocation()); + $this->assertSame($startLocation, $this->leg->getStartLocation()); + } + + public function testResetStartLocation() + { + $this->leg->setStartLocation($this->createCoordinateMock()); + $this->leg->setStartLocation(null); + + $this->assertFalse($this->leg->hasStartLocation()); + $this->assertNull($this->leg->getStartLocation()); + } + + public function testSetSteps() + { + $this->leg->setSteps($steps = [$step = $this->createStepMock()]); + $this->leg->setSteps($steps); + + $this->assertTrue($this->leg->hasSteps()); + $this->assertTrue($this->leg->hasStep($step)); + $this->assertSame($steps, $this->leg->getSteps()); + } + + public function testAddSteps() + { + $this->leg->setSteps($firstSteps = [$this->createStepMock()]); + $this->leg->addSteps($secondSteps = [$this->createStepMock()]); + + $this->assertTrue($this->leg->hasSteps()); + $this->assertSame(array_merge($firstSteps, $secondSteps), $this->leg->getSteps()); + } + + public function testAddStep() + { + $this->leg->addStep($step = $this->createStepMock()); + + $this->assertTrue($this->leg->hasSteps()); + $this->assertTrue($this->leg->hasStep($step)); + $this->assertSame([$step], $this->leg->getSteps()); + } + + public function testRemoveStep() + { + $this->leg->addStep($step = $this->createStepMock()); + $this->leg->removeStep($step); + + $this->assertFalse($this->leg->hasSteps()); + $this->assertFalse($this->leg->hasStep($step)); + $this->assertEmpty($this->leg->getSteps()); + } + + public function testSetViaWaypoints() + { + $this->leg->setViaWaypoints($viaWaypoints = ['foo' => 'bar']); + + $this->assertTrue($this->leg->hasViaWaypoints()); + $this->assertSame($viaWaypoints, $this->leg->getViaWaypoints()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Duration + */ + private function createDurationMock() + { + return $this->createMock(Duration::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Distance + */ + private function createDistanceMock() + { + return $this->createMock(Distance::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|DirectionsStep + */ + private function createStepMock() + { + return $this->createMock(DirectionsStep::class); + } +} diff --git a/tests/Service/Directions/DirectionsRequestTest.php b/tests/Service/Directions/DirectionsRequestTest.php new file mode 100644 index 00000000..3a8a571d --- /dev/null +++ b/tests/Service/Directions/DirectionsRequestTest.php @@ -0,0 +1,543 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Base\TravelMode; +use Ivory\GoogleMap\Service\Base\UnitSystem; +use Ivory\GoogleMap\Service\Directions\DirectionsRequest; +use Ivory\GoogleMap\Service\Directions\DirectionsWaypoint; + +/** + * @author GeLo + */ +class DirectionsRequestTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DirectionsRequest + */ + private $request; + + /** + * @var string + */ + private $origin; + + /** + * @var string + */ + private $destination; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->request = new DirectionsRequest( + $this->origin = 'Lille', + $this->destination = 'Paris' + ); + } + + public function testDefaultState() + { + $this->assertSame($this->origin, $this->request->getOrigin()); + $this->assertSame($this->destination, $this->request->getDestination()); + $this->assertFalse($this->request->hasDepartureTime()); + $this->assertNull($this->request->getDepartureTime()); + $this->assertFalse($this->request->hasArrivalTime()); + $this->assertNull($this->request->getArrivalTime()); + $this->assertFalse($this->request->hasWaypoints()); + $this->assertEmpty($this->request->getWaypoints()); + $this->assertFalse($this->request->hasOptimizeWaypoints()); + $this->assertNull($this->request->getOptimizeWaypoints()); + $this->assertFalse($this->request->hasTravelMode()); + $this->assertNull($this->request->getTravelMode()); + $this->assertFalse($this->request->hasAvoidHighways()); + $this->assertNull($this->request->getAvoidHighways()); + $this->assertFalse($this->request->hasAvoidTolls()); + $this->assertNull($this->request->getAvoidTolls()); + $this->assertFalse($this->request->hasProvideRouteAlternatives()); + $this->assertNull($this->request->getProvideRouteAlternatives()); + $this->assertFalse($this->request->hasRegion()); + $this->assertNull($this->request->getRegion()); + $this->assertFalse($this->request->hasUnitSystem()); + $this->assertNull($this->request->getUnitSystem()); + $this->assertFalse($this->request->hasLanguage()); + $this->assertNull($this->request->getLanguage()); + } + + /** + * @param Coordinate|string $origin + * + * @dataProvider originProvider + */ + public function testOrigin($origin) + { + $this->request->setOrigin($origin); + + $this->assertSame($origin, $this->request->getOrigin()); + } + + /** + * @param Coordinate|string $destination + * + * @dataProvider destinationProvider + */ + public function testDestination($destination) + { + $this->request->setDestination($destination); + + $this->assertSame($destination, $this->request->getDestination()); + } + + public function testDepartureTime() + { + $this->request->setDepartureTime($departureTime = new \DateTime()); + + $this->assertTrue($this->request->hasDepartureTime()); + $this->assertSame($departureTime, $this->request->getDepartureTime()); + } + + public function testResetDepartureTime() + { + $this->request->setDepartureTime(new \DateTime()); + $this->request->setDepartureTime(null); + + $this->assertFalse($this->request->hasDepartureTime()); + $this->assertNull($this->request->getDepartureTime()); + } + + public function testArrivalTime() + { + $this->request->setArrivalTime($arrivalTime = new \DateTime()); + + $this->assertTrue($this->request->hasArrivalTime()); + $this->assertSame($arrivalTime, $this->request->getArrivalTime()); + } + + public function testArrivalTimeWithNullValue() + { + $this->request->setArrivalTime(new \DateTime()); + $this->request->setArrivalTime(null); + + $this->assertFalse($this->request->hasArrivalTime()); + $this->assertNull($this->request->getArrivalTime()); + } + + public function testSetWaypoints() + { + $this->request->setWaypoints($waypoints = [$waypoint = $this->createWaypointMock()]); + $this->request->setWaypoints($waypoints); + + $this->assertTrue($this->request->hasWaypoints()); + $this->assertTrue($this->request->hasWaypoint($waypoint)); + $this->assertSame($waypoints, $this->request->getWaypoints()); + } + + public function testAddWaypoints() + { + $this->request->setWaypoints($firstWaypoints = [$this->createWaypointMock()]); + $this->request->addWaypoints($secondWaypoints = [$this->createWaypointMock()]); + + $this->assertTrue($this->request->hasWaypoints()); + $this->assertSame(array_merge($firstWaypoints, $secondWaypoints), $this->request->getWaypoints()); + } + + public function testAddWaypoint() + { + $this->request->addWaypoint($waypoint = $this->createWaypointMock()); + + $this->assertTrue($this->request->hasWaypoints()); + $this->assertTrue($this->request->hasWaypoint($waypoint)); + $this->assertSame([$waypoint], $this->request->getWaypoints()); + } + + public function testRemoveWaypoint() + { + $this->request->addWaypoint($waypoint = $this->createWaypointMock()); + $this->request->removeWaypoint($waypoint); + + $this->assertFalse($this->request->hasWaypoints()); + $this->assertFalse($this->request->hasWaypoint($waypoint)); + $this->assertEmpty($this->request->getWaypoints()); + } + + public function testOptimizeWaypoints() + { + $this->request->setOptimizeWaypoints(true); + + $this->assertTrue($this->request->hasOptimizeWaypoints()); + $this->assertTrue($this->request->getOptimizeWaypoints()); + } + + public function testResetOptimizeWaypoints() + { + $this->request->setOptimizeWaypoints(true); + $this->request->setOptimizeWaypoints(null); + + $this->assertFalse($this->request->hasOptimizeWaypoints()); + $this->assertNull($this->request->getOptimizeWaypoints()); + } + + public function testTravelMode() + { + $this->request->setTravelMode($travelMode = TravelMode::WALKING); + + $this->assertTrue($this->request->hasTravelMode()); + $this->assertSame($travelMode, $this->request->getTravelMode()); + } + + public function testResetTravelMode() + { + $this->request->setTravelMode(TravelMode::WALKING); + $this->request->setTravelMode(null); + + $this->assertFalse($this->request->hasTravelMode()); + $this->assertNull($this->request->getTravelMode()); + } + + public function testAvoidHighways() + { + $this->request->setAvoidHighways(true); + + $this->assertTrue($this->request->hasAvoidHighways()); + $this->assertTrue($this->request->getAvoidHighways()); + } + + public function testResetAvoidHighways() + { + $this->request->setAvoidHighways(true); + $this->request->setAvoidHighways(null); + + $this->assertFalse($this->request->hasAvoidHighways()); + $this->assertNull($this->request->getAvoidHighways()); + } + + public function testAvoidHighwaysResetAvoidTolls() + { + $this->request->setAvoidTolls(true); + $this->request->setAvoidHighways(true); + + $this->assertFalse($this->request->hasAvoidTolls()); + $this->assertNull($this->request->getAvoidTolls()); + $this->assertTrue($this->request->hasAvoidHighways()); + $this->assertTrue($this->request->getAvoidHighways()); + } + + public function testAvoidTolls() + { + $this->request->setAvoidTolls(true); + + $this->assertTrue($this->request->hasAvoidTolls()); + $this->assertTrue($this->request->getAvoidTolls()); + } + + public function testResetAvoidTolls() + { + $this->request->setAvoidTolls(true); + $this->request->setAvoidTolls(null); + + $this->assertFalse($this->request->hasAvoidTolls()); + $this->assertNull($this->request->getAvoidTolls()); + } + + public function testAvoidTollsResetAvoidHighways() + { + $this->request->setAvoidHighways(true); + $this->request->setAvoidTolls(true); + + $this->assertFalse($this->request->hasAvoidHighways()); + $this->assertNull($this->request->getAvoidHighways()); + $this->assertTrue($this->request->hasAvoidTolls()); + $this->assertTrue($this->request->getAvoidTolls()); + } + + public function testProvideRouteAlternatives() + { + $this->request->setProvideRouteAlternatives(true); + + $this->assertTrue($this->request->hasProvideRouteAlternatives()); + $this->assertTrue($this->request->getProvideRouteAlternatives()); + } + + public function testResetProvideRouteAlternatives() + { + $this->request->setProvideRouteAlternatives(true); + $this->request->setProvideRouteAlternatives(null); + + $this->assertFalse($this->request->hasProvideRouteAlternatives()); + $this->assertNull($this->request->getProvideRouteAlternatives()); + } + + public function testRegion() + { + $this->request->setRegion($region = 'fr'); + + $this->assertTrue($this->request->hasRegion()); + $this->assertSame($region, $this->request->getRegion()); + } + + public function testResetRegion() + { + $this->request->setRegion('fr'); + $this->request->setRegion(null); + + $this->assertFalse($this->request->hasRegion()); + $this->assertNull($this->request->getRegion()); + } + + public function testUnitSystem() + { + $this->request->setUnitSystem($unitSystem = UnitSystem::IMPERIAL); + + $this->assertTrue($this->request->hasUnitSystem()); + $this->assertSame($unitSystem, $this->request->getUnitSystem()); + } + + public function testResetUnitSystem() + { + $this->request->setUnitSystem(UnitSystem::IMPERIAL); + $this->request->setUnitSystem(null); + + $this->assertFalse($this->request->hasUnitSystem()); + $this->assertNull($this->request->getUnitSystem()); + } + + public function testLanguage() + { + $this->request->setLanguage($language = 'fr'); + + $this->assertTrue($this->request->hasLanguage()); + $this->assertSame($language, $this->request->getLanguage()); + } + + public function testResetLanguage() + { + $this->request->setLanguage('fr'); + $this->request->setLanguage(null); + + $this->assertFalse($this->request->hasLanguage()); + $this->assertNull($this->request->getLanguage()); + } + + public function testQuery() + { + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + ], $this->request->buildQuery()); + } + + public function testQueryWithDepartureTime() + { + $this->request->setDepartureTime($departureTime = new \DateTime()); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'departure_time' => $departureTime->getTimestamp(), + ], $this->request->buildQuery()); + } + + public function testQueryWithArrivalTime() + { + $this->request->setArrivalTime($arrivalTime = new \DateTime()); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'arrival_time' => $arrivalTime->getTimestamp(), + ], $this->request->buildQuery()); + } + + public function testQueryWithWaypoints() + { + $firstWaypoint = $this->createWaypointMock(); + $firstWaypoint + ->expects($this->once()) + ->method('getStopover') + ->will($this->returnValue(false)); + + $firstWaypoint + ->expects($this->once()) + ->method('getLocation') + ->will($this->returnValue($firstLocation = 'Compiègne')); + + $secondWaypoint = $this->createWaypointMock(); + $secondWaypoint + ->expects($this->once()) + ->method('getStopover') + ->will($this->returnValue(true)); + + $secondWaypoint + ->expects($this->once()) + ->method('getLocation') + ->will($this->returnValue($secondLocation = $this->createCoordinateMock())); + + $secondLocation + ->expects($this->once()) + ->method('getLatitude') + ->will($this->returnValue($latitude = 50.103558)); + + $secondLocation + ->expects($this->once()) + ->method('getLongitude') + ->will($this->returnValue($longitude = 2.849408)); + + $this->request->addWaypoints([$firstWaypoint, $secondWaypoint]); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'waypoints' => $firstLocation.'|via:'.$latitude.','.$longitude, + ], $this->request->buildQuery()); + } + + public function testQueryWithOptimizedWaypoints() + { + $waypoint = $this->createWaypointMock(); + $waypoint + ->expects($this->once()) + ->method('getStopover') + ->will($this->returnValue(false)); + + $waypoint + ->expects($this->once()) + ->method('getLocation') + ->will($this->returnValue($location = 'Compiègne')); + + $this->request->setOptimizeWaypoints(true); + $this->request->addWaypoint($waypoint); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'waypoints' => 'optimize:true|'.$location, + ], $this->request->buildQuery()); + } + + public function testQueryWithTravelMode() + { + $this->request->setTravelMode($travelMode = TravelMode::BICYCLING); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'mode' => strtolower($travelMode), + ], $this->request->buildQuery()); + } + + public function testQueryWithAvoidTolls() + { + $this->request->setAvoidTolls(true); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'avoid' => 'tolls', + ], $this->request->buildQuery()); + } + + public function testQueryWithAvoidHighways() + { + $this->request->setAvoidHighways(true); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'avoid' => 'highways', + ], $this->request->buildQuery()); + } + + public function testQueryWithAlternatives() + { + $this->request->setProvideRouteAlternatives(true); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'alternatives' => 'true', + ], $this->request->buildQuery()); + } + + public function testQueryWithRegion() + { + $this->request->setRegion($region = 'fr'); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'region' => $region, + ], $this->request->buildQuery()); + } + + public function testQueryWithUnitSystem() + { + $this->request->setUnitSystem($unitSystem = UnitSystem::IMPERIAL); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'units' => strtolower($unitSystem), + ], $this->request->buildQuery()); + } + + public function testQueryWithLanguage() + { + $this->request->setLanguage($language = 'fr'); + + $this->assertSame([ + 'origin' => $this->origin, + 'destination' => $this->destination, + 'language' => $language, + ], $this->request->buildQuery()); + } + + /** + * @return mixed[][] + */ + public function originProvider() + { + return [ + ['Paris'], + [$this->createCoordinateMock()], + ]; + } + + /** + * @return mixed[][] + */ + public function destinationProvider() + { + return [ + ['Paris'], + [$this->createCoordinateMock()], + ]; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|DirectionsWaypoint + */ + private function createWaypointMock() + { + return $this->createMock(DirectionsWaypoint::class); + } +} diff --git a/tests/Service/Directions/DirectionsResponseTest.php b/tests/Service/Directions/DirectionsResponseTest.php new file mode 100644 index 00000000..7236a448 --- /dev/null +++ b/tests/Service/Directions/DirectionsResponseTest.php @@ -0,0 +1,106 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Service\Directions\DirectionsResponse; +use Ivory\GoogleMap\Service\Directions\DirectionsRoute; +use Ivory\GoogleMap\Service\Directions\DirectionsStatus; + +/** + * @author GeLo + */ +class DirectionsResponseTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DirectionsResponse + */ + private $response; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->response = new DirectionsResponse(); + } + + public function testDefaultState() + { + $this->assertFalse($this->response->hasStatus()); + $this->assertNull($this->response->getStatus()); + $this->assertFalse($this->response->hasRoutes()); + $this->assertEmpty($this->response->getRoutes()); + } + + public function testStatus() + { + $this->response->setStatus($status = DirectionsStatus::INVALID_REQUEST); + + $this->assertTrue($this->response->hasStatus()); + $this->assertSame($status, $this->response->getStatus()); + } + + public function testReset() + { + $this->response->setStatus(DirectionsStatus::INVALID_REQUEST); + $this->response->setStatus(null); + + $this->assertFalse($this->response->hasStatus()); + $this->assertNull($this->response->getStatus()); + } + + public function testSetRoutes() + { + $this->response->setRoutes($routes = [$route = $this->createRouteMock()]); + $this->response->setRoutes($routes); + + $this->assertTrue($this->response->hasRoutes()); + $this->assertTrue($this->response->hasRoute($route)); + $this->assertSame($routes, $this->response->getRoutes()); + } + + public function testAddRoutes() + { + $this->response->setRoutes($firstRoutes = [$this->createRouteMock()]); + $this->response->addRoutes($secondRoutes = [$this->createRouteMock()]); + + $this->assertTrue($this->response->hasRoutes()); + $this->assertSame(array_merge($firstRoutes, $secondRoutes), $this->response->getRoutes()); + } + + public function testAddRoute() + { + $this->response->addRoute($route = $this->createRouteMock()); + + $this->assertTrue($this->response->hasRoutes()); + $this->assertTrue($this->response->hasRoute($route)); + $this->assertSame([$route], $this->response->getRoutes()); + } + + public function testRemoveRoute() + { + $this->response->addRoute($route = $this->createRouteMock()); + $this->response->removeRoute($route); + + $this->assertFalse($this->response->hasRoutes()); + $this->assertFalse($this->response->hasRoute($route)); + $this->assertEmpty($this->response->getRoutes()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|DirectionsRoute + */ + private function createRouteMock() + { + return $this->createMock(DirectionsRoute::class); + } +} diff --git a/tests/Service/Directions/DirectionsRouteTest.php b/tests/Service/Directions/DirectionsRouteTest.php new file mode 100644 index 00000000..1b00ffc8 --- /dev/null +++ b/tests/Service/Directions/DirectionsRouteTest.php @@ -0,0 +1,241 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\GoogleMap\Service\Directions\DirectionsLeg; +use Ivory\GoogleMap\Service\Directions\DirectionsRoute; + +/** + * @author GeLo + */ +class DirectionsRouteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DirectionsRoute + */ + private $route; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->route = new DirectionsRoute(); + } + + public function testInitialState() + { + $this->assertFalse($this->route->hasBound()); + $this->assertNull($this->route->getBound()); + $this->assertFalse($this->route->hasCopyrights()); + $this->assertNull($this->route->getCopyrights()); + $this->assertFalse($this->route->hasLegs()); + $this->assertEmpty($this->route->getLegs()); + $this->assertFalse($this->route->hasOverviewPolyline()); + $this->assertNull($this->route->getOverviewPolyline()); + $this->assertFalse($this->route->hasSummary()); + $this->assertNull($this->route->getSummary()); + $this->assertFalse($this->route->hasWarnings()); + $this->assertEmpty($this->route->getWarnings()); + $this->assertFalse($this->route->hasWaypointOrders()); + $this->assertEmpty($this->route->getWaypointOrders()); + } + + public function testBound() + { + $this->route->setBound($bound = $this->createBoundMock()); + + $this->assertTrue($this->route->hasBound()); + $this->assertSame($bound, $this->route->getBound()); + } + + public function testResetBound() + { + $this->route->setBound($this->createBoundMock()); + $this->route->setBound(null); + + $this->assertFalse($this->route->hasBound()); + $this->assertNull($this->route->getBound()); + } + + public function testCopyrights() + { + $this->route->setCopyrights($copyrights = 'copyrights'); + + $this->assertTrue($this->route->hasCopyrights()); + $this->assertSame($copyrights, $this->route->getCopyrights()); + } + + public function testResetCopyrights() + { + $this->route->setCopyrights('copyrights'); + $this->route->setCopyrights(null); + + $this->assertFalse($this->route->hasCopyrights()); + $this->assertNull($this->route->getCopyrights()); + } + + public function testSetLegs() + { + $this->route->setLegs($legs = [$leg = $this->createLegMock()]); + $this->route->setLegs($legs); + + $this->assertTrue($this->route->hasLegs()); + $this->assertTrue($this->route->hasLeg($leg)); + $this->assertSame($legs, $this->route->getLegs()); + } + + public function testAddLegs() + { + $this->route->setLegs($firstLegs = [$this->createLegMock()]); + $this->route->addLegs($secondLegs = [$this->createLegMock()]); + + $this->assertTrue($this->route->hasLegs()); + $this->assertSame(array_merge($firstLegs, $secondLegs), $this->route->getLegs()); + } + + public function testAddLeg() + { + $this->route->addLeg($leg = $this->createLegMock()); + + $this->assertTrue($this->route->hasLegs()); + $this->assertTrue($this->route->hasLeg($leg)); + $this->assertSame([$leg], $this->route->getLegs()); + } + + public function testRemoveLeg() + { + $this->route->addLeg($leg = $this->createLegMock()); + $this->route->removeLeg($leg); + + $this->assertFalse($this->route->hasLegs()); + $this->assertFalse($this->route->hasLeg($leg)); + $this->assertEmpty($this->route->getLegs()); + } + + public function testOverviewPolyline() + { + $this->route->setOverviewPolyline($overviewPolyline = $this->createEncodedPolylineMock()); + + $this->assertTrue($this->route->hasOverviewPolyline()); + $this->assertSame($overviewPolyline, $this->route->getOverviewPolyline()); + } + + public function testResetOverviewPolyline() + { + $this->route->setOverviewPolyline($this->createEncodedPolylineMock()); + $this->route->setOverviewPolyline(null); + + $this->assertFalse($this->route->hasOverviewPolyline()); + $this->assertNull($this->route->getOverviewPolyline()); + } + + public function testSummary() + { + $this->route->setSummary($summary = 'summary'); + + $this->assertTrue($this->route->hasSummary()); + $this->assertSame($summary, $this->route->getSummary()); + } + + public function testResetSummary() + { + $this->route->setSummary('summary'); + $this->route->setSummary(null); + + $this->assertFalse($this->route->hasSummary()); + $this->assertNull($this->route->getSummary()); + } + + public function testSetWarnings() + { + $this->route->setWarnings($warnings = [$warning = 'warning']); + $this->route->setWarnings($warnings); + + $this->assertTrue($this->route->hasWarnings()); + $this->assertTrue($this->route->hasWarning($warning)); + $this->assertSame($warnings, $this->route->getWarnings()); + } + + public function testAddWarnings() + { + $this->route->setWarnings($firstWarnings = ['first_warning']); + $this->route->addWarnings($secondWarnings = ['second_warning']); + + $this->assertTrue($this->route->hasWarnings()); + $this->assertSame(array_merge($firstWarnings, $secondWarnings), $this->route->getWarnings()); + } + + public function testAddWarning() + { + $this->route->addWarning($warning = 'warning'); + + $this->assertTrue($this->route->hasWarnings()); + $this->assertTrue($this->route->hasWarning($warning)); + $this->assertSame([$warning], $this->route->getWarnings()); + } + + public function testRemoveWarning() + { + $this->route->addWarning($warning = 'warning'); + $this->route->removeWarning($warning); + + $this->assertFalse($this->route->hasWarnings()); + $this->assertFalse($this->route->hasWarning($warning)); + $this->assertEmpty($this->route->getWarnings()); + } + + public function testSetWaypointOrders() + { + $this->route->setWaypointOrders($waypointOrders = [$waypointOrder = 2, 1]); + $this->route->setWaypointOrders($waypointOrders); + + $this->assertTrue($this->route->hasWaypointOrders()); + $this->assertTrue($this->route->hasWaypointOrder($waypointOrder)); + $this->assertSame($waypointOrders, $this->route->getWaypointOrders()); + } + + public function testAddWaypointOrder() + { + $this->route->addWaypointOrder($waypointOrder = 2); + + $this->assertTrue($this->route->hasWaypointOrders()); + $this->assertTrue($this->route->hasWaypointOrder($waypointOrder)); + $this->assertSame([$waypointOrder], $this->route->getWaypointOrders()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|DirectionsLeg + */ + private function createLegMock() + { + return $this->createMock(DirectionsLeg::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|EncodedPolyline + */ + private function createEncodedPolylineMock() + { + return $this->createMock(EncodedPolyline::class); + } +} diff --git a/tests/Service/Directions/DirectionsStepTest.php b/tests/Service/Directions/DirectionsStepTest.php new file mode 100644 index 00000000..6b954761 --- /dev/null +++ b/tests/Service/Directions/DirectionsStepTest.php @@ -0,0 +1,207 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Overlay\EncodedPolyline; +use Ivory\GoogleMap\Service\Base\Distance; +use Ivory\GoogleMap\Service\Base\Duration; +use Ivory\GoogleMap\Service\Base\TravelMode; +use Ivory\GoogleMap\Service\Directions\DirectionsStep; + +/** + * @author GeLo + */ +class DirectionsStepTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DirectionsStep + */ + private $step; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->step = new DirectionsStep(); + } + + public function testInitialState() + { + $this->assertFalse($this->step->hasDistance()); + $this->assertNull($this->step->getDistance()); + $this->assertFalse($this->step->hasDuration()); + $this->assertNull($this->step->getDuration()); + $this->assertFalse($this->step->hasEndLocation()); + $this->assertNull($this->step->getEndLocation()); + $this->assertFalse($this->step->hasInstructions()); + $this->assertNull($this->step->getInstructions()); + $this->assertFalse($this->step->hasEncodedPolyline()); + $this->assertNull($this->step->getEncodedPolyline()); + $this->assertFalse($this->step->hasStartLocation()); + $this->assertNull($this->step->getStartLocation()); + $this->assertFalse($this->step->hasTravelMode()); + $this->assertNull($this->step->getTravelMode()); + } + + public function testDistance() + { + $this->step->setDistance($distance = $this->createDistanceMock()); + + $this->assertTrue($this->step->hasDistance()); + $this->assertSame($distance, $this->step->getDistance()); + } + + public function testResetDistance() + { + $this->step->setDistance($this->createDistanceMock()); + $this->step->setDistance(null); + + $this->assertFalse($this->step->hasDistance()); + $this->assertNull($this->step->getDistance()); + } + + public function testDuration() + { + $this->step->setDuration($duration = $this->createDurationMock()); + + $this->assertTrue($this->step->hasDuration()); + $this->assertSame($duration, $this->step->getDuration()); + } + + public function testResetDuration() + { + $this->step->setDuration($this->createDurationMock()); + $this->step->setDuration(null); + + $this->assertFalse($this->step->hasDuration()); + $this->assertNull($this->step->getDuration()); + } + + public function testEndLocation() + { + $this->step->setEndLocation($endLocation = $this->createCoordinateMock()); + + $this->assertTrue($this->step->hasEndLocation()); + $this->assertSame($endLocation, $this->step->getEndLocation()); + } + + public function testResetEndLocation() + { + $this->step->setEndLocation($this->createCoordinateMock()); + $this->step->setEndLocation(null); + + $this->assertFalse($this->step->hasEndLocation()); + $this->assertNull($this->step->getEndLocation()); + } + + public function testInstructions() + { + $this->step->setInstructions($instructions = 'instructions'); + + $this->assertTrue($this->step->hasInstructions()); + $this->assertSame($instructions, $this->step->getInstructions()); + } + + public function testResetInstructions() + { + $this->step->setInstructions('instructions'); + $this->step->setInstructions(null); + + $this->assertFalse($this->step->hasInstructions()); + $this->assertNull($this->step->getInstructions()); + } + + public function testEncodedPolyline() + { + $this->step->setEncodedPolyline($encodedPolyline = $this->createEncodedPolylineMock()); + + $this->assertTrue($this->step->hasEncodedPolyline()); + $this->assertSame($encodedPolyline, $this->step->getEncodedPolyline()); + } + + public function testResetEncodedPolyline() + { + $this->step->setEncodedPolyline($this->createEncodedPolylineMock()); + $this->step->setEncodedPolyline(null); + + $this->assertFalse($this->step->hasEncodedPolyline()); + $this->assertNull($this->step->getEncodedPolyline()); + } + + public function testStartLocation() + { + $this->step->setStartLocation($startLocation = $this->createCoordinateMock()); + + $this->assertTrue($this->step->hasStartLocation()); + $this->assertSame($startLocation, $this->step->getStartLocation()); + } + + public function testResetStartLocation() + { + $this->step->setStartLocation($this->createCoordinateMock()); + $this->step->setStartLocation(null); + + $this->assertFalse($this->step->hasStartLocation()); + $this->assertNull($this->step->getStartLocation()); + } + + public function testTravelMode() + { + $this->step->setTravelMode($travelMode = TravelMode::BICYCLING); + + $this->assertTrue($this->step->hasTravelMode()); + $this->assertSame($travelMode, $this->step->getTravelMode()); + } + + public function testResetTravelMode() + { + $this->step->setTravelMode(TravelMode::BICYCLING); + $this->step->setTravelMode(null); + + $this->assertFalse($this->step->hasTravelMode()); + $this->assertNull($this->step->getTravelMode()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Distance + */ + private function createDistanceMock() + { + return $this->createMock(Distance::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Duration + */ + private function createDurationMock() + { + return $this->createMock(Duration::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|EncodedPolyline + */ + private function createEncodedPolylineMock() + { + return $this->createMock(EncodedPolyline::class); + } +} diff --git a/tests/Service/Directions/DirectionsTest.php b/tests/Service/Directions/DirectionsTest.php new file mode 100644 index 00000000..5589402d --- /dev/null +++ b/tests/Service/Directions/DirectionsTest.php @@ -0,0 +1,383 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Directions; + +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Base\TravelMode; +use Ivory\GoogleMap\Service\Base\UnitSystem; +use Ivory\GoogleMap\Service\BusinessAccount; +use Ivory\GoogleMap\Service\Directions\Directions; +use Ivory\GoogleMap\Service\Directions\DirectionsRequest; +use Ivory\GoogleMap\Service\Directions\DirectionsStatus; +use Ivory\GoogleMap\Service\Directions\DirectionsWaypoint; +use Ivory\Tests\GoogleMap\Service\AbstractServiceTest; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; + +/** + * @author GeLo + */ +class DirectionsTest extends AbstractServiceTest +{ + /** + * @var Directions + */ + private $directions; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + /* + + Uncomment when generating the http cache. + It needs to wait a little bit between test cases + in order to not hit the OVER_QUERY_LIMIT... + + */ + + // sleep(2); + + parent::setUp(); + + $this->directions = new Directions($this->getClient(), $this->getMessageFactory()); + } + + public function testRoute() + { + $request = new DirectionsRequest('Lille', 'Paris'); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithCoordinates() + { + $request = new DirectionsRequest( + new Coordinate(50.629381, 3.057268), + new Coordinate(48.856633, 2.352254) + ); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithDepartureTime() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setDepartureTime($this->getDepartureTime()); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithArrivalTime() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setArrivalTime($this->getArrivalTime()); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithStringWaypoint() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->addWaypoint(new DirectionsWaypoint('Compiègne')); + $request->setOptimizeWaypoints(true); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithCoordinateWaypoint() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->addWaypoint(new DirectionsWaypoint(new Coordinate(49.418079, 2.826190))); + $request->setOptimizeWaypoints(true); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithStopoverWaypoint() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->addWaypoint(new DirectionsWaypoint('Compiègne', true)); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithAvoidTolls() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setAvoidTolls(true); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithAvoidHighways() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setAvoidHighways(true); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithTravelMode() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setTravelMode(TravelMode::DRIVING); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithAlternatives() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setProvideRouteAlternatives(true); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithUnitSystem() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setUnitSystem(UnitSystem::METRIC); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithRegion() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setRegion('fr'); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithLanguage() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $request->setLanguage('fr'); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithHttps() + { + $request = new DirectionsRequest('Lille', 'Paris'); + $this->directions->setHttps(true); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithXmlFormat() + { + $request = new DirectionsRequest('Lille', 'Paris'); + + $this->directions->setFormat(Directions::FORMAT_XML); + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getRoutes()); + } + + public function testRouteWithBusinessAccount() + { + $this->directions = new Directions( + $client = $this->createHttpClientMock(), + $messageFactory = $this->createMessageFactoryMock() + ); + + $request = $this->createDirectionsRequestMock(); + $request + ->expects($this->once()) + ->method('buildQuery') + ->will($this->returnValue($query = ['foo' => 'bar'])); + + $messageFactory + ->expects($this->once()) + ->method('createRequest') + ->with( + $this->identicalTo('GET'), + $this->identicalTo( + $url = 'https://maps.googleapis.com/maps/api/directions/json?foo=bar&signature=signature' + ) + ) + ->will($this->returnValue($httpRequest = $this->createHttpRequestMock())); + + $client + ->expects($this->once()) + ->method('sendRequest') + ->with($this->identicalTo($httpRequest)) + ->will($this->returnValue($httpResponse = $this->createHttpResponseMock())); + + $httpResponse + ->expects($this->once()) + ->method('getBody') + ->will($this->returnValue($httpStream = $this->createHttpStreamMock())); + + $httpStream + ->expects($this->once()) + ->method('__toString') + ->will($this->returnValue('{"status":"OK","routes":[]}')); + + $businessAccount = $this->createBusinessAccountMock(); + $businessAccount + ->expects($this->once()) + ->method('signUrl') + ->with($this->equalTo('https://maps.googleapis.com/maps/api/directions/json?foo=bar')) + ->will($this->returnValue($url)); + + $this->directions->setBusinessAccount($businessAccount); + + $response = $this->directions->route($request); + + $this->assertSame(DirectionsStatus::OK, $response->getStatus()); + $this->assertEmpty($response->getRoutes()); + } + + /** + * @return \DateTime + */ + private function getDepartureTime() + { + return $this->getDateTime('departure'); + } + + /** + * @return \DateTime + */ + private function getArrivalTime() + { + return $this->getDateTime('arrival', '+2 hours'); + } + + /** + * @param string $key + * @param string $value + * + * @return \DateTime + */ + private function getDateTime($key, $value = 'now') + { + $pool = $this->getPool(); + $item = $pool->getItem(sha1(__CLASS__.'::'.$key)); + + if (!$item->isHit()) { + $item->set(new \DateTime($value)); + $pool->save($item); + } + + return $item->get(); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|HttpClient + */ + private function createHttpClientMock() + { + return $this->createMock(HttpClient::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MessageFactory + */ + private function createMessageFactoryMock() + { + return $this->createMock(MessageFactory::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RequestInterface + */ + private function createHttpRequestMock() + { + return $this->createMock(RequestInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ResponseInterface + */ + private function createHttpResponseMock() + { + return $this->createMock(ResponseInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|StreamInterface + */ + private function createHttpStreamMock() + { + return $this->createMock(StreamInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|BusinessAccount + */ + private function createBusinessAccountMock() + { + return $this->createMock(BusinessAccount::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|DirectionsRequest + */ + private function createDirectionsRequestMock() + { + return $this->createMock(DirectionsRequest::class); + } +} diff --git a/tests/Service/Directions/DirectionsWaypointTest.php b/tests/Service/Directions/DirectionsWaypointTest.php new file mode 100644 index 00000000..731fe7fb --- /dev/null +++ b/tests/Service/Directions/DirectionsWaypointTest.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Directions; + +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Directions\DirectionsWaypoint; + +/** + * @author GeLo + */ +class DirectionsWaypointTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DirectionsWaypoint + */ + private $waypoint; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->waypoint = new DirectionsWaypoint(); + } + + public function testDefaultState() + { + $this->assertFalse($this->waypoint->hasLocation()); + $this->assertFalse($this->waypoint->hasStopover()); + } + + /** + * @param string|Coordinate $location + * + * @dataProvider locationProvider + */ + public function testLocation($location) + { + $this->waypoint->setLocation($location); + + $this->assertTrue($this->waypoint->hasLocation()); + $this->assertSame($location, $this->waypoint->getLocation()); + } + + /** + * @param bool $stopover + * + * @dataProvider stopoverProvider + */ + public function testStopover($stopover) + { + $this->waypoint->setStopover($stopover); + + $this->assertTrue($this->waypoint->hasStopover()); + $this->assertSame($stopover, $this->waypoint->getStopover()); + } + + public function testResetStopoverWithNullValue() + { + $this->waypoint->setStopover(true); + $this->waypoint->setStopover(null); + + $this->assertFalse($this->waypoint->hasStopover()); + $this->assertNull($this->waypoint->getStopover()); + } + + /** + * @return mixed[][] + */ + public function locationProvider() + { + return [ + ['Paris'], + [$this->createMock(Coordinate::class)], + ]; + } + + /** + * @return bool[][] + */ + public function stopoverProvider() + { + return [ + [true], + [false], + ]; + } +} diff --git a/tests/Service/DistanceMatrix/DistanceMatrixElementTest.php b/tests/Service/DistanceMatrix/DistanceMatrixElementTest.php new file mode 100644 index 00000000..44c20c4f --- /dev/null +++ b/tests/Service/DistanceMatrix/DistanceMatrixElementTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\DistanceMatrix; + +use Ivory\GoogleMap\Service\Base\Distance; +use Ivory\GoogleMap\Service\Base\Duration; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixElement; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixElementStatus; + +/** + * @author GeLo + */ +class DistanceMatrixElementTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DistanceMatrixElement + */ + private $element; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->element = new DistanceMatrixElement(); + } + + public function testDefaultState() + { + $this->assertFalse($this->element->hasStatus()); + $this->assertNull($this->element->getStatus()); + $this->assertFalse($this->element->hasDistance()); + $this->assertNull($this->element->getDistance()); + $this->assertFalse($this->element->hasDuration()); + $this->assertNull($this->element->getDuration()); + } + + public function testStatus() + { + $this->element->setStatus($status = DistanceMatrixElementStatus::ZERO_RESULTS); + + $this->assertTrue($this->element->hasStatus()); + $this->assertSame($status, $this->element->getStatus()); + } + + public function testResetStatus() + { + $this->element->setStatus(DistanceMatrixElementStatus::ZERO_RESULTS); + $this->element->setStatus(null); + + $this->assertFalse($this->element->hasStatus()); + $this->assertNull($this->element->getStatus()); + } + + public function testDistance() + { + $this->element->setDistance($distance = $this->createDistanceMock()); + + $this->assertTrue($this->element->hasDistance()); + $this->assertSame($distance, $this->element->getDistance()); + } + + public function testResetDistance() + { + $this->element->setDistance($this->createDistanceMock()); + $this->element->setDistance(null); + + $this->assertFalse($this->element->hasDistance()); + $this->assertNull($this->element->getDistance()); + } + + public function testDuration() + { + $this->element->setDuration($duration = $this->createDurationMock()); + + $this->assertTrue($this->element->hasDuration()); + $this->assertSame($duration, $this->element->getDuration()); + } + + public function testResetDuration() + { + $this->element->setDuration($this->createDurationMock()); + $this->element->setDuration(null); + + $this->assertFalse($this->element->hasDuration()); + $this->assertNull($this->element->getDuration()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Distance + */ + private function createDistanceMock() + { + return $this->createMock(Distance::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Duration + */ + private function createDurationMock() + { + return $this->createMock(Duration::class); + } +} diff --git a/tests/Service/DistanceMatrix/DistanceMatrixRequestTest.php b/tests/Service/DistanceMatrix/DistanceMatrixRequestTest.php new file mode 100644 index 00000000..e0add8b2 --- /dev/null +++ b/tests/Service/DistanceMatrix/DistanceMatrixRequestTest.php @@ -0,0 +1,320 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\DistanceMatrix; + +use Ivory\GoogleMap\Service\Base\TravelMode; +use Ivory\GoogleMap\Service\Base\UnitSystem; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixRequest; + +/** + * @author GeLo + */ +class DistanceMatrixRequestTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DistanceMatrixRequest + */ + private $request; + + /** + * @var string[] + */ + private $origins; + + /** + * @var string[] + */ + private $destinations; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->request = new DistanceMatrixRequest( + $this->origins = ['Paris'], + $this->destinations = ['Lille'] + ); + } + + public function testDefaultState() + { + $this->assertTrue($this->request->hasOrigins()); + $this->assertSame($this->origins, $this->request->getOrigins()); + $this->assertTrue($this->request->hasDestinations()); + $this->assertSame($this->destinations, $this->request->getDestinations()); + $this->assertFalse($this->request->hasTravelMode()); + $this->assertNull($this->request->getTravelMode()); + $this->assertFalse($this->request->hasAvoidHighways()); + $this->assertNull($this->request->getAvoidHighways()); + $this->assertFalse($this->request->hasAvoidTolls()); + $this->assertNull($this->request->getAvoidTolls()); + $this->assertFalse($this->request->hasRegion()); + $this->assertNull($this->request->getRegion()); + $this->assertFalse($this->request->hasUnitSystem()); + $this->assertNull($this->request->getUnitSystem()); + $this->assertFalse($this->request->hasLanguage()); + $this->assertNull($this->request->getLanguage()); + } + + public function testSetOrigins() + { + $this->request->setOrigins($origins = [$origin = 'Paris']); + $this->request->setOrigins($origins); + + $this->assertTrue($this->request->hasOrigins()); + $this->assertTrue($this->request->hasOrigin($origin)); + $this->assertSame($origins, $this->request->getOrigins()); + } + + public function testAddOrigins() + { + $this->request->setOrigins($firstOrigins = ['Paris']); + $this->request->addOrigins($secondOrigins = ['Lille']); + + $this->assertTrue($this->request->hasOrigins()); + $this->assertSame(array_merge($firstOrigins, $secondOrigins), $this->request->getOrigins()); + } + + public function testAddOrigin() + { + $this->request->addOrigin($origin = 'Paris'); + + $this->assertTrue($this->request->hasOrigins()); + $this->assertTrue($this->request->hasOrigin($origin)); + $this->assertSame([$origin], $this->request->getOrigins()); + } + + public function testRemoveOrigin() + { + $this->request->addOrigin($origin = 'Paris'); + $this->request->removeOrigin($origin); + + $this->assertFalse($this->request->hasOrigins()); + $this->assertFalse($this->request->hasOrigin($origin)); + $this->assertEmpty($this->request->getOrigins()); + } + + public function testSetDestinations() + { + $this->request->setDestinations($destinations = [$destination = 'Paris']); + $this->request->setDestinations($destinations); + + $this->assertTrue($this->request->hasDestinations()); + $this->assertTrue($this->request->hasDestination($destination)); + $this->assertSame($destinations, $this->request->getDestinations()); + } + + public function testAddDestinations() + { + $this->request->setDestinations($firstDestinations = ['Paris']); + $this->request->addDestinations($secondDestinations = ['Lille']); + + $this->assertTrue($this->request->hasDestinations()); + $this->assertSame(array_merge($firstDestinations, $secondDestinations), $this->request->getDestinations()); + } + + public function testAddDestination() + { + $this->request->addDestination($destination = 'Paris'); + + $this->assertTrue($this->request->hasDestinations()); + $this->assertTrue($this->request->hasDestination($destination)); + $this->assertSame(array_merge($this->destinations, [$destination]), $this->request->getDestinations()); + } + + public function testRemoveDestination() + { + $this->request->addDestination($destination = 'Paris'); + $this->request->removeDestination($destination); + + $this->assertTrue($this->request->hasDestinations()); + $this->assertFalse($this->request->hasDestination($destination)); + $this->assertSame($this->destinations, $this->request->getDestinations()); + } + + public function testTravelMode() + { + $this->request->setTravelMode($travelMode = TravelMode::WALKING); + + $this->assertTrue($this->request->hasTravelMode()); + $this->assertSame($travelMode, $this->request->getTravelMode()); + } + + public function testResetTravelMode() + { + $this->request->setTravelMode(TravelMode::WALKING); + $this->request->setTravelMode(null); + + $this->assertFalse($this->request->hasTravelMode()); + $this->assertNull($this->request->getTravelMode()); + } + + public function testAvoidHighways() + { + $this->request->setAvoidHighways(true); + + $this->assertTrue($this->request->hasAvoidHighways()); + $this->assertTrue($this->request->getAvoidHighways()); + } + + public function testResetAvoidHighways() + { + $this->request->setAvoidHighways(true); + $this->request->setAvoidHighways(null); + + $this->assertFalse($this->request->hasAvoidHighways()); + $this->assertNull($this->request->getAvoidHighways()); + } + + public function testAvoidTolls() + { + $this->request->setAvoidTolls(true); + + $this->assertTrue($this->request->hasAvoidTolls()); + $this->assertTrue($this->request->getAvoidTolls()); + } + + public function testResetAvoidTolls() + { + $this->request->setAvoidTolls(true); + $this->request->setAvoidTolls(null); + + $this->assertFalse($this->request->hasAvoidTolls()); + $this->assertNull($this->request->getAvoidTolls()); + } + + public function testRegion() + { + $this->request->setRegion($region = 'fr'); + + $this->assertTrue($this->request->hasRegion()); + $this->assertSame($region, $this->request->getRegion()); + } + + public function testResetRegion() + { + $this->request->setRegion('fr'); + $this->request->setRegion(null); + + $this->assertFalse($this->request->hasRegion()); + $this->assertNull($this->request->getRegion()); + } + + public function testUnitSystem() + { + $this->request->setUnitSystem($unitSystem = UnitSystem::IMPERIAL); + + $this->assertTrue($this->request->hasUnitSystem()); + $this->assertSame($unitSystem, $this->request->getUnitSystem()); + } + + public function testResetUnitSystem() + { + $this->request->setUnitSystem(UnitSystem::IMPERIAL); + $this->request->setUnitSystem(null); + + $this->assertFalse($this->request->hasUnitSystem()); + $this->assertNull($this->request->getUnitSystem()); + } + + public function testLanguage() + { + $this->request->setLanguage($language = 'fr'); + + $this->assertTrue($this->request->hasLanguage()); + $this->assertSame($language, $this->request->getLanguage()); + } + + public function testResetLanguage() + { + $this->request->setLanguage('fr'); + $this->request->setLanguage(null); + + $this->assertFalse($this->request->hasLanguage()); + $this->assertNull($this->request->getLanguage()); + } + + public function testQuery() + { + $this->assertSame([ + 'origins' => implode('|', $this->origins), + 'destinations' => implode('|', $this->destinations), + ], $this->request->buildQuery()); + } + + public function testQueryWithTravelMode() + { + $this->request->setTravelMode($travelMode = TravelMode::BICYCLING); + + $this->assertSame([ + 'origins' => implode('|', $this->origins), + 'destinations' => implode('|', $this->destinations), + 'mode' => strtolower($travelMode), + ], $this->request->buildQuery()); + } + + public function testQueryWithAvoidTolls() + { + $this->request->setAvoidTolls(true); + + $this->assertSame([ + 'origins' => implode('|', $this->origins), + 'destinations' => implode('|', $this->destinations), + 'avoidTolls' => true, + ], $this->request->buildQuery()); + } + + public function testQueryWithAvoidHighways() + { + $this->request->setAvoidHighways(true); + + $this->assertSame([ + 'origins' => implode('|', $this->origins), + 'destinations' => implode('|', $this->destinations), + 'avoidHighways' => true, + ], $this->request->buildQuery()); + } + + public function testQueryWithUnitSystem() + { + $this->request->setUnitSystem($unitSystem = UnitSystem::IMPERIAL); + + $this->assertSame([ + 'origins' => implode('|', $this->origins), + 'destinations' => implode('|', $this->destinations), + 'units' => strtolower($unitSystem), + ], $this->request->buildQuery()); + } + + public function testQueryWithRegion() + { + $this->request->setRegion($region = 'fr'); + + $this->assertSame([ + 'origins' => implode('|', $this->origins), + 'destinations' => implode('|', $this->destinations), + 'region' => $region, + ], $this->request->buildQuery()); + } + + public function testQueryWithLanguage() + { + $this->request->setLanguage($language = 'fr'); + + $this->assertSame([ + 'origins' => implode('|', $this->origins), + 'destinations' => implode('|', $this->destinations), + 'language' => $language, + ], $this->request->buildQuery()); + } +} diff --git a/tests/Service/DistanceMatrix/DistanceMatrixResponseTest.php b/tests/Service/DistanceMatrix/DistanceMatrixResponseTest.php new file mode 100644 index 00000000..3aa52eb0 --- /dev/null +++ b/tests/Service/DistanceMatrix/DistanceMatrixResponseTest.php @@ -0,0 +1,186 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\DistanceMatrix; + +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixResponse; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixRow; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixStatus; + +/** + * @author GeLo + */ +class DistanceMatrixResponseTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DistanceMatrixResponse + */ + private $response; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->response = new DistanceMatrixResponse(); + } + + public function testDefaultState() + { + $this->assertFalse($this->response->hasStatus()); + $this->assertNull($this->response->getStatus()); + $this->assertFalse($this->response->hasOrigins()); + $this->assertEmpty($this->response->getOrigins()); + $this->assertFalse($this->response->hasDestinations()); + $this->assertEmpty($this->response->getDestinations()); + $this->assertFalse($this->response->hasRows()); + $this->assertEmpty($this->response->getRows()); + } + + public function testStatus() + { + $this->response->setStatus($status = DistanceMatrixStatus::INVALID_REQUEST); + + $this->assertTrue($this->response->hasStatus()); + $this->assertSame($status, $this->response->getStatus()); + } + + public function testResetStatus() + { + $this->response->setStatus(DistanceMatrixStatus::INVALID_REQUEST); + $this->response->setStatus(null); + + $this->assertFalse($this->response->hasStatus()); + $this->assertNull($this->response->getStatus()); + } + + public function testSetOrigins() + { + $this->response->setOrigins($origins = [$origin = 'Paris']); + $this->response->setOrigins($origins); + + $this->assertTrue($this->response->hasOrigins()); + $this->assertTrue($this->response->hasOrigin($origin)); + $this->assertSame($origins, $this->response->getOrigins()); + } + + public function testAddOrigins() + { + $this->response->setOrigins($firstOrigins = ['Paris']); + $this->response->addOrigins($secondOrigins = ['Lille']); + + $this->assertTrue($this->response->hasOrigins()); + $this->assertSame(array_merge($firstOrigins, $secondOrigins), $this->response->getOrigins()); + } + + public function testAddOrigin() + { + $this->response->addOrigin($origin = 'Paris'); + + $this->assertTrue($this->response->hasOrigins()); + $this->assertTrue($this->response->hasOrigin($origin)); + $this->assertSame([$origin], $this->response->getOrigins()); + } + + public function testRemoveOrigin() + { + $this->response->addOrigin($origin = 'Paris'); + $this->response->removeOrigin($origin); + + $this->assertFalse($this->response->hasOrigins()); + $this->assertFalse($this->response->hasOrigin($origin)); + $this->assertEmpty($this->response->getOrigins()); + } + + public function testSetDestinations() + { + $this->response->setDestinations($destinations = [$destination = 'Paris']); + $this->response->setDestinations($destinations); + + $this->assertTrue($this->response->hasDestinations()); + $this->assertTrue($this->response->hasDestination($destination)); + $this->assertSame($destinations, $this->response->getDestinations()); + } + + public function testAddDestinations() + { + $this->response->setDestinations($firstDestinations = ['Paris']); + $this->response->addDestinations($secondDestinations = ['Lille']); + + $this->assertTrue($this->response->hasDestinations()); + $this->assertSame(array_merge($firstDestinations, $secondDestinations), $this->response->getDestinations()); + } + + public function testAddDestination() + { + $this->response->addDestination($destination = 'Paris'); + + $this->assertTrue($this->response->hasDestinations()); + $this->assertTrue($this->response->hasDestination($destination)); + $this->assertSame([$destination], $this->response->getDestinations()); + } + + public function testRemoveDestination() + { + $this->response->addDestination($destination = 'Paris'); + $this->response->removeDestination($destination); + + $this->assertFalse($this->response->hasDestinations()); + $this->assertFalse($this->response->hasDestination($destination)); + $this->assertEmpty($this->response->getDestinations()); + } + + public function testSetRows() + { + $this->response->setRows($rows = [$row = $this->createRowMock()]); + $this->response->setRows($rows); + + $this->assertTrue($this->response->hasRows()); + $this->assertTrue($this->response->hasRow($row)); + $this->assertSame($rows, $this->response->getRows()); + } + + public function testAddRows() + { + $this->response->setRows($firstRows = [$this->createRowMock()]); + $this->response->addRows($secondRows = [$this->createRowMock()]); + + $this->assertTrue($this->response->hasRows()); + $this->assertSame(array_merge($firstRows, $secondRows), $this->response->getRows()); + } + + public function testAddRow() + { + $this->response->addRow($row = $this->createRowMock()); + + $this->assertTrue($this->response->hasRows()); + $this->assertTrue($this->response->hasRow($row)); + $this->assertSame([$row], $this->response->getRows()); + } + + public function testRemoveRow() + { + $this->response->addRow($row = $this->createRowMock()); + $this->response->removeRow($row); + + $this->assertFalse($this->response->hasRows()); + $this->assertFalse($this->response->hasRow($row)); + $this->assertEmpty($this->response->getRows()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|DistanceMatrixRow + */ + private function createRowMock() + { + return $this->createMock(DistanceMatrixRow::class); + } +} diff --git a/tests/Service/DistanceMatrix/DistanceMatrixRowTest.php b/tests/Service/DistanceMatrix/DistanceMatrixRowTest.php new file mode 100644 index 00000000..bf089f1b --- /dev/null +++ b/tests/Service/DistanceMatrix/DistanceMatrixRowTest.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\DistanceMatrix; + +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixElement; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixRow; + +/** + * @author GeLo + */ +class DistanceMatrixRowTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DistanceMatrixRow + */ + private $row; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->row = new DistanceMatrixRow(); + } + + public function testDefaultState() + { + $this->assertFalse($this->row->hasElements()); + $this->assertEmpty($this->row->getElements()); + } + + public function testSetElements() + { + $this->row->setElements($elements = [$element = $this->createElementMock()]); + $this->row->setElements($elements); + + $this->assertTrue($this->row->hasElements()); + $this->assertTrue($this->row->hasElement($element)); + $this->assertSame($elements, $this->row->getElements()); + } + + public function testAddElements() + { + $this->row->setElements($firstElements = [$this->createElementMock()]); + $this->row->addElements($secondElements = [$this->createElementMock()]); + + $this->assertTrue($this->row->hasElements()); + $this->assertSame(array_merge($firstElements, $secondElements), $this->row->getElements()); + } + + public function testAddElement() + { + $this->row->addElement($element = $this->createElementMock()); + + $this->assertTrue($this->row->hasElements()); + $this->assertTrue($this->row->hasElement($element)); + $this->assertSame([$element], $this->row->getElements()); + } + + public function testRemoveElement() + { + $this->row->addElement($element = $this->createElementMock()); + $this->row->removeElement($element); + + $this->assertFalse($this->row->hasElements()); + $this->assertFalse($this->row->hasElement($element)); + $this->assertEmpty($this->row->getElements()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|DistanceMatrixElement + */ + private function createElementMock() + { + return $this->createMock(DistanceMatrixElement::class); + } +} diff --git a/tests/Service/DistanceMatrix/DistanceMatrixTest.php b/tests/Service/DistanceMatrix/DistanceMatrixTest.php new file mode 100644 index 00000000..8b1531ba --- /dev/null +++ b/tests/Service/DistanceMatrix/DistanceMatrixTest.php @@ -0,0 +1,286 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\DistanceMatrix; + +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Base\TravelMode; +use Ivory\GoogleMap\Service\Base\UnitSystem; +use Ivory\GoogleMap\Service\BusinessAccount; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrix; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixRequest; +use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrixStatus; +use Ivory\Tests\GoogleMap\Service\AbstractServiceTest; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; + +/** + * @author GeLo + */ +class DistanceMatrixTest extends AbstractServiceTest +{ + /** + * @var DistanceMatrix + */ + private $distanceMatrix; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + parent::setUp(); + + $this->distanceMatrix = new DistanceMatrix($this->getClient(), $this->getMessageFactory()); + } + + public function testProcess() + { + $response = $this->distanceMatrix->process(new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco'])); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithCoordinates() + { + $response = $this->distanceMatrix->process(new DistanceMatrixRequest( + [new Coordinate(49.262428, -123.113136)], + [new Coordinate(37.775328, -122.418938)] + )); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithTravelMode() + { + $request = new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco']); + $request->setTravelMode(TravelMode::BICYCLING); + + $response = $this->distanceMatrix->process($request); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithAvoidHighways() + { + $request = new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco']); + $request->setAvoidHighways(true); + + $response = $this->distanceMatrix->process($request); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithAvoidTolls() + { + $request = new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco']); + $request->setAvoidTolls(true); + + $response = $this->distanceMatrix->process($request); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithRegion() + { + $request = new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco']); + $request->setRegion('en'); + + $response = $this->distanceMatrix->process($request); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithUnitSystem() + { + $request = new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco']); + $request->setUnitSystem(UnitSystem::METRIC); + + $response = $this->distanceMatrix->process($request); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithLanguage() + { + $request = new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco']); + $request->setLanguage('fr'); + + $response = $this->distanceMatrix->process($request); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithHttps() + { + $this->distanceMatrix->setHttps(true); + + $response = $this->distanceMatrix->process(new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco'])); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testProcessWithXmlFormat() + { + $request = new DistanceMatrixRequest(['Vancouver BC'], ['San Francisco']); + + $this->distanceMatrix->setFormat(DistanceMatrix::FORMAT_XML); + $response = $this->distanceMatrix->process($request); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getOrigins()); + $this->assertNotEmpty($response->getDestinations()); + $this->assertNotEmpty($response->getRows()); + } + + public function testRouteWithBusinessAccount() + { + $this->distanceMatrix = new DistanceMatrix( + $client = $this->createHttpClientMock(), + $messageFactory = $this->createMessageFactoryMock() + ); + + $request = $this->createDistanceMatrixRequestMock(); + $request + ->expects($this->once()) + ->method('buildQuery') + ->will($this->returnValue($query = ['foo' => 'bar'])); + + $messageFactory + ->expects($this->once()) + ->method('createRequest') + ->with( + $this->identicalTo('GET'), + $this->identicalTo( + $url = 'https://maps.googleapis.com/maps/api/distancematrix/json?foo=bar&signature=signature' + ) + ) + ->will($this->returnValue($httpRequest = $this->createHttpRequestMock())); + + $client + ->expects($this->once()) + ->method('sendRequest') + ->with($this->identicalTo($httpRequest)) + ->will($this->returnValue($httpResponse = $this->createHttpResponseMock())); + + $httpResponse + ->expects($this->once()) + ->method('getBody') + ->will($this->returnValue($httpStream = $this->createHttpStreamMock())); + + $httpStream + ->expects($this->once()) + ->method('__toString') + ->will($this->returnValue('{"status":"OK","origin_addresses":[],"destination_addresses":[],"rows":[]}')); + + $businessAccount = $this->createBusinessAccountMock(); + $businessAccount + ->expects($this->once()) + ->method('signUrl') + ->with($this->equalTo('https://maps.googleapis.com/maps/api/distancematrix/json?foo=bar')) + ->will($this->returnValue($url)); + + $this->distanceMatrix->setBusinessAccount($businessAccount); + + $response = $this->distanceMatrix->process($request); + + $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); + $this->assertEmpty($response->getOrigins()); + $this->assertEmpty($response->getDestinations()); + $this->assertEmpty($response->getRows()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|HttpClient + */ + private function createHttpClientMock() + { + return $this->createMock(HttpClient::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MessageFactory + */ + private function createMessageFactoryMock() + { + return $this->createMock(MessageFactory::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RequestInterface + */ + private function createHttpRequestMock() + { + return $this->createMock(RequestInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ResponseInterface + */ + private function createHttpResponseMock() + { + return $this->createMock(ResponseInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|StreamInterface + */ + private function createHttpStreamMock() + { + return $this->createMock(StreamInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|BusinessAccount + */ + private function createBusinessAccountMock() + { + return $this->createMock(BusinessAccount::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|DistanceMatrixRequest + */ + private function createDistanceMatrixRequestMock() + { + return $this->createMock(DistanceMatrixRequest::class); + } +} diff --git a/tests/Service/Geocoder/GeocoderAddressComponentTest.php b/tests/Service/Geocoder/GeocoderAddressComponentTest.php new file mode 100644 index 00000000..3d7202af --- /dev/null +++ b/tests/Service/Geocoder/GeocoderAddressComponentTest.php @@ -0,0 +1,115 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Geocoder; + +use Ivory\GoogleMap\Service\Geocoder\GeocoderAddressComponent; + +/** + * @author GeLo + */ +class GeocoderAddressComponentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var GeocoderAddressComponent + */ + private $addressComponent; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->addressComponent = new GeocoderAddressComponent(); + } + + public function testInitialState() + { + $this->assertFalse($this->addressComponent->hasLongName()); + $this->assertNull($this->addressComponent->getLongName()); + $this->assertFalse($this->addressComponent->hasShortName()); + $this->assertNull($this->addressComponent->getShortName()); + $this->assertFalse($this->addressComponent->hasTypes()); + $this->assertEmpty($this->addressComponent->getTypes()); + } + + public function testLongName() + { + $this->addressComponent->setLongName($longName = 'foo'); + + $this->assertTrue($this->addressComponent->hasLongName()); + $this->assertSame($longName, $this->addressComponent->getLongName()); + } + + public function testResetLongName() + { + $this->addressComponent->setLongName('foo'); + $this->addressComponent->setLongName(null); + + $this->assertFalse($this->addressComponent->hasLongName()); + $this->assertNull($this->addressComponent->getLongName()); + } + + public function testShortName() + { + $this->addressComponent->setShortName($shortName = 'foo'); + + $this->assertTrue($this->addressComponent->hasShortName()); + $this->assertSame($shortName, $this->addressComponent->getShortName()); + } + + public function testResetShortName() + { + $this->addressComponent->setShortName('foo'); + $this->addressComponent->setShortName(null); + + $this->assertFalse($this->addressComponent->hasShortName()); + $this->assertNull($this->addressComponent->getShortName()); + } + + public function testSetTypes() + { + $this->addressComponent->setTypes($types = [$type = 'type']); + $this->addressComponent->setTypes($types); + + $this->assertTrue($this->addressComponent->hasTypes()); + $this->assertTrue($this->addressComponent->hasType($type)); + $this->assertSame($types, $this->addressComponent->getTypes()); + } + + public function testAddTypes() + { + $this->addressComponent->setTypes($firstTypes = ['first_type']); + $this->addressComponent->addTypes($secondTypes = ['second_type']); + + $this->assertTrue($this->addressComponent->hasTypes()); + $this->assertSame(array_merge($firstTypes, $secondTypes), $this->addressComponent->getTypes()); + } + + public function testAddType() + { + $this->addressComponent->addType($type = 'type'); + + $this->assertTrue($this->addressComponent->hasTypes()); + $this->assertTrue($this->addressComponent->hasType($type)); + $this->assertSame([$type], $this->addressComponent->getTypes()); + } + + public function testRemoveType() + { + $this->addressComponent->addType($type = 'type'); + $this->addressComponent->removeType($type); + + $this->assertFalse($this->addressComponent->hasTypes()); + $this->assertFalse($this->addressComponent->hasType($type)); + $this->assertEmpty($this->addressComponent->getTypes()); + } +} diff --git a/tests/Service/Geocoder/GeocoderGeometryTest.php b/tests/Service/Geocoder/GeocoderGeometryTest.php new file mode 100644 index 00000000..993e1da7 --- /dev/null +++ b/tests/Service/Geocoder/GeocoderGeometryTest.php @@ -0,0 +1,132 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Geocoder; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Geocoder\GeocoderGeometry; +use Ivory\GoogleMap\Service\Geocoder\GeocoderLocationType; + +/** + * @author GeLo + */ +class GeocoderGeometryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var GeocoderGeometry + */ + private $geometry; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->geometry = new GeocoderGeometry(); + } + + public function testInitialState() + { + $this->assertFalse($this->geometry->hasLocation()); + $this->assertNull($this->geometry->getLocation()); + $this->assertFalse($this->geometry->hasLocationType()); + $this->assertNull($this->geometry->getLocationType()); + $this->assertFalse($this->geometry->hasViewport()); + $this->assertNull($this->geometry->getViewport()); + $this->assertFalse($this->geometry->hasBound()); + $this->assertNull($this->geometry->getBound()); + } + + public function testLocation() + { + $this->geometry->setLocation($location = $this->createCoordinateMock()); + + $this->assertTrue($this->geometry->hasLocation()); + $this->assertSame($location, $this->geometry->getLocation()); + } + + public function testResetLocation() + { + $this->geometry->setLocation($this->createCoordinateMock()); + $this->geometry->setLocation(null); + + $this->assertFalse($this->geometry->hasLocation()); + $this->assertNull($this->geometry->getLocation()); + } + + public function testLocationType() + { + $this->geometry->setLocationType($locationType = GeocoderLocationType::GEOMETRIC_CENTER); + + $this->assertTrue($this->geometry->hasLocationType()); + $this->assertSame($locationType, $this->geometry->getLocationType()); + } + + public function testResetLocationType() + { + $this->geometry->setLocationType(GeocoderLocationType::GEOMETRIC_CENTER); + $this->geometry->setLocationType(null); + + $this->assertFalse($this->geometry->hasLocationType()); + $this->assertNull($this->geometry->getLocationType()); + } + + public function testViewport() + { + $this->geometry->setViewport($viewport = $this->createBoundMock()); + + $this->assertTrue($this->geometry->hasViewport()); + $this->assertSame($viewport, $this->geometry->getViewport()); + } + + public function testResetViewport() + { + $this->geometry->setViewport($this->createBoundMock()); + $this->geometry->setViewport(null); + + $this->assertFalse($this->geometry->hasViewport()); + $this->assertNull($this->geometry->getViewport()); + } + + public function testBound() + { + $this->geometry->setBound($bound = $this->createBoundMock()); + + $this->assertTrue($this->geometry->hasBound()); + $this->assertSame($bound, $this->geometry->getBound()); + } + + public function testResetBound() + { + $this->geometry->setBound($this->createBoundMock()); + $this->geometry->setBound(null); + + $this->assertFalse($this->geometry->hasBound()); + $this->assertNull($this->geometry->getBound()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Service/Geocoder/GeocoderProviderTest.php b/tests/Service/Geocoder/GeocoderProviderTest.php new file mode 100644 index 00000000..9a7edf70 --- /dev/null +++ b/tests/Service/Geocoder/GeocoderProviderTest.php @@ -0,0 +1,293 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Geocoder; + +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\BusinessAccount; +use Ivory\GoogleMap\Service\Geocoder\GeocoderProvider; +use Ivory\GoogleMap\Service\Geocoder\GeocoderRequest; +use Ivory\GoogleMap\Service\Geocoder\GeocoderStatus; +use Ivory\Tests\GoogleMap\Service\AbstractServiceTest; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; + +/** + * @author GeLo + */ +class GeocoderProviderTest extends AbstractServiceTest +{ + /** + * @var GeocoderProvider + */ + private $geocoder; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + parent::setUp(); + + $this->geocoder = new GeocoderProvider($this->getClient(), $this->getMessageFactory()); + } + + public function testLimit() + { + $this->geocoder->limit($limit = 1); + + $this->assertSame($limit, $this->geocoder->getLimit()); + } + + public function testLocale() + { + $this->geocoder->setLocale($locale = 'fr'); + + $this->assertSame($locale, $this->geocoder->getLocale()); + } + + public function testGeocode() + { + $response = $this->geocoder->geocode('Paris'); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithIp() + { + $response = $this->geocoder->geocode('66.249.64.1'); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithRequest() + { + $request = new GeocoderRequest('Paris'); + $request->setBound(new Bound(new Coordinate(48.815573, 2.224199), new Coordinate(48.9021449, 2.4699208))); + $request->setRegion('fr'); + $request->setLanguage('pl'); + + $response = $this->geocoder->geocode($request); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithBound() + { + $request = new GeocoderRequest('Paris'); + $request->setBound(new Bound(new Coordinate(48.815573, 2.224199), new Coordinate(48.9021449, 2.4699208))); + + $response = $this->geocoder->geocode($request); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithRegion() + { + $request = new GeocoderRequest('Paris'); + $request->setRegion('fr'); + + $response = $this->geocoder->geocode($request); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithLanguage() + { + $request = new GeocoderRequest('Paris'); + $request->setLanguage('pl'); + + $response = $this->geocoder->geocode($request); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithHttps() + { + $this->geocoder->setHttps(true); + + $response = $this->geocoder->geocode('Paris'); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithXmlFormat() + { + $this->geocoder->setFormat(GeocoderProvider::FORMAT_XML); + $response = $this->geocoder->geocode('Paris'); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithLimit() + { + $this->geocoder->limit(1); + $response = $this->geocoder->geocode('Chelsea, New York, NY, USA'); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertCount(1, $response->getResults()); + } + + public function testGeocodeWithLocale() + { + $this->geocoder->setLocale('fr'); + $response = $this->geocoder->geocode('Paris'); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testGeocodeWithBusinessAccount() + { + $this->geocoder = new GeocoderProvider( + $client = $this->createHttpClientMock(), + $messageFactory = $this->createMessageFactoryMock() + ); + + $request = $this->createGeocoderRequestMock(); + $request + ->expects($this->once()) + ->method('buildQuery') + ->will($this->returnValue($query = ['foo' => 'bar'])); + + $messageFactory + ->expects($this->once()) + ->method('createRequest') + ->with( + $this->identicalTo('GET'), + $this->identicalTo( + $url = 'https://maps.googleapis.com/maps/api/geocoder/json?foo=bar&signature=signature' + ) + ) + ->will($this->returnValue($httpRequest = $this->createHttpRequestMock())); + + $client + ->expects($this->once()) + ->method('sendRequest') + ->with($this->identicalTo($httpRequest)) + ->will($this->returnValue($httpResponse = $this->createHttpResponseMock())); + + $httpResponse + ->expects($this->once()) + ->method('getBody') + ->will($this->returnValue($httpStream = $this->createHttpStreamMock())); + + $httpStream + ->expects($this->once()) + ->method('__toString') + ->will($this->returnValue('{"status":"OK","results":[]}')); + + $businessAccount = $this->createBusinessAccountMock(); + $businessAccount + ->expects($this->once()) + ->method('signUrl') + ->with($this->equalTo('https://maps.googleapis.com/maps/api/geocode/json?foo=bar')) + ->will($this->returnValue($url)); + + $this->geocoder->setBusinessAccount($businessAccount); + + $response = $this->geocoder->geocode($request); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertEmpty($response->getResults()); + } + + public function testReverse() + { + $response = $this->geocoder->reverse(48.856633, 2.352254); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testReverseWithXmlFormat() + { + $this->geocoder->setFormat(GeocoderProvider::FORMAT_XML); + + $response = $this->geocoder->reverse(48.856633, 2.352254); + + $this->assertSame(GeocoderStatus::OK, $response->getStatus()); + $this->assertNotEmpty($response->getResults()); + } + + public function testName() + { + $this->assertSame('ivory_google_map', $this->geocoder->getName()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|HttpClient + */ + private function createHttpClientMock() + { + return $this->createMock(HttpClient::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MessageFactory + */ + private function createMessageFactoryMock() + { + return $this->createMock(MessageFactory::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RequestInterface + */ + private function createHttpRequestMock() + { + return $this->createMock(RequestInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|ResponseInterface + */ + private function createHttpResponseMock() + { + return $this->createMock(ResponseInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|StreamInterface + */ + private function createHttpStreamMock() + { + return $this->createMock(StreamInterface::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|BusinessAccount + */ + private function createBusinessAccountMock() + { + return $this->createMock(BusinessAccount::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|GeocoderRequest + */ + private function createGeocoderRequestMock() + { + return $this->createMock(GeocoderRequest::class); + } +} diff --git a/tests/Service/Geocoder/GeocoderRequestTest.php b/tests/Service/Geocoder/GeocoderRequestTest.php new file mode 100644 index 00000000..634cf995 --- /dev/null +++ b/tests/Service/Geocoder/GeocoderRequestTest.php @@ -0,0 +1,225 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Geocoder; + +use Ivory\GoogleMap\Base\Bound; +use Ivory\GoogleMap\Base\Coordinate; +use Ivory\GoogleMap\Service\Geocoder\GeocoderRequest; + +/** + * @author GeLo + */ +class GeocoderRequestTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var GeocoderRequest + */ + private $request; + + /** + * @var string + */ + private $address; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->request = new GeocoderRequest($this->address = 'Lille'); + } + + public function testDefaultState() + { + $this->assertSame($this->address, $this->request->getAddress()); + $this->assertFalse($this->request->hasBound()); + $this->assertNull($this->request->getBound()); + $this->assertFalse($this->request->hasRegion()); + $this->assertNull($this->request->getRegion()); + $this->assertFalse($this->request->hasLanguage()); + $this->assertNull($this->request->getLanguage()); + } + + /** + * @param Coordinate|string $address + * + * @dataProvider addressProvider + */ + public function testAddress($address) + { + $this->request->setAddress($address); + + $this->assertSame($address, $this->request->getAddress()); + } + + public function testBound() + { + $this->request->setBound($bound = $this->createBoundMock()); + + $this->assertTrue($this->request->hasBound()); + $this->assertSame($bound, $this->request->getBound()); + } + + public function testResetBound() + { + $this->request->setBound($this->createBoundMock()); + $this->request->setBound(null); + + $this->assertFalse($this->request->hasBound()); + $this->assertNull($this->request->getBound()); + } + + public function testRegion() + { + $this->request->setRegion($region = 'fr'); + + $this->assertTrue($this->request->hasRegion()); + $this->assertSame($region, $this->request->getRegion()); + } + + public function testResetRegion() + { + $this->request->setRegion('fr'); + $this->request->setRegion(null); + + $this->assertFalse($this->request->hasRegion()); + $this->assertNull($this->request->getRegion()); + } + + public function testLanguage() + { + $this->request->setLanguage($language = 'pl'); + + $this->assertTrue($this->request->hasLanguage()); + $this->assertSame($language, $this->request->getLanguage()); + } + + public function testResetLanguage() + { + $this->request->setLanguage('pl'); + $this->request->setLanguage(null); + + $this->assertFalse($this->request->hasLanguage()); + $this->assertNull($this->request->getLanguage()); + } + + public function testQuery() + { + $this->assertSame(['address' => $this->address], $this->request->buildQuery()); + } + + public function testQueryWithCoordinate() + { + $address = $this->createCoordinateMock(); + $address + ->expects($this->once()) + ->method('getLatitude') + ->will($this->returnValue($latitude = 1.2)); + + $address + ->expects($this->once()) + ->method('getLongitude') + ->will($this->returnValue($longitude = 2.3)); + + $this->request->setAddress($address); + + $this->assertSame(['latlng' => $latitude.','.$longitude], $this->request->buildQuery()); + } + + public function testQueryWithBound() + { + $bound = $this->createBoundMock(); + $bound + ->expects($this->once()) + ->method('getSouthWest') + ->will($this->returnValue($southWest = $this->createCoordinateMock())); + + $southWest + ->expects($this->once()) + ->method('getLatitude') + ->will($this->returnValue($southWestLatitude = 1.2)); + + $southWest + ->expects($this->once()) + ->method('getLongitude') + ->will($this->returnValue($southWestLongitude = 2.3)); + + $bound + ->expects($this->once()) + ->method('getNorthEast') + ->will($this->returnValue($northEast = $this->createCoordinateMock())); + + $northEast + ->expects($this->once()) + ->method('getLatitude') + ->will($this->returnValue($northEastLatitude = 3.4)); + + $northEast + ->expects($this->once()) + ->method('getLongitude') + ->will($this->returnValue($northEastLongitude = 4.5)); + + $this->request->setBound($bound); + + $this->assertSame([ + 'address' => $this->address, + 'bound' => $southWestLatitude.','.$southWestLongitude.'|'.$northEastLatitude.','.$northEastLongitude, + ], $this->request->buildQuery()); + } + + public function testQueryWithRegion() + { + $this->request->setRegion($region = 'fr'); + + $this->assertSame([ + 'address' => $this->address, + 'region' => 'fr', + ], $this->request->buildQuery()); + } + + public function testQueryWithLanguage() + { + $this->request->setLanguage($language = 'fr'); + + $this->assertSame([ + 'address' => $this->address, + 'language' => 'fr', + ], $this->request->buildQuery()); + } + + /** + * @return mixed[][] + */ + public function addressProvider() + { + return [ + ['Lille'], + [$this->createCoordinateMock()], + ]; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Coordinate + */ + private function createCoordinateMock() + { + return $this->createMock(Coordinate::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Bound + */ + private function createBoundMock() + { + return $this->createMock(Bound::class); + } +} diff --git a/tests/Service/Geocoder/GeocoderResponseTest.php b/tests/Service/Geocoder/GeocoderResponseTest.php new file mode 100644 index 00000000..33bb419e --- /dev/null +++ b/tests/Service/Geocoder/GeocoderResponseTest.php @@ -0,0 +1,106 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Geocoder; + +use Ivory\GoogleMap\Service\Geocoder\GeocoderResponse; +use Ivory\GoogleMap\Service\Geocoder\GeocoderResult; +use Ivory\GoogleMap\Service\Geocoder\GeocoderStatus; + +/** + * @author GeLo + */ +class GeocoderResponseTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var GeocoderResponse + */ + private $response; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->response = new GeocoderResponse(); + } + + public function testInitialState() + { + $this->assertFalse($this->response->hasStatus()); + $this->assertNull($this->response->getStatus()); + $this->assertFalse($this->response->hasResults()); + $this->assertEmpty($this->response->getResults()); + } + + public function testStatus() + { + $this->response->setStatus($status = GeocoderStatus::ERROR); + + $this->assertTrue($this->response->hasStatus()); + $this->assertSame($status, $this->response->getStatus()); + } + + public function testResetStatus() + { + $this->response->setStatus(GeocoderStatus::ERROR); + $this->response->setStatus(null); + + $this->assertFalse($this->response->hasStatus()); + $this->assertNull($this->response->getStatus()); + } + + public function testSetResults() + { + $this->response->setResults($results = [$result = $this->createResultMock()]); + $this->response->setResults($results); + + $this->assertTrue($this->response->hasResults()); + $this->assertTrue($this->response->hasResult($result)); + $this->assertSame($results, $this->response->getResults()); + } + + public function testAddResults() + { + $this->response->setResults($firstResults = [$this->createResultMock()]); + $this->response->addResults($secondResults = [$this->createResultMock()]); + + $this->assertTrue($this->response->hasResults()); + $this->assertSame(array_merge($firstResults, $secondResults), $this->response->getResults()); + } + + public function testAddResult() + { + $this->response->addResult($result = $this->createResultMock()); + + $this->assertTrue($this->response->hasResults()); + $this->assertTrue($this->response->hasResult($result)); + $this->assertSame([$result], $this->response->getResults()); + } + + public function testRemoveResult() + { + $this->response->addResult($result = $this->createResultMock()); + $this->response->removeResult($result); + + $this->assertFalse($this->response->hasResults()); + $this->assertFalse($this->response->hasResult($result)); + $this->assertEmpty($this->response->getResults()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|GeocoderResult + */ + private function createResultMock() + { + return $this->createMock(GeocoderResult::class); + } +} diff --git a/tests/Service/Geocoder/GeocoderResultTest.php b/tests/Service/Geocoder/GeocoderResultTest.php new file mode 100644 index 00000000..f4c716e5 --- /dev/null +++ b/tests/Service/Geocoder/GeocoderResultTest.php @@ -0,0 +1,213 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Geocoder; + +use Ivory\GoogleMap\Service\Geocoder\GeocoderAddressComponent; +use Ivory\GoogleMap\Service\Geocoder\GeocoderGeometry; +use Ivory\GoogleMap\Service\Geocoder\GeocoderResult; + +/** + * @author GeLo + */ +class GeocoderResultTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var GeocoderResult + */ + private $result; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->result = new GeocoderResult(); + } + + public function testInitialState() + { + $this->assertFalse($this->result->hasAddressComponents()); + $this->assertEmpty($this->result->getAddressComponents()); + $this->assertFalse($this->result->hasFormattedAddress()); + $this->assertNull($this->result->getFormattedAddress()); + $this->assertFalse($this->result->hasGeometry()); + $this->assertNull($this->result->getGeometry()); + $this->assertFalse($this->result->hasTypes()); + $this->assertEmpty($this->result->getTypes()); + $this->assertFalse($this->result->hasPartialMatch()); + $this->assertNull($this->result->isPartialMatch()); + } + + public function testSetAddressComponents() + { + $addressComponents = [$addressComponent = $this->createAddressComponentMock()]; + + $this->result->setAddressComponents($addressComponents); + $this->result->setAddressComponents($addressComponents); + + $this->assertTrue($this->result->hasAddressComponents()); + $this->assertTrue($this->result->hasAddressComponent($addressComponent)); + $this->assertSame($addressComponents, $this->result->getAddressComponents()); + } + + public function testAddAddressComponents() + { + $this->result->setAddressComponents($firstAddressComponents = [$this->createAddressComponentMock()]); + $this->result->addAddressComponents($secondAddressComponents = [$this->createAddressComponentMock()]); + + $this->assertTrue($this->result->hasAddressComponents()); + $this->assertSame( + array_merge($firstAddressComponents, $secondAddressComponents), + $this->result->getAddressComponents() + ); + } + + public function testAddAddressComponent() + { + $this->result->addAddressComponent($addressComponent = $this->createAddressComponentMock()); + + $this->assertTrue($this->result->hasAddressComponents()); + $this->assertTrue($this->result->hasAddressComponent($addressComponent)); + $this->assertSame([$addressComponent], $this->result->getAddressComponents()); + } + + public function testRemoveAddressComponent() + { + $this->result->addAddressComponent($addressComponent = $this->createAddressComponentMock()); + $this->result->removeAddressComponent($addressComponent); + + $this->assertFalse($this->result->hasAddressComponents()); + $this->assertFalse($this->result->hasAddressComponent($addressComponent)); + $this->assertEmpty($this->result->getAddressComponents()); + } + + public function testTypedAddressComponents() + { + $addressComponent = $this->createAddressComponentMock(); + $addressComponent + ->expects($this->exactly(4)) + ->method('getTypes') + ->will($this->returnValue([$type = 'foo'])); + + $this->result->setAddressComponents($addressComponents = [$addressComponent]); + + $this->assertTrue($this->result->hasAddressComponents($type)); + $this->assertSame($addressComponents, $this->result->getAddressComponents($type)); + $this->assertFalse($this->result->hasAddressComponents('bar')); + $this->assertEmpty($this->result->getAddressComponents('bar')); + } + + public function testFormattedAddress() + { + $this->result->setFormattedAddress($formattedAddress = 'foo'); + + $this->assertTrue($this->result->hasFormattedAddress()); + $this->assertSame($formattedAddress, $this->result->getFormattedAddress()); + } + + public function testResetFormattedAddress() + { + $this->result->setFormattedAddress('foo'); + $this->result->setFormattedAddress(null); + + $this->assertFalse($this->result->hasFormattedAddress()); + $this->assertNull($this->result->getFormattedAddress()); + } + + public function testGeometry() + { + $this->result->setGeometry($geometry = $this->createGeometryMock()); + + $this->assertTrue($this->result->hasGeometry()); + $this->assertSame($geometry, $this->result->getGeometry()); + } + + public function testResetGeometry() + { + $this->result->setGeometry($this->createGeometryMock()); + $this->result->setGeometry(null); + + $this->assertFalse($this->result->hasGeometry()); + $this->assertNull($this->result->getGeometry()); + } + + public function testPartialMatch() + { + $this->result->setPartialMatch(true); + + $this->assertTrue($this->result->hasPartialMatch()); + $this->assertTrue($this->result->isPartialMatch()); + } + + public function testResetPartialMatch() + { + $this->result->setPartialMatch(true); + $this->result->setPartialMatch(null); + + $this->assertFalse($this->result->hasPartialMatch()); + $this->assertNull($this->result->isPartialMatch()); + } + + public function testSetTypes() + { + $this->result->setTypes($types = [$type = 'foo']); + $this->result->setTypes($types); + + $this->assertTrue($this->result->hasTypes()); + $this->assertTrue($this->result->hasType($type)); + $this->assertSame($types, $this->result->getTypes()); + } + + public function testAddTypes() + { + $this->result->setTypes($firstTypes = ['foo']); + $this->result->addTypes($secondTypes = ['bar']); + + $this->assertTrue($this->result->hasTypes()); + $this->assertSame(array_merge($firstTypes, $secondTypes), $this->result->getTypes()); + } + + public function testAddType() + { + $this->result->addType($type = 'foo'); + + $this->assertTrue($this->result->hasTypes()); + $this->assertTrue($this->result->hasType($type)); + $this->assertSame([$type], $this->result->getTypes()); + } + + public function testRemoveType() + { + $this->result->addType($type = 'foo'); + $this->result->removeType($type); + + $this->assertFalse($this->result->hasTypes()); + $this->assertFalse($this->result->hasType($type)); + $this->assertEmpty($this->result->getTypes()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|GeocoderAddressComponent + */ + private function createAddressComponentMock() + { + return $this->createMock(GeocoderAddressComponent::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|GeocoderGeometry + */ + private function createGeometryMock() + { + return $this->createMock(GeocoderGeometry::class); + } +} diff --git a/tests/Service/ServiceTest.php b/tests/Service/ServiceTest.php new file mode 100644 index 00000000..0ff56e5c --- /dev/null +++ b/tests/Service/ServiceTest.php @@ -0,0 +1,166 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service; + +use Http\Client\HttpClient; +use Http\Message\MessageFactory; +use Ivory\GoogleMap\Service\AbstractService; +use Ivory\GoogleMap\Service\BusinessAccount; +use Ivory\GoogleMap\Service\Utility\XmlParser; + +/** + * @author GeLo + */ +class ServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AbstractService|\PHPUnit_Framework_MockObject_MockObject + */ + private $service; + + /** + * @var HttpClient|\PHPUnit_Framework_MockObject_MockObject + */ + private $client; + + /** + * @var MessageFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $messageFactory; + + /** + * @var string + */ + private $url; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->service = $this->getMockBuilder(AbstractService::class) + ->setConstructorArgs([ + $this->client = $this->createHttpClientMock(), + $this->messageFactory = $this->createMessageFactoryMock(), + $this->url = 'http://foo', + ]) + ->getMockForAbstractClass(); + } + + public function testDefaultState() + { + $this->assertSame($this->client, $this->service->getClient()); + $this->assertSame($this->messageFactory, $this->service->getMessageFactory()); + $this->assertSame('https://foo', $this->service->getUrl()); + $this->assertTrue($this->service->isHttps()); + $this->assertSame(AbstractService::FORMAT_JSON, $this->service->getFormat()); + $this->assertInstanceOf(XmlParser::class, $this->service->getXmlParser()); + $this->assertFalse($this->service->hasBusinessAccount()); + $this->assertNull($this->service->getBusinessAccount()); + } + + public function testClient() + { + $this->service->setClient($client = $this->createHttpClientMock()); + + $this->assertSame($client, $this->service->getClient()); + } + + public function testMessageFactory() + { + $this->service->setMessageFactory($messageFactory = $this->createMessageFactoryMock()); + + $this->assertSame($messageFactory, $this->service->getMessageFactory()); + } + + public function testHttps() + { + $this->service->setHttps(true); + + $this->assertTrue($this->service->isHttps()); + } + + public function testUrl() + { + $this->assertSame('https://foo', $this->service->getUrl()); + } + + public function testUrlWithHttps() + { + $this->service->setHttps(false); + + $this->assertSame('http://foo', $this->service->getUrl()); + } + + public function testFormat() + { + $this->service->setFormat($format = AbstractService::FORMAT_XML); + + $this->assertSame($format, $this->service->getFormat()); + } + + public function testXmlParser() + { + $this->service->setXmlParser($xmlParser = $this->createXmlParserMock()); + + $this->assertSame($xmlParser, $this->service->getXmlParser()); + } + + public function testBusinessAccount() + { + $this->service->setBusinessAccount($businessAccount = $this->createBusinessAccountMock()); + + $this->assertTrue($this->service->hasBusinessAccount()); + $this->assertSame($businessAccount, $this->service->getBusinessAccount()); + } + + public function testResetBusinessAccount() + { + $this->service->setBusinessAccount($this->createBusinessAccountMock()); + $this->service->setBusinessAccount(); + + $this->assertFalse($this->service->hasBusinessAccount()); + $this->assertNull($this->service->getBusinessAccount()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|HttpClient + */ + private function createHttpClientMock() + { + return $this->createMock(HttpClient::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|MessageFactory + */ + private function createMessageFactoryMock() + { + return $this->createMock(MessageFactory::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|XmlParser + */ + private function createXmlParserMock() + { + return $this->createMock(XmlParser::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|BusinessAccount + */ + private function createBusinessAccountMock() + { + return $this->createMock(BusinessAccount::class); + } +} diff --git a/tests/Service/Utility/XmlParserTest.php b/tests/Service/Utility/XmlParserTest.php new file mode 100644 index 00000000..a971ce08 --- /dev/null +++ b/tests/Service/Utility/XmlParserTest.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Service\Utility; + +use Ivory\GoogleMap\Service\Utility\XmlParser; + +/** + * @author GeLo + */ +class XmlParserTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var XmlParser + */ + private $xmlParser; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->xmlParser = new XmlParser(); + } + + /** + * @param string $xml + * @param mixed[] $expected + * @param string[] $rules + * + * @dataProvider parseProvider + */ + public function testParse($xml, array $expected, array $rules = []) + { + $this->assertSame($expected, $this->xmlParser->parse($xml, $rules)); + } + + /** + * @return mixed[] + */ + public function parseProvider() + { + $xml = 'bar'; + + return [ + [$xml, ['foo' => 'bar']], + [$xml, ['baz' => ['bar']], ['foo' => 'baz']], + ]; + } +} diff --git a/tests/Services/AbstractServiceTest.php b/tests/Services/AbstractServiceTest.php deleted file mode 100644 index c864c2c3..00000000 --- a/tests/Services/AbstractServiceTest.php +++ /dev/null @@ -1,195 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services; - -use Ivory\GoogleMap\Services\BusinessAccount; - -/** - * Abstract service test. - * - * @author GeLo - */ -class AbstractServiceTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\AbstractService */ - protected $service; - - /** @var \Widop\HttpAdapter\HttpAdapterInterface */ - protected $httpAdapter; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->httpAdapter = $this->getMock('Widop\HttpAdapter\HttpAdapterInterface'); - - $this->service = $this->getMockBuilder('Ivory\GoogleMap\Services\AbstractService') - ->setConstructorArgs(array($this->httpAdapter, 'http://foo')) - ->getMockForAbstractClass(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->httpAdapter); - unset($this->service); - } - - public function testDefaultState() - { - $this->assertSame($this->httpAdapter, $this->service->getHttpAdapter()); - $this->assertSame('http://foo', $this->service->getUrl()); - $this->assertFalse($this->service->isHttps()); - $this->assertSame('json', $this->service->getFormat()); - $this->assertInstanceOf('Ivory\GoogleMap\Services\Utils\XmlParser', $this->service->getXmlParser()); - $this->assertFalse($this->service->hasBusinessAccount()); - $this->assertNull($this->service->getBusinessAccount()); - } - - public function testInitialState() - { - $xmlParser = $this->getMock('Ivory\GoogleMap\Services\Utils\XmlParser'); - - $businessAccount = $this->getMockBuilder('Ivory\GoogleMap\Services\BusinessAccount') - ->disableOriginalConstructor() - ->getMock(); - - $this->service = $this->getMockBuilder('Ivory\GoogleMap\Services\AbstractService') - ->setConstructorArgs(array($this->httpAdapter, 'http://bar', true, 'xml', $xmlParser, $businessAccount)) - ->getMockForAbstractClass(); - - $this->assertSame($this->httpAdapter, $this->service->getHttpAdapter()); - $this->assertSame('https://bar', $this->service->getUrl()); - $this->assertTrue($this->service->isHttps()); - $this->assertSame('xml', $this->service->getFormat()); - $this->assertSame($xmlParser, $this->service->getXmlParser()); - $this->assertTrue($this->service->hasBusinessAccount()); - $this->assertSame($businessAccount, $this->service->getBusinessAccount()); - } - - public function testHttpAdapter() - { - $httpAdapter = $this->getMock('Widop\HttpAdapter\HttpAdapterInterface'); - $this->service->setHttpAdapter($httpAdapter); - - $this->assertSame($httpAdapter, $this->service->getHttpAdapter()); - } - - public function testHttps() - { - $this->service->setHttps(true); - - $this->assertTrue($this->service->isHttps()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The service https flag must be a boolean value. - */ - public function testHttpsWithInvalidValue() - { - $this->service->setHttps('foo'); - } - - public function testUrlWithHttps() - { - $this->service->setHttps(true); - $this->assertSame('https://foo', $this->service->getUrl()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The service url must be a string value. - */ - public function testUrlWithInvalidValue() - { - $this->service->setUrl(true); - } - - public function testFormatWithJsonAndXml() - { - $this->service->setFormat('xml'); - $this->assertSame('xml', $this->service->getFormat()); - - $this->service->setFormat('json'); - $this->assertSame('json', $this->service->getFormat()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The service format can only be : json, xml. - */ - public function testFormatWithInvalidValue() - { - $this->service->setFormat('foo'); - } - - public function testXmlParser() - { - $xmlParser = $this->getMock('Ivory\GoogleMap\Services\Utils\XmlParser'); - $this->service->setXmlParser($xmlParser); - - $this->assertSame($xmlParser, $this->service->getXmlParser()); - } - - public function testBusinessAccount() - { - $businessAccount = $this->getMockBuilder('Ivory\GoogleMap\Services\BusinessAccount') - ->disableOriginalConstructor() - ->getMock(); - - $this->service->setBusinessAccount($businessAccount); - - $this->assertTrue($this->service->hasBusinessAccount()); - $this->assertSame($businessAccount, $this->service->getBusinessAccount()); - - $this->service->setBusinessAccount(); - - $this->assertFalse($this->service->hasBusinessAccount()); - $this->assertNull($this->service->getBusinessAccount()); - } - - public function testSignUrlWithoutBusinessAccount() - { - $method = new \ReflectionMethod($this->service, 'signUrl'); - $method->setAccessible(true); - - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - - $this->assertSame($url, $method->invoke($this->service, $url)); - } - - public function testSignUrlWithBusinessAccount() - { - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - - $businessAccount = $this->getMockBuilder('Ivory\GoogleMap\Services\BusinessAccount') - ->disableOriginalConstructor() - ->getMock(); - - $businessAccount - ->expects($this->once()) - ->method('signUrl') - ->with($this->equalTo($url)) - ->will($this->returnValue('url')); - - $this->service->setBusinessAccount($businessAccount); - - $method = new \ReflectionMethod($this->service, 'signUrl'); - $method->setAccessible(true); - - $this->assertSame('url', $method->invoke($this->service, $url)); - } -} diff --git a/tests/Services/Base/DistanceTest.php b/tests/Services/Base/DistanceTest.php deleted file mode 100644 index 335604e7..00000000 --- a/tests/Services/Base/DistanceTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Service; - -use Ivory\GoogleMap\Services\Base\Distance; - -/** - * Distance test. - * - * @author GeLo - */ -class DistanceTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Base\Distance */ - protected $distance; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->distance = new Distance('foo', 2.2); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->distance); - } - - public function testInitialState() - { - $this->assertSame('foo', $this->distance->getText()); - $this->assertSame(2.2, $this->distance->getValue()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The distance text must be a string value. - */ - public function testTextWithInvalidValue() - { - $this->distance->setText(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The distance value must be a numeric value. - */ - public function testValueWithInvalidValue() - { - $this->distance->setValue('foo'); - } -} diff --git a/tests/Services/Base/DurationTest.php b/tests/Services/Base/DurationTest.php deleted file mode 100644 index 828d6643..00000000 --- a/tests/Services/Base/DurationTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Base; - -use Ivory\GoogleMap\Services\Base\Duration; - -/** - * Duration test. - * - * @author GeLo - */ -class DurationTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Base\Duration */ - protected $duration; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->duration = new Duration('foo', 2.2); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->duration); - } - - public function testInitialState() - { - $this->assertSame('foo', $this->duration->getText()); - $this->assertSame(2.2, $this->duration->getValue()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The duration text must be a string value. - */ - public function testTextWithInvalidValue() - { - $this->duration->setText(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The duration value must be a numeric value. - */ - public function testValueWithInvalidValue() - { - $this->duration->setValue('foo'); - } -} diff --git a/tests/Services/Base/TravelModeTest.php b/tests/Services/Base/TravelModeTest.php deleted file mode 100644 index a37ebcfc..00000000 --- a/tests/Services/Base/TravelModeTest.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Base; - -use Ivory\GoogleMap\Services\Base\TravelMode; - -/** - * Travel mode test. - * - * @author GeLo - */ -class TravelModeTest extends \PHPUnit_Framework_TestCase -{ - public function testTravelModes() - { - $expected = array( - TravelMode::BICYCLING, - TravelMode::DRIVING, - TravelMode::WALKING, - TravelMode::TRANSIT, - ); - - $this->assertSame($expected, TravelMode::getTravelModes()); - } -} diff --git a/tests/Services/Base/UnitSystemTest.php b/tests/Services/Base/UnitSystemTest.php deleted file mode 100644 index 5613bd35..00000000 --- a/tests/Services/Base/UnitSystemTest.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Base; - -use Ivory\GoogleMap\Services\Base\UnitSystem; - -/** - * Unit system test. - * - * @author GeLo - */ -class UnitSystemTest extends \PHPUnit_Framework_TestCase -{ - public function testUnitSystems() - { - $expected = array( - UnitSystem::IMPERIAL, - UnitSystem::METRIC, - ); - - $this->assertSame($expected, UnitSystem::getUnitSystems()); - } -} diff --git a/tests/Services/BusinessAccountTest.php b/tests/Services/BusinessAccountTest.php deleted file mode 100644 index 48f87027..00000000 --- a/tests/Services/BusinessAccountTest.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services; - -use Ivory\GoogleMap\Services\BusinessAccount; - -/** - * Business account test. - * - * @author GeLo - */ -class BusinessAccountTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\BusinessAccount */ - protected $businessAccount; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->businessAccount = new BusinessAccount('client_id', 'secret'); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->businessAccount); - } - - public function testDefaultState() - { - $this->assertSame('client_id', $this->businessAccount->getClientId()); - $this->assertSame('secret', $this->businessAccount->getSecret()); - $this->assertFalse($this->businessAccount->hasChannel()); - $this->assertNull($this->businessAccount->getChannel()); - } - - public function testInitialState() - { - $this->businessAccount = new BusinessAccount('client_id', 'secret', 'channel'); - - $this->assertTrue($this->businessAccount->hasChannel()); - $this->assertSame('channel', $this->businessAccount->getChannel()); - } - - public function testClientId() - { - $this->businessAccount->setClientId('foo'); - - $this->assertSame('foo', $this->businessAccount->getClientId()); - } - - public function testSecret() - { - $this->businessAccount->setSecret('foo'); - - $this->assertSame('foo', $this->businessAccount->getSecret()); - } - - public function testChannel() - { - $this->businessAccount->setChannel('foo'); - - $this->assertSame('foo', $this->businessAccount->getChannel()); - } - - public function testSignUrlWithoutChannel() - { - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - $expected = $url.'&client=gme-client_id&signature=EO4W2ipM4YzwEIOM1pRZ5xbrl8k='; - - $this->assertSame($expected, $this->businessAccount->signUrl($url)); - } - - public function testSignUrlWithChannel() - { - $this->businessAccount->setChannel('channel'); - - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - $expected = $url.'&client=gme-client_id&channel=channel&signature=e9BFlnQaKg-t3NIxKbilkQeTU1Y='; - - $this->assertSame($expected, $this->businessAccount->signUrl($url)); - } -} diff --git a/tests/Services/Directions/DirectionsLegTest.php b/tests/Services/Directions/DirectionsLegTest.php deleted file mode 100644 index 3d18c3ad..00000000 --- a/tests/Services/Directions/DirectionsLegTest.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Services\Directions\DirectionsLeg; - -/** - * Directions leg test. - * - * @author GeLo - */ -class DirectionsLegTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Directions\DirectionsLeg */ - protected $directionsLeg; - - /** @var \Ivory\GoogleMap\Services\Base\Distance */ - protected $distance; - - /** @var \Ivory\GoogleMap\Services\Base\Duration */ - protected $duration; - - /** @var string */ - protected $endAddress; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $endLocation; - - /** @var string */ - protected $startAddress; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $startLocation; - - /** @var array */ - protected $steps; - - /** @var array */ - protected $viaWaypoint; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->distance = $this->getMockBuilder('Ivory\GoogleMap\Services\Base\Distance') - ->disableOriginalConstructor() - ->getMock(); - - $this->duration = $this->getMockBuilder('Ivory\GoogleMap\Services\Base\Duration') - ->disableOriginalConstructor() - ->getMock(); - - $this->endAddress = 'foo'; - $this->endLocation = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->startAddress = 'bar'; - $this->startLocation = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $step = $this->getMockBuilder('Ivory\GoogleMap\Services\Directions\DirectionsStep') - ->disableOriginalConstructor() - ->getMock(); - - $this->steps = array($step); - $this->viaWaypoint = array('foo'); - - $this->directionsLeg = new DirectionsLeg( - $this->distance, - $this->duration, - $this->endAddress, - $this->endLocation, - $this->startAddress, - $this->startLocation, - $this->steps, - $this->viaWaypoint - ); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->directionsLeg); - unset($this->duration); - unset($this->distance); - unset($this->endAddress); - unset($this->endLocation); - unset($this->startAddress); - unset($this->startLocation); - unset($this->steps); - unset($this->viaWaypoint); - } - - public function testInitialState() - { - $this->assertSame($this->duration, $this->directionsLeg->getDuration()); - $this->assertSame($this->distance, $this->directionsLeg->getDistance()); - $this->assertSame($this->endAddress, $this->directionsLeg->getEndAddress()); - $this->assertSame($this->endLocation, $this->directionsLeg->getEndLocation()); - $this->assertSame($this->startAddress, $this->directionsLeg->getStartAddress()); - $this->assertSame($this->startLocation, $this->directionsLeg->getStartLocation()); - $this->assertSame($this->steps, $this->directionsLeg->getSteps()); - $this->assertSame($this->viaWaypoint, $this->directionsLeg->getViaWaypoints()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The leg end address must be a string value. - */ - public function testEndAddressWithInvalidValue() - { - $this->directionsLeg->setEndAddress(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The leg start address must be a string value. - */ - public function testStartAddressWithInvalidValue() - { - $this->directionsLeg->setStartAddress(true); - } -} diff --git a/tests/Services/Directions/DirectionsRequestTest.php b/tests/Services/Directions/DirectionsRequestTest.php deleted file mode 100644 index ff6a8af7..00000000 --- a/tests/Services/Directions/DirectionsRequestTest.php +++ /dev/null @@ -1,535 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Directions; - -use \DateTime; -use Ivory\GoogleMap\Services\Directions\DirectionsRequest; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; - -/** - * Directions request test. - * - * @author GeLo - */ -class DirectionsRequestTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Directions\DirectionsRequest */ - protected $directionsRequest; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->directionsRequest = new DirectionsRequest(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->directionsRequest); - } - - public function testDefaultState() - { - $this->assertFalse($this->directionsRequest->hasAvoidHighways()); - $this->assertFalse($this->directionsRequest->hasAvoidTolls()); - $this->assertFalse($this->directionsRequest->hasDestination()); - $this->assertFalse($this->directionsRequest->hasOptimizeWaypoints()); - $this->assertFalse($this->directionsRequest->hasOrigin()); - $this->assertFalse($this->directionsRequest->hasDepartureTime()); - $this->assertFalse($this->directionsRequest->hasArrivalTime()); - $this->assertFalse($this->directionsRequest->hasProvideRouteAlternatives()); - $this->assertFalse($this->directionsRequest->hasRegion()); - $this->assertFalse($this->directionsRequest->hasLanguage()); - $this->assertFalse($this->directionsRequest->hasTravelMode()); - $this->assertFalse($this->directionsRequest->hasUnitSystem()); - $this->assertFalse($this->directionsRequest->hasWaypoints()); - } - - public function testAvoidHightwaysWithValidValue() - { - $this->directionsRequest->setAvoidHighways(true); - - $this->assertTrue($this->directionsRequest->hasAvoidHighways()); - $this->assertTrue($this->directionsRequest->getAvoidHighways()); - } - - public function testAvoidHighwaysWithNullValue() - { - $this->directionsRequest->setAvoidHighways(true); - $this->directionsRequest->setAvoidHighways(null); - - $this->assertNull($this->directionsRequest->getAvoidHighways()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request avoid hightways flag must be a boolean value. - */ - public function testAvoidHighwaysWithInvalidValue() - { - $this->directionsRequest->setAvoidHighways('foo'); - } - - public function testAvoidTollsWithValidValue() - { - $this->directionsRequest->setAvoidTolls(true); - - $this->assertTrue($this->directionsRequest->hasAvoidTolls()); - $this->assertTrue($this->directionsRequest->getAvoidTolls()); - } - - public function testAvoidTollsWithNullValue() - { - $this->directionsRequest->setAvoidTolls(true); - $this->directionsRequest->setAvoidTolls(null); - - $this->assertNull($this->directionsRequest->getAvoidTolls()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request avoid tolls flag must be a boolean value. - */ - public function testAvoidTollsWithInvalidValue() - { - $this->directionsRequest->setAvoidTolls('foo'); - } - - public function testDestinationWithString() - { - $this->directionsRequest->setDestination('foo'); - - $this->assertTrue($this->directionsRequest->hasDestination()); - $this->assertEquals($this->directionsRequest->getDestination(), 'foo'); - } - - public function testDestinationWithCoordinate() - { - $location = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->directionsRequest->setDestination($location); - - $this->assertSame($location, $this->directionsRequest->getDestination()); - } - - public function testDestinationWithLatitudeAndLongitude() - { - $this->directionsRequest->setDestination(1.1, 2.1, false); - - $this->assertSame(1.1, $this->directionsRequest->getDestination()->getLatitude()); - $this->assertSame(2.1, $this->directionsRequest->getDestination()->getLongitude()); - $this->assertFalse($this->directionsRequest->getDestination()->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The destination setter arguments are invalid. - * The available prototypes are : - * - function setDestination(string $destination) - * - function setDestination(Ivory\GoogleMap\Base\Coordinate $destination) - * - function setDestination(double $latitude, double $longitude, boolean $noWrap) - */ - public function testDestinationWithInvalidValue() - { - $this->directionsRequest->setDestination(true); - } - - public function testOptimizeWaypointsWithValidValue() - { - $this->directionsRequest->setOptimizeWaypoints(true); - - $this->assertTrue($this->directionsRequest->hasOptimizeWaypoints()); - $this->assertTrue($this->directionsRequest->getOptimizeWaypoints()); - } - - public function testOptimizeWaypointsWithNullValue() - { - $this->directionsRequest->setOptimizeWaypoints(true); - $this->directionsRequest->setOptimizeWaypoints(null); - - $this->assertNull($this->directionsRequest->getOptimizeWaypoints()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request optimize waypoints flag must be a boolean value. - */ - public function testOptimizeWaypointsWithInvalidValue() - { - $this->directionsRequest->setOptimizeWaypoints('foo'); - } - - public function testOriginWithString() - { - $this->directionsRequest->setOrigin('foo'); - - $this->assertTrue($this->directionsRequest->hasOrigin()); - $this->assertSame('foo', $this->directionsRequest->getOrigin()); - } - - public function testOriginWithCoordinate() - { - $origin = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->directionsRequest->setOrigin($origin); - - $this->assertSame($origin, $this->directionsRequest->getOrigin()); - } - - public function testOriginWithLatitudeAndLongitude() - { - $this->directionsRequest->setOrigin(1.1, 2.1, false); - - $this->assertSame(1.1, $this->directionsRequest->getOrigin()->getLatitude()); - $this->assertSame(2.1, $this->directionsRequest->getOrigin()->getLongitude()); - $this->assertFalse($this->directionsRequest->getOrigin()->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The origin setter arguments are invalid. - * The available prototypes are : - * - function setOrigin(string $destination) - * - function setOrigin(Ivory\GoogleMap\Base\Coordinate $destination) - * - function setOrigin(double $latitude, double $longitude, boolean $noWrap) - */ - public function testOriginWithInvalidValue() - { - $this->directionsRequest->setOrigin(true); - } - - public function testDepartureTimeWithValidValue() - { - $now = new DateTime(); - $this->directionsRequest->setDepartureTime($now); - - $this->assertTrue($this->directionsRequest->hasDepartureTime()); - $this->assertSame($now, $this->directionsRequest->getDepartureTime()); - } - - public function testDepartureTimeWithNullValue() - { - $this->directionsRequest->setDepartureTime(new DateTime()); - $this->directionsRequest->setDepartureTime(null); - - $this->assertNull($this->directionsRequest->getDepartureTime()); - } - - public function testArrivalTimeWithValidValue() - { - $now = new DateTime(); - $this->directionsRequest->setArrivalTime($now); - - $this->assertTrue($this->directionsRequest->hasArrivalTime()); - $this->assertSame($now, $this->directionsRequest->getArrivalTime()); - } - - public function testArrivalTimeWithNullValue() - { - $this->directionsRequest->setArrivalTime(new DateTime()); - $this->directionsRequest->setArrivalTime(null); - - $this->assertNull($this->directionsRequest->getArrivalTime()); - } - - public function testProvideRouteAlternativesWithValidValue() - { - $this->directionsRequest->setProvideRouteAlternatives(true); - - $this->assertTrue($this->directionsRequest->hasProvideRouteAlternatives()); - $this->assertTrue($this->directionsRequest->getProvideRouteAlternatives()); - } - - public function testProvideRouteAlternativesWithNullValue() - { - $this->directionsRequest->setProvideRouteAlternatives(true); - $this->directionsRequest->setProvideRouteAlternatives(null); - - $this->assertNull($this->directionsRequest->getProvideRouteAlternatives()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request provide route alternatives flag must be a boolean value. - */ - public function testProvideRouteAlternativesWithInvalidValue() - { - $this->directionsRequest->setProvideRouteAlternatives('foo'); - } - - public function testRegionWithValidValue() - { - $this->directionsRequest->setRegion('fr'); - - $this->assertTrue($this->directionsRequest->hasRegion()); - $this->assertSame('fr', $this->directionsRequest->getRegion()); - } - - public function testRegionWithNullValue() - { - $this->directionsRequest->setRegion('fr'); - $this->directionsRequest->setRegion(null); - - $this->assertNull($this->directionsRequest->getRegion()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request region must be a string with two characters. - */ - public function testRegionWithInvalidValue() - { - $this->directionsRequest->setRegion('foo'); - } - - public function testLanguageWithValidValue() - { - $this->directionsRequest->setLanguage('fr'); - - $this->assertTrue($this->directionsRequest->hasLanguage()); - $this->assertSame('fr', $this->directionsRequest->getLanguage()); - } - - public function testLanguageWithNullValue() - { - $this->directionsRequest->setLanguage('fr'); - $this->directionsRequest->setLanguage(null); - - $this->assertNull($this->directionsRequest->getLanguage()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request language must be a string with two or five characters. - */ - public function testLanguageWithInvalidValue() - { - $this->directionsRequest->setLanguage('foo'); - } - - public function testTravelModeWithValidValue() - { - $this->directionsRequest->setTravelMode(TravelMode::WALKING); - - $this->assertTrue($this->directionsRequest->hasTravelMode()); - $this->assertSame(TravelMode::WALKING, $this->directionsRequest->getTravelMode()); - } - - public function testTravelModeWithNullValue() - { - $this->directionsRequest->setTravelMode(TravelMode::WALKING); - $this->directionsRequest->setTravelMode(null); - - $this->assertNull($this->directionsRequest->getTravelMode()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request travel mode can only be : BICYCLING, DRIVING, WALKING, TRANSIT. - */ - public function testTravelModeWithInvalidValue() - { - $this->directionsRequest->setTravelMode('foo'); - } - - public function testUnitSystemWithValidValue() - { - $this->directionsRequest->setUnitSystem(UnitSystem::IMPERIAL); - - $this->assertTrue($this->directionsRequest->hasUnitSystem()); - $this->assertSame(UnitSystem::IMPERIAL, $this->directionsRequest->getUnitSystem()); - } - - public function testUnitSystemWithNullValue() - { - $this->directionsRequest->setUnitSystem(UnitSystem::IMPERIAL); - $this->directionsRequest->setUnitSystem(null); - - $this->assertNull($this->directionsRequest->getUnitSystem()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request unit system can only be : IMPERIAL, METRIC. - */ - public function testUnitSystemWithInvalidValue() - { - $this->directionsRequest->setUnitSystem('foo'); - } - - public function testWaypointWithWaypoint() - { - $waypoint = $this->getMock('Ivory\GoogleMap\Services\Directions\DirectionsWaypoint'); - $this->directionsRequest->setWaypoints(array($waypoint)); - - $this->assertTrue($this->directionsRequest->hasWaypoints()); - $this->assertSame(array($waypoint), $this->directionsRequest->getWaypoints()); - } - - public function testWaypointWithCoordinate() - { - $coordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->directionsRequest->setWaypoints(array($coordinate)); - - $waypoints = $this->directionsRequest->getWaypoints(); - - $this->assertArrayHasKey(0, $waypoints); - $this->assertSame($coordinate, $waypoints[0]->getLocation()); - } - - public function testWaypointWithLatitudeAndLongitude() - { - $this->directionsRequest->addWaypoint(1.1, 2.2, false); - - $waypoints = $this->directionsRequest->getWaypoints(); - - $this->assertArrayHasKey(0, $waypoints); - $this->assertSame(1.1, $waypoints[0]->getLocation()->getLatitude()); - $this->assertSame(2.2, $waypoints[0]->getLocation()->getLongitude()); - $this->assertFalse($waypoints[0]->getLocation()->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The waypoint adder arguments are invalid. - * The available prototypes are : - * - function addWaypoint(Ivory\GoogleMap\Services\Directions\DirectionsWaypoint $waypoint) - * - function addWaypoint(string $location) - * - function addWaypoint(Ivory\GoogleMap\Base\Coordinate $location) - * - function addWaypoint(double $latitude, double $longitude, boolean $noWrap) - */ - public function testWaypointWithInvalidValue() - { - $this->directionsRequest->addWaypoint(true); - } - - public function testSensorWithValidValue() - { - $this->directionsRequest->setSensor(true); - - $this->assertTrue($this->directionsRequest->hasSensor()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request sensor flag must be a boolean value. - */ - public function testSensorWithInvalidValue() - { - $this->directionsRequest->setSensor('foo'); - } - - public function testIsValid() - { - $this->assertFalse($this->directionsRequest->isValid()); - } - - public function testIsValidWithOrigin() - { - $this->directionsRequest->setOrigin('foo'); - - $this->assertFalse($this->directionsRequest->isValid()); - } - - public function testIsValidWithDestination() - { - $this->directionsRequest->setDestination('foo'); - - $this->assertFalse($this->directionsRequest->isValid()); - } - - public function testIsValidWithOriginAndDestination() - { - $this->directionsRequest->setDestination('foo'); - $this->directionsRequest->setOrigin('bar'); - - $this->assertTrue($this->directionsRequest->isValid()); - } - - public function testIsValidWithValidWaypoint() - { - $waypoint = $this->getMock('Ivory\GoogleMap\Services\Directions\DirectionsWaypoint'); - $waypoint - ->expects($this->once()) - ->method('isValid') - ->will($this->returnValue(true)); - - $this->directionsRequest->setDestination('foo'); - $this->directionsRequest->setOrigin('bar'); - $this->directionsRequest->addWaypoint($waypoint); - - $this->assertTrue($this->directionsRequest->isValid()); - } - - public function testIsValidWithInvalidWaypoint() - { - $waypoint = $this->getMock('Ivory\GoogleMap\Services\Directions\DirectionsWaypoint'); - $waypoint - ->expects($this->once()) - ->method('isValid') - ->will($this->returnValue(false)); - - $this->directionsRequest->setDestination('foo'); - $this->directionsRequest->setOrigin('bar'); - $this->directionsRequest->addWaypoint($waypoint); - - $this->assertFalse($this->directionsRequest->isValid()); - } - - public function testIsValidWithInvalidTransit() - { - $this->directionsRequest->setDestination('foo'); - $this->directionsRequest->setOrigin('bar'); - - $this->directionsRequest->setTravelMode(TravelMode::TRANSIT); - - $this->assertFalse($this->directionsRequest->isValid()); - } - - public function testIsValidWithValidTransitDepartureTime() - { - $this->directionsRequest->setDestination('foo'); - $this->directionsRequest->setOrigin('bar'); - - $this->directionsRequest->setTravelMode(TravelMode::TRANSIT); - $this->directionsRequest->setDepartureTime(new DateTime()); - - $this->assertTrue($this->directionsRequest->isValid()); - } - - public function testIsValidWithTransitArrivalTime() - { - $this->directionsRequest->setDestination('foo'); - $this->directionsRequest->setOrigin('bar'); - - $this->directionsRequest->setTravelMode(TravelMode::TRANSIT); - $this->directionsRequest->setArrivalTime(new DateTime()); - - $this->assertTrue($this->directionsRequest->isValid()); - } - - public function testIsValidWithValidTransitDepartureTimeAndArrivalTime() - { - $this->directionsRequest->setDestination('foo'); - $this->directionsRequest->setOrigin('bar'); - - $this->directionsRequest->setTravelMode(TravelMode::TRANSIT); - $this->directionsRequest->setArrivalTime(new DateTime()); - $this->directionsRequest->setDepartureTime(new DateTime()); - - $this->assertTrue($this->directionsRequest->isValid()); - } -} diff --git a/tests/Services/Directions/DirectionsResponseTest.php b/tests/Services/Directions/DirectionsResponseTest.php deleted file mode 100644 index 36e7dc0d..00000000 --- a/tests/Services/Directions/DirectionsResponseTest.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Services\Directions\DirectionsResponse; -use Ivory\GoogleMap\Services\Directions\DirectionsStatus; - -/** - * Directions response test. - * - * @author GeLo - */ -class DirectionsResponseTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Directions\DirectionsResponse */ - protected $directionsResponse; - - /** @var array */ - protected $routes; - - /** @var string */ - protected $status; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $route = $this->getMockBuilder('Ivory\GoogleMap\Services\Directions\DirectionsRoute') - ->disableOriginalConstructor() - ->getMock(); - - $this->routes = array($route); - $this->status = DirectionsStatus::NOT_FOUND; - - $this->directionsResponse = new DirectionsResponse($this->routes, $this->status); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->directionsResponse); - unset($this->routes); - unset($this->status); - } - - public function testDefaultState() - { - $this->assertSame($this->routes, $this->directionsResponse->getRoutes()); - $this->assertSame($this->status, $this->directionsResponse->getStatus()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions response status can only be : INVALID_REQUEST, - * MAX_WAYPOINTS_EXCEEDED, NOT_FOUND, OK, OVER_QUERY_LIMIT, REQUEST_DENIED, UNKNOWN_ERROR, ZERO_RESULTS. - */ - public function testStatusWithInvalidValue() - { - $this->directionsResponse->setStatus('foo'); - } -} diff --git a/tests/Services/Directions/DirectionsRouteTest.php b/tests/Services/Directions/DirectionsRouteTest.php deleted file mode 100644 index 2cd30deb..00000000 --- a/tests/Services/Directions/DirectionsRouteTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Services\Directions\DirectionsRoute; - -/** - * Directions route test. - * - * @author GeLo - */ -class DirectionsRouteTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Directions\DirectionsRoute */ - protected $directionsRoute; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** @var string */ - protected $copyrights; - - /** @var array */ - protected $legs; - - /** @var \Ivory\GoogleMap\Overlays\EncodedPolyline */ - protected $encodedPolyline; - - /** @var string */ - protected $summary; - - /** @var array */ - protected $warnings; - - /** @var array */ - protected $waypointOrder; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $this->copyrights = 'foo'; - - $leg = $this->getMockBuilder('Ivory\GoogleMap\Services\Directions\DirectionsLeg') - ->disableOriginalConstructor() - ->getMock(); - - $this->legs = array($leg); - - $this->encodedPolyline = $this->getMock('Ivory\GoogleMap\Overlays\EncodedPolyline'); - $this->summary = 'bar'; - $this->warnings = array('foo', 'baz'); - $this->waypointOrder = array(3, 2, 1); - - $this->directionsRoute = new DirectionsRoute( - $this->bound, - $this->copyrights, - $this->legs, - $this->encodedPolyline, - $this->summary, - $this->warnings, - $this->waypointOrder - ); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->directionsRoute); - unset($this->bound); - unset($this->copyrights); - unset($this->legs); - unset($this->encodedPolyline); - unset($this->summary); - unset($this->warnings); - unset($this->waypointOrder); - } - - public function testInitialState() - { - $this->assertSame($this->bound, $this->directionsRoute->getBound()); - $this->assertSame($this->copyrights, $this->directionsRoute->getCopyrights()); - $this->assertSame($this->legs, $this->directionsRoute->getLegs()); - $this->assertSame($this->encodedPolyline, $this->directionsRoute->getOverviewPolyline()); - $this->assertSame($this->summary, $this->directionsRoute->getSummary()); - $this->assertSame($this->warnings, $this->directionsRoute->getWarnings()); - $this->assertSame($this->waypointOrder, $this->directionsRoute->getWaypointOrder()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions route copyrights must be a string value. - */ - public function testCopyrightsWithInvalidValue() - { - $this->directionsRoute->setCopyrights(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions route summary must be a string value. - */ - public function testSummaryWithInvalidValue() - { - $this->directionsRoute->setSummary(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions route warning must be a string value. - */ - public function testWarningsWithInvalidValue() - { - $this->directionsRoute->addWarning(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions route waypoint order must be an integer value. - */ - public function testWaypointOrderWithInvalidValue() - { - $this->directionsRoute->addWaypointOrder(true); - } -} diff --git a/tests/Services/Directions/DirectionsStatusTest.php b/tests/Services/Directions/DirectionsStatusTest.php deleted file mode 100644 index 9df965f7..00000000 --- a/tests/Services/Directions/DirectionsStatusTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Services\Directions\DirectionsStatus; - -/** - * Directions status test. - * - * @author GeLo - */ -class DirectionsStatusTest extends \PHPUnit_Framework_TestCase -{ - public function testDirectionsStatus() - { - $expected = array( - DirectionsStatus::INVALID_REQUEST, - DirectionsStatus::MAX_WAYPOINTS_EXCEEDED, - DirectionsStatus::NOT_FOUND, - DirectionsStatus::OK, - DirectionsStatus::OVER_QUERY_LIMIT, - DirectionsStatus::REQUEST_DENIED, - DirectionsStatus::UNKNOWN_ERROR, - DirectionsStatus::ZERO_RESULTS, - ); - - $this->assertSame($expected, DirectionsStatus::getDirectionsStatus()); - } -} diff --git a/tests/Services/Directions/DirectionsStepTest.php b/tests/Services/Directions/DirectionsStepTest.php deleted file mode 100644 index 7727097f..00000000 --- a/tests/Services/Directions/DirectionsStepTest.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Services\Directions\DirectionsStep; -use Ivory\GoogleMap\Services\Base\TravelMode; - -/** - * Directions step test. - * - * @author GeLo - */ -class DirectionsStepTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Directions\DirectionsStep */ - protected $directionsStep; - - /** @var \Ivory\GoogleMap\Services\Base\Distance */ - protected $distance; - - /** @var \Ivory\GoogleMap\Services\Base\Duration */ - protected $duration; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $endLocation; - - /** @var string */ - protected $instructions; - - /** @var \Ivory\GoogleMap\Overlays\EncodedPolyline */ - protected $encodedPolyline; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $startLocation; - - /** @var string */ - protected $travelMode; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->distance = $this->getMockBuilder('Ivory\GoogleMap\Services\Base\Distance') - ->disableOriginalConstructor() - ->getMock(); - - $this->duration = $this->getMockBuilder('Ivory\GoogleMap\Services\Base\Duration') - ->disableOriginalConstructor() - ->getMock(); - - $this->endLocation = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->instructions = 'instructions'; - $this->encodedPolyline = $this->getMock('Ivory\GoogleMap\Overlays\EncodedPolyline'); - $this->startLocation = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->travelMode = TravelMode::DRIVING; - - $this->directionsStep = new DirectionsStep( - $this->distance, - $this->duration, - $this->endLocation, - $this->instructions, - $this->encodedPolyline, - $this->startLocation, - $this->travelMode - ); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->directionsStep); - unset($this->distance); - unset($this->duration); - unset($this->endLocation); - unset($this->instructions); - unset($this->encodedPolyline); - unset($this->startLocation); - unset($this->travelMode); - } - - public function testInitialState() - { - $this->assertSame($this->distance, $this->directionsStep->getDistance()); - $this->assertSame($this->duration, $this->directionsStep->getDuration()); - $this->assertSame($this->endLocation, $this->directionsStep->getEndLocation()); - $this->assertSame($this->instructions, $this->directionsStep->getInstructions()); - $this->assertSame($this->encodedPolyline, $this->directionsStep->getEncodedPolyline()); - $this->assertSame($this->startLocation, $this->directionsStep->getStartLocation()); - $this->assertSame($this->travelMode, $this->directionsStep->getTravelMode()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The step instructions must be a string value. - */ - public function testInstructionsWithInvalidValue() - { - $this->directionsStep->setInstructions(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions step travel mode can only be : BICYCLING, DRIVING, WALKING, TRANSIT. - */ - public function testTravelModeWithInvalidValue() - { - $this->directionsStep->setTravelMode('foo'); - } -} diff --git a/tests/Services/Directions/DirectionsTest.php b/tests/Services/Directions/DirectionsTest.php deleted file mode 100644 index 732ea8d4..00000000 --- a/tests/Services/Directions/DirectionsTest.php +++ /dev/null @@ -1,285 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Directions; - -use \DateTime; -use Ivory\GoogleMap\Services\Directions\Directions; -use Ivory\GoogleMap\Services\Directions\DirectionsRequest; -use Ivory\GoogleMap\Services\Directions\DirectionsStatus; -use Ivory\GoogleMap\Services\Directions\DirectionsWaypoint; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; -use Widop\HttpAdapter\CurlHttpAdapter; - -/** - * Directions test. - * - * @author GeLo - */ -class DirectionsTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Directions\Directions */ - protected $directions; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - sleep(5); - - $this->directions = new Directions(new CurlHttpAdapter()); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->directions); - } - - public function testRouteWithOriginAndDestination() - { - $response = $this->directions->route('Lille', 'Paris'); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequest() - { - $request = new DirectionsRequest(); - $request->setOrigin(50.629381, 3.057268); - $request->setDestination(48.856633, 2.352254); - $request->setTravelMode(TravelMode::DRIVING); - $request->setProvideRouteAlternatives(true); - $request->setUnitSystem(UnitSystem::METRIC); - $request->setRegion('fr'); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndStringWaypointAndOptimizeWaypoint() - { - $request = new DirectionsRequest(); - $request->setOrigin('Lille'); - $request->addWaypoint('Compiègne'); - $request->setDestination('Paris'); - - $request->setOptimizeWaypoints(true); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndCoordinateWaypoint() - { - $request = new DirectionsRequest(); - $request->setOrigin('Lille'); - $request->addWaypoint(49.418079, 2.826190); - $request->setDestination('Paris'); - - $request->setOptimizeWaypoints(true); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndStopoverWaypoint() - { - $waypoint = new DirectionsWaypoint(); - $waypoint->setLocation('Compiègne'); - $waypoint->setStopover(true); - - $request = new DirectionsRequest(); - $request->setOrigin('Lille'); - $request->addWaypoint($waypoint); - $request->setDestination('Paris'); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndAvoidTolls() - { - $request = new DirectionsRequest(); - $request->setOrigin('Lille'); - $request->setDestination('Paris'); - $request->setAvoidTolls(true); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndAvoidHighways() - { - $request = new DirectionsRequest(); - $request->setOrigin('Lille'); - $request->setDestination('Paris'); - $request->setAvoidHighways(true); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndLanguage() - { - $request = new DirectionsRequest(); - $request->setOrigin('Lille'); - $request->setDestination('Paris'); - $request->setLanguage('fr'); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndTransitModeAndDepartureTime() - { - $request = new DirectionsRequest(); - $request->setOrigin('601-625 Ashbury Street, San Francisco'); - $request->setDestination('Bike Route 95, San Francisco'); - - $request->setTravelMode(TravelMode::TRANSIT); - $request->setDepartureTime(new DateTime()); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndTransitModeAndArrivalTime() - { - $request = new DirectionsRequest(); - $request->setOrigin('601-625 Ashbury Street, San Francisco'); - $request->setDestination('Bike Route 95, San Francisco'); - - $request->setTravelMode(TravelMode::TRANSIT); - $request->setArrivalTime(new DateTime('+2 hours')); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithDirectionsRequestAndTransitModeAndDepartureTimeAndArrivalTime() - { - $request = new DirectionsRequest(); - $request->setOrigin('601-625 Ashbury Street, San Francisco'); - $request->setDestination('Bike Route 95, San Francisco'); - - $request->setTravelMode(TravelMode::TRANSIT); - $request->setArrivalTime(new DateTime()); - $request->setArrivalTime(new DateTime('+2 hours')); - - $response = $this->directions->route($request); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testRouteWithXmlFormat() - { - $this->directions->setFormat('xml'); - $response = $this->directions->route('Lille', 'Paris'); - - $this->assertSame(DirectionsStatus::OK, $response->getStatus()); - $this->assertNotEmpty($response->getRoutes()); - } - - public function testSignUrlWithoutBusinessAccount() - { - $method = new \ReflectionMethod($this->directions, 'signUrl'); - $method->setAccessible(true); - - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - - $this->assertSame($url, $method->invoke($this->directions, $url)); - } - - public function testSignUrlWithBusinessAccount() - { - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - - $businessAccount = $this->getMockBuilder('Ivory\GoogleMap\Services\BusinessAccount') - ->disableOriginalConstructor() - ->getMock(); - - $businessAccount - ->expects($this->once()) - ->method('signUrl') - ->with($this->equalTo($url)) - ->will($this->returnValue('url')); - - $this->directions->setBusinessAccount($businessAccount); - - $method = new \ReflectionMethod($this->directions, 'signUrl'); - $method->setAccessible(true); - - $this->assertSame('url', $method->invoke($this->directions, $url)); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The route arguments are invalid. - * The available prototypes are: - * - function route(string $origin, string $destination) - * - function route(Ivory\GoogleMap\Services\Directions\DirectionsRequest $request) - */ - public function testRouteWithInvalidRequestParameters() - { - $this->directions->route(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions request is not valid. It needs at least an origin and a destination. - * If you add waypoint to the directions request, it needs at least a location. - */ - public function testRouteWithInvalidRequest() - { - $this->directions->route(new DirectionsRequest()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The service result is not valid. - */ - public function testRouteWithInvalidResult() - { - $httpAdapterMock = $this->getMock('Widop\HttpAdapter\HttpAdapterInterface'); - $httpAdapterMock - ->expects($this->once()) - ->method('getContent') - ->will($this->returnValue(null)); - - $this->directions = new Directions($httpAdapterMock); - $this->directions->route('Lille', 'Paris'); - } -} diff --git a/tests/Services/Directions/DirectionsWaypointTest.php b/tests/Services/Directions/DirectionsWaypointTest.php deleted file mode 100644 index 68770823..00000000 --- a/tests/Services/Directions/DirectionsWaypointTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Directions; - -use Ivory\GoogleMap\Services\Directions\DirectionsWaypoint; - -/** - * Directions waypoint test. - * - * @author GeLo - */ -class DirectionsWaypointTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Directions\DirectionsWaypoint */ - protected $directionsWaypoint; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->directionsWaypoint = new DirectionsWaypoint(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->directionsWaypoint); - } - - public function testDefaultState() - { - $this->assertFalse($this->directionsWaypoint->hasLocation()); - $this->assertFalse($this->directionsWaypoint->hasStopover()); - } - - public function testLocationWithString() - { - $this->directionsWaypoint->setLocation('address'); - $this->assertTrue($this->directionsWaypoint->hasLocation()); - $this->assertEquals($this->directionsWaypoint->getLocation(), 'address'); - } - - public function testLocationWithCoordinate() - { - $location = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->directionsWaypoint->setLocation($location); - - $this->assertSame($location, $this->directionsWaypoint->getLocation()); - } - - public function testLocationWithLatitudeAndLongitude() - { - $this->directionsWaypoint->setLocation(1.1, 2.1, false); - - $this->assertSame(1.1, $this->directionsWaypoint->getLocation()->getLatitude()); - $this->assertSame(2.1, $this->directionsWaypoint->getLocation()->getLongitude()); - $this->assertFalse($this->directionsWaypoint->getLocation()->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The location setter arguments are invalid. - * The available prototypes are : - * - function setLocation(string $destination) - * - function setLocation(Ivory\GoogleMap\Base\Coordinate $destination) - * - function setLocation(double $latitude, double $longitude, boolean $noWrap) - */ - public function testLocationWithInvalidValue() - { - $this->directionsWaypoint->setLocation(true); - } - - public function testStopoverWithValieValue() - { - $this->directionsWaypoint->setStopover(true); - - $this->assertTrue($this->directionsWaypoint->hasStopover()); - $this->assertTrue($this->directionsWaypoint->getStopover()); - } - - public function testStopoverWithNullValue() - { - $this->directionsWaypoint->setStopover(true); - $this->directionsWaypoint->setStopover(null); - - $this->assertFalse($this->directionsWaypoint->hasStopover()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DirectionsException - * @expectedExceptionMessage The directions waypoint stopover flag must be a boolean value. - */ - public function testStopoverWithInvalidValue() - { - $this->directionsWaypoint->setStopover('foo'); - } - - public function testIsValidWithoutLocation() - { - $this->assertFalse($this->directionsWaypoint->isValid()); - } - - public function testIsValidWithLocation() - { - $this->directionsWaypoint->setLocation('foo'); - - $this->assertTrue($this->directionsWaypoint->isValid()); - } -} diff --git a/tests/Services/DistanceMatrix/DistanceMatrixElementStatusTest.php b/tests/Services/DistanceMatrix/DistanceMatrixElementStatusTest.php deleted file mode 100644 index d6386a97..00000000 --- a/tests/Services/DistanceMatrix/DistanceMatrixElementStatusTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixElementStatus; - -/** - * Distance matrix element status test. - * - * @author GeLo - */ -class DirectionsMatrixElementStatusTest extends \PHPUnit_Framework_TestCase -{ - public function testDistanceMatrixElementStatus() - { - $expected = array( - DistanceMatrixElementStatus::NOT_FOUND, - DistanceMatrixElementStatus::OK, - DistanceMatrixElementStatus::ZERO_RESULTS, - ); - - $this->assertSame($expected, DistanceMatrixElementStatus::getDistanceMatrixElementStatus()); - } -} diff --git a/tests/Services/DistanceMatrix/DistanceMatrixRequestTest.php b/tests/Services/DistanceMatrix/DistanceMatrixRequestTest.php deleted file mode 100644 index df22eb57..00000000 --- a/tests/Services/DistanceMatrix/DistanceMatrixRequestTest.php +++ /dev/null @@ -1,351 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; - -/** - * DistanceMatrix request test. - * - * @author GeLo - * @author Tyler Sommer - */ -class DistanceMatrixRequestTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest */ - protected $distanceMatrixRequest; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->distanceMatrixRequest = new DistanceMatrixRequest(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->distanceMatrixRequest); - } - - public function testDefaultState() - { - $this->assertFalse($this->distanceMatrixRequest->hasAvoidHighways()); - $this->assertFalse($this->distanceMatrixRequest->hasAvoidTolls()); - $this->assertFalse($this->distanceMatrixRequest->hasDestinations()); - $this->assertFalse($this->distanceMatrixRequest->hasOrigins()); - $this->assertFalse($this->distanceMatrixRequest->hasRegion()); - $this->assertFalse($this->distanceMatrixRequest->hasLanguage()); - $this->assertFalse($this->distanceMatrixRequest->hasTravelMode()); - $this->assertFalse($this->distanceMatrixRequest->hasUnitSystem()); - $this->assertFalse($this->distanceMatrixRequest->hasSensor()); - } - - public function testAvoidHightwaysWithValidValue() - { - $this->distanceMatrixRequest->setAvoidHighways(true); - - $this->assertTrue($this->distanceMatrixRequest->hasAvoidHighways()); - $this->assertTrue($this->distanceMatrixRequest->getAvoidHighways()); - } - - public function testAvoidHighwaysWithNullValue() - { - $this->distanceMatrixRequest->setAvoidHighways(true); - $this->distanceMatrixRequest->setAvoidHighways(null); - - $this->assertNull($this->distanceMatrixRequest->getAvoidHighways()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix request avoid hightways flag must be a boolean value. - */ - public function testAvoidHighwaysWithInvalidValue() - { - $this->distanceMatrixRequest->setAvoidHighways('foo'); - } - - public function testAvoidTollsWithValidValue() - { - $this->distanceMatrixRequest->setAvoidTolls(true); - - $this->assertTrue($this->distanceMatrixRequest->hasAvoidTolls()); - $this->assertTrue($this->distanceMatrixRequest->getAvoidTolls()); - } - - public function testAvoidTollsWithNullValue() - { - $this->distanceMatrixRequest->setAvoidTolls(true); - $this->distanceMatrixRequest->setAvoidTolls(null); - - $this->assertNull($this->distanceMatrixRequest->getAvoidTolls()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix request avoid tolls flag must be a boolean value. - */ - public function testAvoidTollsWithInvalidValue() - { - $this->distanceMatrixRequest->setAvoidTolls('foo'); - } - - public function testDestinationWithString() - { - $this->distanceMatrixRequest->setDestinations(array('foo')); - - $this->assertTrue($this->distanceMatrixRequest->hasDestinations()); - $this->assertEquals($this->distanceMatrixRequest->getDestinations(), array('foo')); - } - - public function testDestinationWithCoordinate() - { - $location = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->distanceMatrixRequest->setDestinations(array($location)); - - $destinations = $this->distanceMatrixRequest->getDestinations(); - - $this->assertArrayHasKey(0, $destinations); - $this->assertCount(1, $destinations); - $this->assertSame($location, $destinations[0]); - } - - public function testDestinationWithLatitudeAndLongitude() - { - $this->distanceMatrixRequest->addDestination(1.1, 2.1, false); - - $destinations = $this->distanceMatrixRequest->getDestinations(); - - $this->assertArrayHasKey(0, $destinations); - $this->assertCount(1, $destinations); - $this->assertSame(1.1, $destinations[0]->getLatitude()); - $this->assertSame(2.1, $destinations[0]->getLongitude()); - $this->assertFalse($destinations[0]->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The destination adder arguments are invalid. - * The available prototypes are : - * - function setDestination(string $destination) - * - function setDestination(Ivory\GoogleMap\Base\Coordinate $destination) - * - function setDestination(double $latitude, double $longitude, boolean $noWrap) - */ - public function testDestinationWithInvalidValue() - { - $this->distanceMatrixRequest->addDestination(true); - } - - public function testOriginWithString() - { - $this->distanceMatrixRequest->setOrigins(array('foo')); - - $this->assertTrue($this->distanceMatrixRequest->hasOrigins()); - $this->assertSame(array('foo'), $this->distanceMatrixRequest->getOrigins()); - } - - public function testOriginWithCoordinate() - { - $origin = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->distanceMatrixRequest->setOrigins(array($origin)); - - $origins = $this->distanceMatrixRequest->getOrigins(); - - $this->assertArrayHasKey(0, $origins); - $this->assertSame($origin, $origins[0]); - } - - public function testOriginWithLatitudeAndLongitude() - { - $this->distanceMatrixRequest->addOrigin(1.1, 2.1, false); - - $origins = $this->distanceMatrixRequest->getOrigins(); - - $this->assertArrayHasKey(0, $origins); - $this->assertCount(1, $origins); - $this->assertSame(1.1, $origins[0]->getLatitude()); - $this->assertSame(2.1, $origins[0]->getLongitude()); - $this->assertFalse($origins[0]->isNoWrap()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The origin adder arguments are invalid. - * The available prototypes are : - * - function setOrigin(string $origin) - * - function setOrigin(Ivory\GoogleMap\Base\Coordinate $origin) - * - function setOrigin(double $latitude, double $longitude, boolean $noWrap) - */ - public function testOriginWithInvalidValue() - { - $this->distanceMatrixRequest->addOrigin(true); - } - - public function testRegionWithValidValue() - { - $this->distanceMatrixRequest->setRegion('fr'); - - $this->assertTrue($this->distanceMatrixRequest->hasRegion()); - $this->assertSame('fr', $this->distanceMatrixRequest->getRegion()); - } - - public function testRegionWithNullValue() - { - $this->distanceMatrixRequest->setRegion('fr'); - $this->distanceMatrixRequest->setRegion(null); - - $this->assertNull($this->distanceMatrixRequest->getRegion()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix request region must be a string with two characters. - */ - public function testRegionWithInvalidValue() - { - $this->distanceMatrixRequest->setRegion('foo'); - } - - public function testLanguageWithValidValue() - { - $this->distanceMatrixRequest->setLanguage('fr'); - - $this->assertTrue($this->distanceMatrixRequest->hasLanguage()); - $this->assertSame('fr', $this->distanceMatrixRequest->getLanguage()); - } - - public function testLanguageWithNullValue() - { - $this->distanceMatrixRequest->setLanguage('fr'); - $this->distanceMatrixRequest->setLanguage(null); - - $this->assertNull($this->distanceMatrixRequest->getLanguage()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix request language must be a string with two or five characters. - */ - public function testLanguageWithInvalidValue() - { - $this->distanceMatrixRequest->setLanguage('foo'); - } - - public function testTravelModeWithValidValue() - { - $this->distanceMatrixRequest->setTravelMode(TravelMode::WALKING); - - $this->assertTrue($this->distanceMatrixRequest->hasTravelMode()); - $this->assertSame(TravelMode::WALKING, $this->distanceMatrixRequest->getTravelMode()); - } - - public function testTravelModeWithNullValue() - { - $this->distanceMatrixRequest->setTravelMode(TravelMode::WALKING); - $this->distanceMatrixRequest->setTravelMode(null); - - $this->assertNull($this->distanceMatrixRequest->getTravelMode()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix request travel mode can only be : BICYCLING, DRIVING, WALKING. - */ - public function testTravelModeWithTransitValue() - { - $this->distanceMatrixRequest->setTravelMode(TravelMode::TRANSIT); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix request travel mode can only be : BICYCLING, DRIVING, WALKING. - */ - public function testTravelModeWithInvalidValue() - { - $this->distanceMatrixRequest->setTravelMode('foo'); - } - - public function testUnitSystemWithValidValue() - { - $this->distanceMatrixRequest->setUnitSystem(UnitSystem::IMPERIAL); - - $this->assertTrue($this->distanceMatrixRequest->hasUnitSystem()); - $this->assertSame(UnitSystem::IMPERIAL, $this->distanceMatrixRequest->getUnitSystem()); - } - - public function testUnitSystemWithNullValue() - { - $this->distanceMatrixRequest->setUnitSystem(UnitSystem::IMPERIAL); - $this->distanceMatrixRequest->setUnitSystem(null); - - $this->assertNull($this->distanceMatrixRequest->getUnitSystem()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix request unit system can only be : IMPERIAL, METRIC. - */ - public function testUnitSystemWithInvalidValue() - { - $this->distanceMatrixRequest->setUnitSystem('foo'); - } - - public function testSensorWithValidValue() - { - $this->distanceMatrixRequest->setSensor(true); - - $this->assertTrue($this->distanceMatrixRequest->hasSensor()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix request sensor flag must be a boolean value. - */ - public function testSensorWithInvalidValue() - { - $this->distanceMatrixRequest->setSensor('foo'); - } - - public function testIsValid() - { - $this->assertFalse($this->distanceMatrixRequest->isValid()); - } - - public function testIsValidWithOrigin() - { - $this->distanceMatrixRequest->addOrigin('foo'); - - $this->assertFalse($this->distanceMatrixRequest->isValid()); - } - - public function testIsValidWithDestination() - { - $this->distanceMatrixRequest->addDestination('foo'); - - $this->assertFalse($this->distanceMatrixRequest->isValid()); - } - - public function testIsValidWithOriginAndDestination() - { - $this->distanceMatrixRequest->addDestination('foo'); - $this->distanceMatrixRequest->addOrigin('bar'); - - $this->assertTrue($this->distanceMatrixRequest->isValid()); - } -} diff --git a/tests/Services/DistanceMatrix/DistanceMatrixResponseElementTest.php b/tests/Services/DistanceMatrix/DistanceMatrixResponseElementTest.php deleted file mode 100644 index e140a5c1..00000000 --- a/tests/Services/DistanceMatrix/DistanceMatrixResponseElementTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixElementStatus; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseElement; - -/** - * Directions response row test. - * - * @author GeLo - */ -class DirectionsResponseElementTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponse */ - protected $distanceMatrixResponseElement; - - /** @var string */ - protected $status; - - /** @var \Ivory\GoogleMap\Services\Base\Distance */ - protected $distance; - - /** @var \Ivory\GoogleMap\Services\Base\Duration */ - protected $duration; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->status = DistanceMatrixElementStatus::ZERO_RESULTS; - - $this->distance = $this->getMockBuilder('Ivory\GoogleMap\Services\Base\Distance') - ->disableOriginalConstructor() - ->getMock(); - - $this->duration = $this->getMockBuilder('Ivory\GoogleMap\Services\Base\Duration') - ->disableOriginalConstructor() - ->getMock(); - - $this->distanceMatrixResponseElement = new DistanceMatrixResponseElement( - $this->status, - $this->distance, - $this->duration - ); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->status); - unset($this->distance); - unset($this->duration); - unset($this->distanceMatrixResponseElement); - } - - public function testDefaultState() - { - $this->assertSame($this->status, $this->distanceMatrixResponseElement->getStatus()); - $this->assertSame($this->distance, $this->distanceMatrixResponseElement->getDistance()); - $this->assertSame($this->duration, $this->distanceMatrixResponseElement->getDuration()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix response element status can only be : NOT_FOUND, OK, ZERO_RESULTS. - */ - public function testStatusWithInvalidValue() - { - $this->distanceMatrixResponseElement->setStatus('foo'); - } -} diff --git a/tests/Services/DistanceMatrix/DistanceMatrixResponseRowTest.php b/tests/Services/DistanceMatrix/DistanceMatrixResponseRowTest.php deleted file mode 100644 index 68e3f668..00000000 --- a/tests/Services/DistanceMatrix/DistanceMatrixResponseRowTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseRow; - -/** - * Directions response row test. - * - * @author GeLo - */ -class DirectionsResponseRowTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponse */ - protected $distanceMatrixResponseRow; - - /** @var array */ - protected $elements; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $element = $this->getMockBuilder('Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseElement') - ->disableOriginalConstructor() - ->getMock(); - - $this->elements = array($element); - - $this->distanceMatrixResponseRow = new DistanceMatrixResponseRow($this->elements); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->elements); - unset($this->distanceMatrixResponseRow); - } - - public function testDefaultState() - { - $this->assertSame($this->elements, $this->distanceMatrixResponseRow->getElements()); - } -} diff --git a/tests/Services/DistanceMatrix/DistanceMatrixResponseTest.php b/tests/Services/DistanceMatrix/DistanceMatrixResponseTest.php deleted file mode 100644 index ecdb79b4..00000000 --- a/tests/Services/DistanceMatrix/DistanceMatrixResponseTest.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponse; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixStatus; - -/** - * Directions response test. - * - * @author GeLo - */ -class DirectionsResponseTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponse */ - protected $distanceMatrixResponse; - - /** @var string */ - protected $status; - - /** @var array */ - protected $origins; - - /** @var array */ - protected $destinations; - - /** @var array */ - protected $rows; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $row = $this->getMockBuilder('Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseRow') - ->disableOriginalConstructor() - ->getMock(); - - $this->status = DistanceMatrixStatus::REQUEST_DENIED; - $this->origins = array('foo'); - $this->destinations = array('bar'); - $this->rows = array($row); - - $this->distanceMatrixResponse = new DistanceMatrixResponse( - $this->status, - $this->origins, - $this->destinations, - $this->rows - ); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->status); - unset($this->origins); - unset($this->destinations); - unset($this->rows); - unset($this->distanceMatrixResponse); - } - - public function testDefaultState() - { - $this->assertSame($this->status, $this->distanceMatrixResponse->getStatus()); - $this->assertSame($this->origins, $this->distanceMatrixResponse->getOrigins()); - $this->assertSame($this->destinations, $this->distanceMatrixResponse->getDestinations()); - $this->assertSame($this->rows, $this->distanceMatrixResponse->getRows()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The distance matrix response status can only be : INVALID_REQUEST, - * MAX_DIMENSIONS_EXCEEDED, MAX_ELEMENTS_EXCEEDED, OK, OVER_QUERY_LIMIT, REQUEST_DENIED, UNKNOWN_ERROR. - */ - public function testStatusWithInvalidValue() - { - $this->distanceMatrixResponse->setStatus('foo'); - } -} diff --git a/tests/Services/DistanceMatrix/DistanceMatrixStatusTest.php b/tests/Services/DistanceMatrix/DistanceMatrixStatusTest.php deleted file mode 100644 index 91d24cf0..00000000 --- a/tests/Services/DistanceMatrix/DistanceMatrixStatusTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixStatus; - -/** - * Distance matrix status test. - * - * @author GeLo - */ -class DirectionsMatrixStatusTest extends \PHPUnit_Framework_TestCase -{ - public function testDistanceMatrixStatus() - { - $expected = array( - DistanceMatrixStatus::INVALID_REQUEST, - DistanceMatrixStatus::MAX_DIMENSIONS_EXCEEDED, - DistanceMatrixStatus::MAX_ELEMENTS_EXCEEDED, - DistanceMatrixStatus::OK, - DistanceMatrixStatus::OVER_QUERY_LIMIT, - DistanceMatrixStatus::REQUEST_DENIED, - DistanceMatrixStatus::UNKNOWN_ERROR, - ); - - $this->assertSame($expected, DistanceMatrixStatus::getDistanceMatrixStatus()); - } -} diff --git a/tests/Services/DistanceMatrix/DistanceMatrixTest.php b/tests/Services/DistanceMatrix/DistanceMatrixTest.php deleted file mode 100644 index eb58ce7c..00000000 --- a/tests/Services/DistanceMatrix/DistanceMatrixTest.php +++ /dev/null @@ -1,256 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\DistanceMatrix; - -use Ivory\GoogleMap\Base\Coordinate; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixElementStatus; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixStatus; -use Ivory\GoogleMap\Services\Base\TravelMode; -use Ivory\GoogleMap\Services\Base\UnitSystem; -use Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrix; -use Widop\HttpAdapter\CurlHttpAdapter; - -/** - * Distance matrix test. - * - * @author GeLo - */ -class DistanceMatrixTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrix */ - protected $service; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->service = new DistanceMatrix(new CurlHttpAdapter()); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->service); - } - - public function testProcessWithOriginAndDestinationStrings() - { - $response = $this->service->process(array('Vancouver BC'), array('San Francisco')); - - $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); - $this->assertCount(1, $response->getOrigins()); - $this->assertCount(1, $response->getDestinations()); - - $rows = $response->getRows(); - $this->assertCount(1, $rows); - - $elements = $rows[0]->getElements(); - $this->assertCount(1, $elements); - $this->assertSame(DistanceMatrixElementStatus::OK, $elements[0]->getStatus()); - } - - public function testProcessWithOriginAndDestinationCoordinates() - { - $vancouver = new Coordinate(49.262428, -123.113136); - $sanFrancisco = new Coordinate(37.775328, -122.418938); - - $response = $this->service->process(array($vancouver), array($sanFrancisco)); - - $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); - $this->assertCount(1, $response->getOrigins()); - $this->assertCount(1, $response->getDestinations()); - - $rows = $response->getRows(); - $this->assertCount(1, $rows); - - $elements = $rows[0]->getElements(); - $this->assertCount(1, $elements); - $this->assertSame(DistanceMatrixElementStatus::OK, $elements[0]->getStatus()); - } - - public function testProcessWithMinimalDistanceMatrixRequest() - { - $request = new DistanceMatrixRequest(); - $request->addOrigin('Vancouver BC'); - $request->addDestination('San Francisco'); - - $response = $this->service->process($request); - $this->assertCount(1, $response->getOrigins()); - $this->assertCount(1, $response->getDestinations()); - - $rows = $response->getRows(); - $this->assertCount(1, $rows); - - $elements = $rows[0]->getElements(); - $this->assertCount(1, $elements); - $this->assertSame(DistanceMatrixElementStatus::OK, $elements[0]->getStatus()); - } - - public function testProcessWithDistanceMatrixRequest() - { - $request = new DistanceMatrixRequest(); - $request->addOrigin('Vancouver BC'); - $request->addDestination('San Francisco'); - $request->setTravelMode(TravelMode::BICYCLING); - $request->setUnitSystem(UnitSystem::METRIC); - $request->setRegion('en'); - $request->setLanguage('fr'); - - $response = $this->service->process($request); - $this->assertCount(1, $response->getOrigins()); - $this->assertCount(1, $response->getDestinations()); - - $rows = $response->getRows(); - $this->assertCount(1, $rows); - - $elements = $rows[0]->getElements(); - $this->assertCount(1, $elements); - $this->assertSame(DistanceMatrixElementStatus::OK, $elements[0]->getStatus()); - } - - public function testProcessWithDistanceMatrixRequestAndAvoidTolls() - { - $request = new DistanceMatrixRequest(); - $request->addOrigin('Vancouver BC'); - $request->addDestination('San Francisco'); - $request->setAvoidTolls(true); - - $response = $this->service->process($request); - $this->assertCount(1, $response->getOrigins()); - $this->assertCount(1, $response->getDestinations()); - - $rows = $response->getRows(); - $this->assertCount(1, $rows); - - $elements = $rows[0]->getElements(); - $this->assertCount(1, $elements); - $this->assertSame(DistanceMatrixElementStatus::OK, $elements[0]->getStatus()); - } - - public function testProcessWithDistanceMatrixRequestAndAvoidHighways() - { - $request = new DistanceMatrixRequest(); - $request->addOrigin('Vancouver BC'); - $request->addDestination('San Francisco'); - $request->setAvoidHighways(true); - - $response = $this->service->process($request); - $this->assertCount(1, $response->getOrigins()); - $this->assertCount(1, $response->getDestinations()); - - $rows = $response->getRows(); - $this->assertCount(1, $rows); - - $elements = $rows[0]->getElements(); - $this->assertCount(1, $elements); - $this->assertSame(DistanceMatrixElementStatus::OK, $elements[0]->getStatus()); - } - - public function testProcessWithXmlFormat() - { - $this->service->setFormat('xml'); - $response = $this->service->process(array('Vancouver BC'), array('San Francisco')); - - $this->assertSame(DistanceMatrixStatus::OK, $response->getStatus()); - $this->assertCount(1, $response->getOrigins()); - $this->assertCount(1, $response->getDestinations()); - - $rows = $response->getRows(); - $this->assertCount(1, $rows); - - $elements = $rows[0]->getElements(); - $this->assertCount(1, $elements); - $this->assertSame(DistanceMatrixElementStatus::OK, $elements[0]->getStatus()); - } - - public function testSignUrlWithoutBusinessAccount() - { - $method = new \ReflectionMethod($this->service, 'signUrl'); - $method->setAccessible(true); - - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - - $this->assertSame($url, $method->invoke($this->service, $url)); - } - - public function testSignUrlWithBusinessAccount() - { - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - - $businessAccount = $this->getMockBuilder('Ivory\GoogleMap\Services\BusinessAccount') - ->disableOriginalConstructor() - ->getMock(); - - $businessAccount - ->expects($this->once()) - ->method('signUrl') - ->with($this->equalTo($url)) - ->will($this->returnValue('url')); - - $this->service->setBusinessAccount($businessAccount); - - $method = new \ReflectionMethod($this->service, 'signUrl'); - $method->setAccessible(true); - - $this->assertSame('url', $method->invoke($this->service, $url)); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The process arguments are invalid. - * The available prototypes are: - * - function route(array $origins, array $destinations) - * - function route(Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixRequest $request) - */ - public function testProcessWithInvalidRequestParameters() - { - $this->service->process(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\DistanceMatrixException - * @expectedExceptionMessage The directions request is not valid. It needs at least one origin and one destination. - */ - public function testProcessWithInvalidRequest() - { - $this->service->process(new DistanceMatrixRequest()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage The service result is not valid. - */ - public function testProcessWithInvalidResult() - { - $httpAdapterMock = $this->getMock('Widop\HttpAdapter\HttpAdapterInterface'); - $httpAdapterMock - ->expects($this->once()) - ->method('getContent') - ->will($this->returnValue(null)); - - $this->service = new DistanceMatrix($httpAdapterMock); - $this->service->process(array('Vancouver BC'), array('San Francisco')); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\ServiceException - * @expectedExceptionMessage An error occured while fetching - */ - public function testProcessThrowsInvalidResponse() - { - $this->service->process(array('Vancouver BC'.str_repeat('a', 2000)), array('San Francisco')); - } -} diff --git a/tests/Services/Geocoding/GeocoderProviderTest.php b/tests/Services/Geocoding/GeocoderProviderTest.php deleted file mode 100644 index f4990ad7..00000000 --- a/tests/Services/Geocoding/GeocoderProviderTest.php +++ /dev/null @@ -1,275 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding; - -use Geocoder\HttpAdapter\CurlHttpAdapter; -use Ivory\GoogleMap\Services\Geocoding\GeocoderProvider; -use Ivory\GoogleMap\Services\Geocoding\GeocoderRequest; -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderStatus; - -/** - * Geocoder provider test. - * - * @author GeLo - */ -class GeocoderProviderTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Geocoding\GeocoderProvider */ - protected $geocoderProvider; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->geocoderProvider = new GeocoderProvider(new CurlHttpAdapter()); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->geocoderProvider); - } - - public function testInitialState() - { - $this->assertSame('http://maps.googleapis.com/maps/api/geocode', $this->geocoderProvider->getUrl()); - $this->assertFalse($this->geocoderProvider->isHttps()); - $this->assertSame('json', $this->geocoderProvider->getFormat()); - $this->assertInstanceOf('Ivory\GoogleMap\Services\Utils\XmlParser', $this->geocoderProvider->getXmlParser()); - $this->assertFalse($this->geocoderProvider->hasBusinessAccount()); - $this->assertNull($this->geocoderProvider->getBusinessAccount()); - } - - public function testUrlWithValieValue() - { - $this->geocoderProvider->setUrl('http://foo'); - - $this->assertSame('http://foo', $this->geocoderProvider->getUrl()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder provider url must be a string value. - */ - public function testUrlWithInvalidValue() - { - $this->geocoderProvider->setUrl(true); - } - - public function testHttpsWithValidValue() - { - $this->geocoderProvider->setHttps(true); - - $this->assertTrue($this->geocoderProvider->isHttps()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder provider https flag must be a boolean value. - */ - public function testHttpsWithInvalidValue() - { - $this->geocoderProvider->setHttps('foo'); - } - - public function testUrlWithHttps() - { - $this->geocoderProvider->setUrl('http://foo'); - $this->geocoderProvider->setHttps(true); - - $this->assertSame('https://foo', $this->geocoderProvider->getUrl()); - } - - public function testFormatWithJsonValue() - { - $this->geocoderProvider->setFormat('json'); - - $this->assertSame('json', $this->geocoderProvider->getFormat()); - } - - public function testFormatWithXmlFormat() - { - $this->geocoderProvider->setFormat('xml'); - - $this->assertSame('xml', $this->geocoderProvider->getFormat()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder provider format can only be : json, xml. - */ - public function testFormatWithInvalidValue() - { - $this->geocoderProvider->setFormat('foo'); - } - - public function testXmlParser() - { - $xmlParser = $this->getMock('Ivory\GoogleMap\Services\Utils\XmlParser'); - $this->geocoderProvider->setXmlParser($xmlParser); - - $this->assertSame($xmlParser, $this->geocoderProvider->getXmlParser()); - } - - public function testBusinessAccount() - { - $businessAccount = $this->getMockBuilder('Ivory\GoogleMap\Services\BusinessAccount') - ->disableOriginalConstructor() - ->getMock(); - - $this->geocoderProvider->setBusinessAccount($businessAccount); - - $this->assertTrue($this->geocoderProvider->hasBusinessAccount()); - $this->assertSame($businessAccount, $this->geocoderProvider->getBusinessAccount()); - - $this->geocoderProvider->setBusinessAccount(); - - $this->assertFalse($this->geocoderProvider->hasBusinessAccount()); - $this->assertNull($this->geocoderProvider->getBusinessAccount()); - } - - public function testGeocodedDataWithAddress() - { - $response = $this->geocoderProvider->getGeocodedData('Paris'); - - $this->assertInstanceOf('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse', $response); - - $this->assertNotEmpty($response->getResults()); - $this->assertSame(GeocoderStatus::OK, $response->getStatus()); - } - - public function testGeocdedDataWithIp() - { - $response = $this->geocoderProvider->getGeocodedData('111.111.111.111'); - - $this->assertInstanceOf('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse', $response); - - $this->assertNotEmpty($response->getResults()); - $this->assertSame(GeocoderStatus::OK, $response->getStatus()); - } - - public function testGeocodedDataWithGeocoderRequest() - { - $request = new GeocoderRequest(); - $request->setAddress('Paris'); - $request->setBound(48.815573, 2.224199, 48.9021449, 2.4699208); - $request->setRegion('FR'); - $request->setLanguage('PL'); - - $response = $this->geocoderProvider->getGeocodedData($request); - - $this->assertInstanceOf('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse', $response); - - $this->assertNotEmpty($response->getResults()); - $this->assertSame(GeocoderStatus::OK, $response->getStatus()); - } - - public function testGeocodedDataWithXmlFormat() - { - $this->geocoderProvider->setFormat('xml'); - $response = $this->geocoderProvider->getGeocodedData('Paris'); - - $this->assertInstanceOf('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse', $response); - - $this->assertNotEmpty($response->getResults()); - $this->assertSame(GeocoderStatus::OK, $response->getStatus()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geolocate argument is invalid. - * The available prototypes are : - * - function geocode(string $address) - * - function geocode(Ivory\GoogleMap\Services\Geocoding\GeocoderRequest $request) - */ - public function testGeocodedDataWithInvalidValue() - { - $this->geocoderProvider->getGeocodedData(true); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder request is not valid. It needs at least an address or a coordinate. - */ - public function testGeocodedDataWithInvalidGeocoderRequest() - { - $request = new GeocoderRequest(); - - $this->geocoderProvider->getGeocodedData($request); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The service result is not valid. - */ - public function testGeocodedDataWithInvalidResult() - { - $httpAdapterMock = $this->getMock('Geocoder\HttpAdapter\HttpAdapterInterface'); - $httpAdapterMock - ->expects($this->once()) - ->method('getContent') - ->will($this->returnValue(null)); - - $this->geocoderProvider = new GeocoderProvider($httpAdapterMock); - $this->geocoderProvider->getGeocodedData('Paris'); - } - - public function testReversedData() - { - $response = $this->geocoderProvider->getReversedData(array(48.856633, 2.352254)); - - $this->assertInstanceOf('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse', $response); - - $this->assertNotEmpty($response->getResults()); - $this->assertSame(GeocoderStatus::OK, $response->getStatus()); - } - - public function testSignUrlWithoutBusinessAccount() - { - $method = new \ReflectionMethod($this->geocoderProvider, 'signUrl'); - $method->setAccessible(true); - - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - - $this->assertSame($url, $method->invoke($this->geocoderProvider, $url)); - } - - public function testSignUrlWithBusinessAccount() - { - $url = 'http://maps.googleapis.com/maps/api/staticmap?center=%E4%B8%8A%E6%B5%B7+%E4%B8%AD%E5%9C%8B&size=640x640&zoom=10&sensor=false'; - - $businessAccount = $this->getMockBuilder('Ivory\GoogleMap\Services\BusinessAccount') - ->disableOriginalConstructor() - ->getMock(); - - $businessAccount - ->expects($this->once()) - ->method('signUrl') - ->with($this->equalTo($url)) - ->will($this->returnValue('url')); - - $this->geocoderProvider->setBusinessAccount($businessAccount); - - $method = new \ReflectionMethod($this->geocoderProvider, 'signUrl'); - $method->setAccessible(true); - - $this->assertSame('url', $method->invoke($this->geocoderProvider, $url)); - } - - public function testName() - { - $this->assertSame('ivory_google_map', $this->geocoderProvider->getName()); - } -} diff --git a/tests/Services/Geocoding/GeocoderRequestTest.php b/tests/Services/Geocoding/GeocoderRequestTest.php deleted file mode 100644 index c80a4547..00000000 --- a/tests/Services/Geocoding/GeocoderRequestTest.php +++ /dev/null @@ -1,261 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding; - -use Ivory\GoogleMap\Services\Geocoding\GeocoderRequest; - -/** - * Geocoder request test. - * - * @author GeLo - */ -class GeocoderRequestTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Geocoding\GeocoderRequest */ - protected $geocoderRequest; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->geocoderRequest = new GeocoderRequest(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->geocoderRequest); - } - - public function testDefaultState() - { - $this->assertFalse($this->geocoderRequest->hasAddress()); - $this->assertFalse($this->geocoderRequest->hasCoordinate()); - $this->assertFalse($this->geocoderRequest->hasBound()); - $this->assertFalse($this->geocoderRequest->hasRegion()); - $this->assertFalse($this->geocoderRequest->hasLanguage()); - $this->assertFalse($this->geocoderRequest->hasSensor()); - } - - public function testAddressWithValidValue() - { - $this->geocoderRequest->setAddress('foo'); - - $this->assertTrue($this->geocoderRequest->hasAddress()); - $this->assertSame('foo', $this->geocoderRequest->getAddress()); - } - - public function testAddressWithNullValue() - { - $this->geocoderRequest->setAddress('foo'); - $this->geocoderRequest->setAddress(null); - - $this->assertNull($this->geocoderRequest->getAddress()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder request address must be a string value. - */ - public function testAddressWithInvalidValue() - { - $this->geocoderRequest->setAddress(true); - } - - public function testCoordinateWithCoordinate() - { - $coordinate = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->geocoderRequest->setCoordinate($coordinate); - - $this->assertTrue($this->geocoderRequest->hasCoordinate()); - $this->assertSame($coordinate, $this->geocoderRequest->getCoordinate()); - } - - public function testCoordinateWithLatitudeAndLongitude() - { - $this->geocoderRequest->setCoordinate(1.1, -2.1, false); - - $this->assertSame(1.1, $this->geocoderRequest->getCoordinate()->getLatitude()); - $this->assertSame(-2.1, $this->geocoderRequest->getCoordinate()->getLongitude()); - $this->assertFalse($this->geocoderRequest->getCoordinate()->isNoWrap()); - } - - public function testCoordinateWithNullValue() - { - $this->geocoderRequest->setCoordinate(1.1, -2.1); - $this->geocoderRequest->setCoordinate(null); - - $this->assertNull($this->geocoderRequest->getCoordinate()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The coordinate setter arguments is invalid. - * The available prototypes are : - * - function setCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate = null) - * - function setCoordinate(double $latitude, double $longitude, boolean $noWrap = true) - */ - public function testCoordinateWithInvalidValue() - { - $this->geocoderRequest->setCoordinate('foo'); - } - - public function testBoundWithBound() - { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $this->geocoderRequest->setBound($bound); - - $this->assertTrue($this->geocoderRequest->hasBound()); - $this->assertSame($bound, $this->geocoderRequest->getBound()); - } - - public function testBoundWithCoordinates() - { - $southWest = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $northEast = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - - $this->geocoderRequest->setBound($southWest, $northEast); - - $this->assertSame($southWest, $this->geocoderRequest->getBound()->getSouthWest()); - $this->assertSame($northEast, $this->geocoderRequest->getBound()->getNorthEast()); - } - - public function testBoundWithLatitudesAndLongitudes() - { - $this->geocoderRequest->setBound(-2, -2, 2, 2, true, false); - - $this->assertSame(-2, $this->geocoderRequest->getBound()->getSouthWest()->getLatitude()); - $this->assertSame(-2, $this->geocoderRequest->getBound()->getSouthWest()->getLongitude()); - $this->assertTrue($this->geocoderRequest->getBound()->getSouthWest()->isNoWrap()); - - $this->assertSame(2, $this->geocoderRequest->getBound()->getNorthEast()->getLatitude()); - $this->assertSame(2, $this->geocoderRequest->getBound()->getNorthEast()->getLongitude()); - $this->assertFalse($this->geocoderRequest->getBound()->getNorthEast()->isNoWrap()); - } - - public function testBoundWithNullValue() - { - $this->geocoderRequest->setBound(-2, -2, 2, 2); - $this->geocoderRequest->setBound(null); - - $this->assertNull($this->geocoderRequest->getBound()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The bound setter arguments are invalid. - * The available prototypes are : - * - function setBound(Ivory\GoogleMap\Base\Bound $bound = null) - * - function setBound(Ivory\GoogleMap\Base\Coordinate $southWest, Ivory\GoogleMap\Base\Coordinate $northEast) - * - function setBound( - * double $southWestLatitude, - * double $southWestLongitude, - * double $northEastLatitude, - * double $northEastLongitude, - * boolean southWestNoWrap = true, - * boolean $northEastNoWrap = true - * ) - */ - public function testBoundWithInvalidValue() - { - $this->geocoderRequest->setBound('foo'); - } - - public function testRegionWithValidValue() - { - $this->geocoderRequest->setRegion('fr'); - - $this->assertTrue($this->geocoderRequest->hasRegion()); - $this->assertSame('fr', $this->geocoderRequest->getRegion()); - } - - public function testRegionWithNullValue() - { - $this->geocoderRequest->setRegion('fr'); - $this->geocoderRequest->setRegion(null); - - $this->assertNull($this->geocoderRequest->getRegion()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder request region must be a string with two characters. - */ - public function testRegionWithInvalidValue() - { - $this->geocoderRequest->setRegion('foo'); - } - - public function testLanguageWithValidValue() - { - $this->geocoderRequest->setLanguage('pl'); - - $this->assertTrue($this->geocoderRequest->hasLanguage()); - $this->assertSame('pl', $this->geocoderRequest->getLanguage()); - } - - public function testLanguageWithNullValue() - { - $this->geocoderRequest->setLanguage('pl'); - $this->geocoderRequest->setLanguage(null); - - $this->assertNull($this->geocoderRequest->getLanguage()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder request language must be a string with two or five characters. - */ - public function testLanguageWithInvalidValue() - { - $this->geocoderRequest->setLanguage('foo'); - } - - public function testSensorWithValidValue() - { - $this->geocoderRequest->setSensor(true); - - $this->assertTrue($this->geocoderRequest->hasSensor()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder request sensor flag must be a boolean value. - */ - public function testSensorWithInvalidValue() - { - $this->geocoderRequest->setSensor('foo'); - } - - public function testIsValidWithoutAddressAndCoordinate() - { - $this->assertFalse($this->geocoderRequest->isValid()); - } - - public function testIsValidWithAddress() - { - $this->geocoderRequest->setAddress('address'); - - $this->assertTrue($this->geocoderRequest->isValid()); - } - - public function testIsValidWithCoordinate() - { - $this->geocoderRequest->setCoordinate(1, 1); - - $this->assertTrue($this->geocoderRequest->isValid()); - } -} diff --git a/tests/Services/Geocoding/GeocoderTest.php b/tests/Services/Geocoding/GeocoderTest.php deleted file mode 100644 index 34122b1c..00000000 --- a/tests/Services/Geocoding/GeocoderTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding; - -use Geocoder\HttpAdapter\CurlHttpAdapter; -use Geocoder\Provider\GoogleMapsProvider; -use Ivory\GoogleMap\Services\Geocoding\Geocoder; -use Ivory\GoogleMap\Services\Geocoding\GeocoderProvider; - -/** - * Geocoder test. - * - * @author GeLo - */ -class GeocoderTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Geocoding\Geocoder */ - protected $geocoder; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->geocoder = new Geocoder(); - } - - /** - * Set up a geocoder provider. - */ - protected function setUpGeocoderProvider() - { - $this->geocoder->registerProvider(new GoogleMapsProvider(new CurlHttpAdapter())); - } - - /** - * Set up the Ivory provider. - */ - protected function setUpIvoryProvider() - { - $this->geocoder->registerProvider(new GeocoderProvider(new CurlHttpAdapter())); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->geocoder); - } - - public function testGeocodeWithGeocoderProvider() - { - $this->setUpGeocoderProvider(); - - $this->assertInstanceOf('Geocoder\Result\Geocoded', $this->geocoder->geocode('Paris')); - } - - public function testGeocodeWithIvoryProvider() - { - $this->setUpIvoryProvider(); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse', - $this->geocoder->geocode('Paris') - ); - } - - public function testReverseWithGeocoderProvider() - { - $this->setUpGeocoderProvider(); - - $this->assertInstanceOf('Geocoder\Result\Geocoded', $this->geocoder->reverse(48.856633, 2.352254)); - } - - public function testReverseWithIvoryProvider() - { - $this->setUpIvoryProvider(); - - $this->assertInstanceOf( - 'Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse', - $this->geocoder->reverse(48.856633, 2.352254) - ); - } -} diff --git a/tests/Services/Geocoding/Result/GeocoderAddressComponentTest.php b/tests/Services/Geocoding/Result/GeocoderAddressComponentTest.php deleted file mode 100644 index 057eac30..00000000 --- a/tests/Services/Geocoding/Result/GeocoderAddressComponentTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderAddressComponent; - -/** - * Geocoder address component test. - * - * @author GeLo - */ -class GeocoderAddressComponentTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderAddressComponent */ - protected $geocoderAddressComponent; - - /** @var string */ - protected $longName; - - /** @var string */ - protected $shortName; - - /** @var array */ - protected $types; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->longName = 'long_name'; - $this->shortName = 'short_name'; - $this->types = array('foo', 'bar'); - - $this->geocoderAddressComponent = new GeocoderAddressComponent( - $this->longName, - $this->shortName, - $this->types - ); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->geocoderAddressComponent); - unset($this->longName); - unset($this->shortName); - unset($this->types); - } - - public function testInitialState() - { - $this->assertSame($this->longName, $this->geocoderAddressComponent->getLongName()); - $this->assertSame($this->shortName, $this->geocoderAddressComponent->getShortName()); - $this->assertSame($this->types, $this->geocoderAddressComponent->getTypes()); - } - - public function testLongNameWithValidValue() - { - $this->geocoderAddressComponent->setLongName('longname'); - - $this->assertSame('longname', $this->geocoderAddressComponent->getLongName()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder address component long name must be a string value. - */ - public function testLongNameWithInvalidValue() - { - $this->geocoderAddressComponent->setLongName(true); - } - - public function testShortNameWithValidValue() - { - $this->geocoderAddressComponent->setShortName('shortname'); - - $this->assertSame('shortname', $this->geocoderAddressComponent->getShortName()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder address component short name must be a string value. - */ - public function testShortNameWithInvalidValue() - { - $this->geocoderAddressComponent->setShortName(true); - } - - public function testTypesWithValidValue() - { - $types = array('type1', 'type2'); - $this->geocoderAddressComponent->setTypes($types); - - $this->assertSame($types, $this->geocoderAddressComponent->getTypes()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder address component type must be a string value. - */ - public function testTypesWithInvalidValue() - { - $this->geocoderAddressComponent->addType(true); - } -} diff --git a/tests/Services/Geocoding/Result/GeocoderGeometryTest.php b/tests/Services/Geocoding/Result/GeocoderGeometryTest.php deleted file mode 100644 index 3995a3ad..00000000 --- a/tests/Services/Geocoding/Result/GeocoderGeometryTest.php +++ /dev/null @@ -1,114 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderLocationType; -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry; - -/** - * Geocoder geometry test. - * - * @author GeLo - */ -class GeocoderGeometryTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry */ - protected $geocoderGeometry; - - /** @var \Ivory\GoogleMap\Base\Coordinate */ - protected $location; - - /** @var string */ - protected $locationType; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $viewport; - - /** @var \Ivory\GoogleMap\Base\Bound */ - protected $bound; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->location = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->locationType = GeocoderLocationType::RANGE_INTERPOLATED; - $this->viewport = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $this->bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - - $this->geocoderGeometry = new GeocoderGeometry( - $this->location, - $this->locationType, - $this->viewport, - $this->bound - ); - } - - protected function tearDown() - { - unset($this->geocoderGeometry); - unset($this->location); - unset($this->locationType); - unset($this->viewport); - unset($this->bound); - } - - public function testInitialState() - { - $this->assertSame($this->location, $this->geocoderGeometry->getLocation()); - $this->assertSame($this->locationType, $this->geocoderGeometry->getLocationType()); - $this->assertSame($this->viewport, $this->geocoderGeometry->getViewport()); - $this->assertSame($this->bound, $this->geocoderGeometry->getBound()); - } - - public function testLocation() - { - $location = $this->getMock('Ivory\GoogleMap\Base\Coordinate'); - $this->geocoderGeometry->setLocation($location); - - $this->assertSame($location, $this->geocoderGeometry->getLocation()); - } - - public function testLocationTypeWithValidValue() - { - $this->geocoderGeometry->setLocationType(GeocoderLocationType::GEOMETRIC_CENTER); - - $this->assertSame(GeocoderLocationType::GEOMETRIC_CENTER, $this->geocoderGeometry->getLocationType()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder geometry location type can only be : APPROXIMATE, GEOMETRIC_CENTER, - * RANGE_INTERPOLATED, ROOFTOP. - */ - public function testLocationTypeWithInvalidValue() - { - $this->geocoderGeometry->setLocationType('foo'); - } - - public function testViewport() - { - $viewport = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $this->geocoderGeometry->setViewport($viewport); - - $this->assertSame($viewport, $this->geocoderGeometry->getViewport()); - } - - public function testBound() - { - $bound = $this->getMock('Ivory\GoogleMap\Base\Bound'); - $this->geocoderGeometry->setBound($bound); - - $this->assertSame($bound, $this->geocoderGeometry->getBound()); - } -} diff --git a/tests/Services/Geocoding/Result/GeocoderLocationTypeTest.php b/tests/Services/Geocoding/Result/GeocoderLocationTypeTest.php deleted file mode 100644 index 8f4c8f68..00000000 --- a/tests/Services/Geocoding/Result/GeocoderLocationTypeTest.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderLocationType; - -/** - * Geocoder location type test. - * - * @author GeLo - */ -class GeocoderLocationTypeTest extends \PHPUnit_Framework_TestCase -{ - public function testGeocoderLocationtypes() - { - $expected = array( - GeocoderLocationType::APPROXIMATE, - GeocoderLocationType::GEOMETRIC_CENTER, - GeocoderLocationType::RANGE_INTERPOLATED, - GeocoderLocationType::ROOFTOP, - ); - - $this->assertSame($expected, GeocoderLocationType::getGeocoderLocationTypes()); - } -} diff --git a/tests/Services/Geocoding/Result/GeocoderResponseTest.php b/tests/Services/Geocoding/Result/GeocoderResponseTest.php deleted file mode 100644 index 0af94168..00000000 --- a/tests/Services/Geocoding/Result/GeocoderResponseTest.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse; -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderStatus; - -/** - * Geocoder response test. - * - * @author GeLo - */ -class GeocoderResponseTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResponse */ - protected $geocoderResponse; - - /** @var array */ - protected $results; - - /** @var string */ - protected $status; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $geocoderResult = $this->getMockBuilder('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResult') - ->disableOriginalConstructor() - ->getMock(); - - $this->results = array($geocoderResult); - $this->status = GeocoderStatus::REQUEST_DENIED; - - $this->geocoderResponse = new GeocoderResponse($this->results, $this->status); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->geocoderResponse); - unset($this->results); - unset($this->status); - } - - public function testInitialState() - { - $this->assertSame($this->results, $this->geocoderResponse->getResults()); - $this->assertSame($this->status, $this->geocoderResponse->getStatus()); - } - - public function testResults() - { - $geocoderResult = $this->getMockBuilder('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResult') - ->disableOriginalConstructor() - ->getMock(); - - $results = array($geocoderResult); - - $this->geocoderResponse->setResults($results); - - $this->assertSame($results, $this->geocoderResponse->getResults()); - } - - public function testStatusWithValidValue() - { - $this->geocoderResponse->setStatus(GeocoderStatus::ERROR); - - $this->assertSame(GeocoderStatus::ERROR, $this->geocoderResponse->getStatus()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder response status can only be : ERROR, INVALID_REQUEST, OK, - * OVER_QUERY_LIMIT, REQUEST_DENIED, UNKNOWN_ERROR, ZERO_RESULTS. - */ - public function testStatusWithInvalidValue() - { - $this->geocoderResponse->setStatus('foo'); - } -} diff --git a/tests/Services/Geocoding/Result/GeocoderResultTest.php b/tests/Services/Geocoding/Result/GeocoderResultTest.php deleted file mode 100644 index ef3945e8..00000000 --- a/tests/Services/Geocoding/Result/GeocoderResultTest.php +++ /dev/null @@ -1,181 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResult; - -/** - * Geocoder result test. - * - * @author GeLo - */ -class GeocoderResultTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderResult */ - protected $geocoderResult; - - /** @var array */ - protected $addressComponents; - - /** @var string */ - protected $formattedAddress; - - /** @var \Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry */ - protected $geometry; - - /** @var boolean */ - protected $partialMatch; - - /** @var array */ - protected $types; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $addressComponent = $this->getMockBuilder('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderAddressComponent') - ->disableOriginalConstructor() - ->getMock(); - - $this->addressComponents = array($addressComponent); - $this->formattedAddress = 'formattedAddress'; - - $this->geometry = $this->getMockBuilder('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry') - ->disableOriginalConstructor() - ->getMock(); - - $this->partialMatch = true; - $this->types = array('foo', 'bar'); - - $this->geocoderResult = new GeocoderResult( - $this->addressComponents, - $this->formattedAddress, - $this->geometry, - $this->types, - $this->partialMatch - ); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->geocoderResult); - unset($this->addressComponents); - unset($this->geometry); - unset($this->types); - unset($this->partialMatch); - } - - public function testInitialState() - { - $this->assertSame($this->addressComponents, $this->geocoderResult->getAddressComponents()); - $this->assertSame($this->formattedAddress, $this->geocoderResult->getFormattedAddress()); - $this->assertSame($this->geometry, $this->geocoderResult->getGeometry()); - $this->assertSame($this->types, $this->geocoderResult->getTypes()); - $this->assertSame($this->partialMatch, $this->geocoderResult->isPartialMatch()); - } - - public function testAddressComponentsWithoutType() - { - $addressComponent = $this->getMockBuilder('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderAddressComponent') - ->disableOriginalConstructor() - ->getMock(); - - $addressComponents = array($addressComponent); - - $this->geocoderResult->setAddressComponents($addressComponents); - - $this->assertSame($addressComponents, $this->geocoderResult->getAddressComponents()); - } - - public function testAddressComponentsWithType() - { - $addressComponent = $this->getMockBuilder('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderAddressComponent') - ->disableOriginalConstructor() - ->getMock(); - - $addressComponent - ->expects($this->any()) - ->method('getTypes') - ->will($this->returnValue(array('foo'))); - - $addressComponents = array($addressComponent); - - $this->geocoderResult->setAddressComponents($addressComponents); - - $this->assertSame($addressComponents, $this->geocoderResult->getAddressComponents('foo')); - $this->assertEmpty($this->geocoderResult->getAddressComponents('bar')); - } - - public function testFormattedAddressWithValidValue() - { - $this->geocoderResult->setFormattedAddress('formatted_address'); - - $this->assertSame('formatted_address', $this->geocoderResult->getFormattedAddress()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder result formatted address must be a string value. - */ - public function testFormattedAddressWithInvalidValue() - { - $this->geocoderResult->setFormattedAddress(true); - } - - public function testGeometry() - { - $geometry = $this->getMockBuilder('Ivory\GoogleMap\Services\Geocoding\Result\GeocoderGeometry') - ->disableOriginalConstructor() - ->getMock(); - - $this->geocoderResult->setGeometry($geometry); - - $this->assertSame($geometry, $this->geocoderResult->getGeometry()); - } - - public function testPartialMatchWithValidValue() - { - $this->geocoderResult->setPartialMatch(false); - - $this->assertFalse($this->geocoderResult->isPartialMatch()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder result partial match flag must be a boolean value. - */ - public function testPartialMatchWithInvalidValue() - { - $this->geocoderResult->setPartialMatch('foo'); - } - - public function testTypeWithValidValue() - { - $types = array('type_1', 'type_2'); - $this->geocoderResult->setTypes($types); - - $this->assertSame($types, $this->geocoderResult->getTypes()); - } - - /** - * @expectedException \Ivory\GoogleMap\Exception\GeocodingException - * @expectedExceptionMessage The geocoder result type must be a string value. - */ - public function testTypeWithInvalidValue() - { - $this->geocoderResult->addType(true); - } -} diff --git a/tests/Services/Geocoding/Result/GeocoderStatusTest.php b/tests/Services/Geocoding/Result/GeocoderStatusTest.php deleted file mode 100644 index b140b9c1..00000000 --- a/tests/Services/Geocoding/Result/GeocoderStatusTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Geocoding\Result; - -use Ivory\GoogleMap\Services\Geocoding\Result\GeocoderStatus; - -/** - * Geocoder status test. - * - * @author GeLo - */ -class GeocoderStatusTest extends \PHPUnit_Framework_TestCase -{ - public function testGeocoderStatus() - { - $expected = array( - GeocoderStatus::ERROR, - GeocoderStatus::INVALID_REQUEST, - GeocoderStatus::OK, - GeocoderStatus::OVER_QUERY_LIMIT, - GeocoderStatus::REQUEST_DENIED, - GeocoderStatus::UNKNOWN_ERROR, - GeocoderStatus::ZERO_RESULTS - ); - - $this->assertSame($expected, GeocoderStatus::getGeocoderStatus()); - } -} diff --git a/tests/Services/Utils/XmlParserTest.php b/tests/Services/Utils/XmlParserTest.php deleted file mode 100644 index e0c2aa2c..00000000 --- a/tests/Services/Utils/XmlParserTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please read the LICENSE - * file that was distributed with this source code. - */ - -namespace Ivory\Tests\GoogleMap\Services\Utils; - -use Ivory\GoogleMap\Services\Utils\XmlParser; - -/** - * Xml parser test. - * - * @author GeLo - */ -class XmlParserTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Ivory\GoogleMap\Services\Utils\XmlParser */ - protected $xmlParser; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->xmlParser = new XmlParser(); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->xmlParser); - } - - public function testParse() - { - $xml = 'bar'; - - $expected = new \stdClass(); - $expected->foo = 'bar'; - - $this->assertEquals($expected, $this->xmlParser->parse($xml)); - } - - public function testParsePluralized() - { - $xml = 'bar'; - $rules = array('foo' => 'foos'); - - $expected = new \stdClass(); - $expected->foos = array('bar'); - - $this->assertEquals($expected, $this->xmlParser->parse($xml, $rules)); - } -} diff --git a/tests/Utility/OptionsAwareTest.php b/tests/Utility/OptionsAwareTest.php new file mode 100644 index 00000000..a81eddbf --- /dev/null +++ b/tests/Utility/OptionsAwareTest.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Utility; + +use Ivory\GoogleMap\Utility\OptionsAwareInterface; +use Ivory\GoogleMap\Utility\OptionsAwareTrait; + +/** + * @author GeLo + */ +class OptionsAwareTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var OptionsAwareTrait + */ + private $optionsAware; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->optionsAware = new OptionsAwareMock(); + } + + public function testDefaultState() + { + $this->assertEmpty($this->optionsAware->getOptions()); + } + + public function testSetOptions() + { + $this->optionsAware->setOptions($options = [$option = 'foo' => $value = 'bar']); + $this->optionsAware->setOptions($options); + + $this->assertTrue($this->optionsAware->hasOptions()); + $this->assertSame($options, $this->optionsAware->getOptions()); + $this->assertTrue($this->optionsAware->hasOption($option)); + $this->assertSame($value, $this->optionsAware->getOption($option)); + } + + public function testAddOptions() + { + $this->optionsAware->setOptions($firstOptions = ['foo' => 'bar']); + $this->optionsAware->addOptions($secondOptions = ['baz' => 'bat']); + + $this->assertTrue($this->optionsAware->hasOptions()); + $this->assertSame(array_merge($firstOptions, $secondOptions), $this->optionsAware->getOptions()); + } + + public function testSetOption() + { + $this->optionsAware->setOption($option = 'foo', $value = 'bar'); + + $this->assertTrue($this->optionsAware->hasOptions()); + $this->assertSame([$option => $value], $this->optionsAware->getOptions()); + $this->assertTrue($this->optionsAware->hasOption($option)); + $this->assertSame($value, $this->optionsAware->getOption($option)); + } + + public function testRemoveOption() + { + $this->optionsAware->setOption($option = 'foo', 'bar'); + $this->optionsAware->removeOption($option); + + $this->assertFalse($this->optionsAware->hasOptions()); + $this->assertFalse($this->optionsAware->hasOption($option)); + } + + public function testMissingOption() + { + $this->assertNull($this->optionsAware->getOption('foo')); + } +} + +/** + * @author GeLo + */ +class OptionsAwareMock implements OptionsAwareInterface +{ + use OptionsAwareTrait; +} diff --git a/tests/Utility/VariableAwareTest.php b/tests/Utility/VariableAwareTest.php new file mode 100644 index 00000000..4283c47e --- /dev/null +++ b/tests/Utility/VariableAwareTest.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +namespace Ivory\Tests\GoogleMap\Utility; + +use Ivory\GoogleMap\Utility\VariableAwareInterface; +use Ivory\GoogleMap\Utility\VariableAwareTrait; + +/** + * @author GeLo + */ +class VariableAwareTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var VariableAwareTrait + */ + private $variableAware; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->variableAware = new VariableAwareMock(); + } + + public function testDefaultState() + { + $this->assertInternalType('string', $this->variableAware->getVariable()); + } + + public function testVariable() + { + $this->variableAware->setVariable($variable = 'foo'); + + $this->assertSame($variable, $this->variableAware->getVariable()); + } + + public function testPrefixedVariable() + { + $this->variableAware = new PrefixedVariableAwareMock(); + + $this->assertStringStartsWith('prefix', $this->variableAware->getVariable()); + } +} + +/** + * @author GeLo + */ +class VariableAwareMock implements VariableAwareInterface +{ + use VariableAwareTrait; +} + +/** + * @author GeLo + */ +class PrefixedVariableAwareMock implements VariableAwareInterface +{ + use VariableAwareTrait; + + public function __construct() + { + $this->setVariablePrefix('prefix'); + } +} diff --git a/tests/bootstrap.php b/tests/autoload.php similarity index 61% rename from tests/bootstrap.php rename to tests/autoload.php index 9251aeb7..df940298 100644 --- a/tests/bootstrap.php +++ b/tests/autoload.php @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -// Autoloads library. -$loader = require __DIR__.'/../vendor/autoload.php'; +require_once __DIR__.'/../vendor/autoload.php'; -// Autoloads tests. -$loader->addPsr4('Ivory\\Tests\\GoogleMap\\', __DIR__); +\PHPUnit_Extensions_Selenium2TestCase::shareSession(true);