logipro/datamaps-php
最新稳定版本:v1.0.4
Composer 安装命令:
composer require logipro/datamaps-php
包简介
A PHP component to use Datamaps API within your PHP project.
关键字:
README 文档
README
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 $mapIdis the id of the map.string $createdAtis the creation date and time of the map, with format ATOM.[[float, float], [float, float]] $boundssets the limit of the map.Layer[] $layerscontains every layer. Each of them has astring $nameand an array ofMarker(storing a geographic point[float, float] $point, astring $descriptionand 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 theamountlast created maps. Returns an array ofMap.create(Map $map)to create and save a new map. Onlyboundsandlayerswill be persisted,mapIdandcreatedAtwill 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
composer require logipro/datamaps-php
To contribute to Datamaps PHP
Requirements:
- docker
- git
Unit tests
bin/phpunit
Integration tests
bin/phpunit-integration
Quality
Some indicators:
- phpcs PSR12
- phpstan level 9
- coverage >= 100%
- infection MSI >= 100%
Quick check with:
./codecheck
Check coverage with:
bin/phpunit --coverage-html var
and view 'var/index.html' in your browser
Check infection with:
bin/infection
and view 'var/infection.html' in your browser
统计信息
- 总下载量: 42
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-16