rmasters / swapi
v0.2.0
2015-01-20 17:55 UTC
Requires
- guzzlehttp/guzzle: ~5.0
- netresearch/jsonmapper: ~0.4
- psr/log: ~1.0
Requires (Dev)
- fabpot/php-cs-fixer: ~1.3
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-09-24 02:47:30 UTC
README
## 使用方法
使用Composer安装: composer require "rmasters/swapi:~1.0"
.
require_once __DIR__ . '/vendor/autoload.php'; use SWAPI\SWAPI; $swapi = new SWAPI; $swapi->characters()->index(); => Character[] $swapi->characters()->index(2); => Character[] $swapi->vehicles()->get(1); => Vehicle <X-wing> $swapi->planets()->get(7); => Planet <Mustafar> $swapi->people()->get(9999); => null (not-found) // Iteration do { if (!isset($starships)) { $starships = $swapi->starships()->index(); } else { $starships = $starships->getNext(); } foreach ($starships as $s) { echo "{$s->name}\n"; } } while ($starships->hasNext());
## 运行测试和贡献
使用composer install --dev
安装依赖项,并运行vendor/bin/phpunit
以运行测试套件。测试套件包括
- tests/Endpoints - 使用模拟样本响应的测试
- tests/Functional - 使用实时API的测试,以发现更改