xvrmallafre / swapi
This package is abandoned and no longer maintained.
No replacement package was suggested.
This is a fork of rmasters/swapi that works again.
1.0.0
2020-02-22 16:02 UTC
Requires
- guzzlehttp/guzzle: ~5.0
- netresearch/jsonmapper: 0.4.0
- psr/log: ~1.0
Requires (Dev)
- fabpot/php-cs-fixer: ~1.3
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2023-03-20 05:02:28 UTC
README
## Usage
Install with 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());
## Running tests and contributing
Install dependencies with composer install --dev
and run vendor/bin/phpunit
to run the testsuite. The test suite comprises of:
- tests/Endpoints - tests that use mocked sample responses,
- tests/Functional - tests that use the live API, to spot changes.