Download the PHP package logipro/datamaps-php without Composer
On this page you can find all versions of the php package logipro/datamaps-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download logipro/datamaps-php
More information about logipro/datamaps-php
Files in logipro/datamaps-php
Package datamaps-php
Short Description A PHP component to use Datamaps API within your PHP project.
License MIT
Homepage https://github.com/logipro-fr/datamaps-php
Informations about the package datamaps-php
Datamaps PHP
A PHP component to use Datamaps' API within your PHP project.
DatamapsClient allows you to
- get a specific map via its ID,
- search the last maps created,
- create a new map.
A map is defined by 4 values :
string $mapId
is the id of the map.string $createdAt
is the creation date and time of the map, with format ATOM.[[float, float], [float, float]] $bounds
sets the limit of the map.Layer[] $layers
contains every layer. Each of them has astring $name
and an array ofMarker
(storing a geographic point[float, float] $point
, astring $description
and astring $color
).
Check DatamapsClient factories to obtain mocked versions of DatamapsClient for your tests.
Usage
In source files
DatamapsClient contains 3 public methods :
get(string $mapId)
to retrieve a specific map of idmapId
. Returns aMap
.search(int $amount)
to retrieve theamount
last created maps. Returns an array ofMap
.create(Map $map)
to create and save a new map. Onlybounds
andlayers
will be persisted,mapId
andcreatedAt
will be generated on creation by Datamaps. Returns aMap
.
In test files
SucceedingDatamapsClientMockFactory allows to test DatamapsClient if everything goes right.
make()
creates a mock of DatamapsClient that will never respond with failures.getExpectedResponseFromGet(string $mapId)
returns the map the mocked version of theget($mapId)
method will return.getExpectedResponseFromSearch(int $amount)
returns the map the mocked version of thesearch($amount)
method will return.getExpectedResponseFromCreate(Map $map)
returns the map the mocked version of thecreate($map)
method will return.
FailingDatamapsClientMockFactory allows to test DatamapsClient if everything goes wrong.
make()
creates a mock of DatamapsClient that will always respond with failures.get($mapId)
will always result onError on request to Datamaps. Map with mapId $mapId not found
.search($amount)
will always result onError on request to Datamaps. Can't retrieve data from an empty repository
.create($map)
will always result onError on request to Datamaps. /bounds: Array should have at least 2 items, 1 found
.
Install
To contribute to Datamaps PHP
Requirements:
- docker
- git
Unit tests
Integration tests
Quality
Some indicators:
- phpcs PSR12
- phpstan level 9
- coverage >= 100%
- infection MSI >= 100%
Quick check with:
Check coverage with:
and view 'var/index.html' in your browser
Check infection with:
and view 'var/infection.html' in your browser