rmasters/swapi

v0.2.0 2015-01-20 17:55 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:47:30 UTC


README

Build status Stable release License

## 使用方法

使用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以运行测试套件。测试套件包括

许可证

MIT许可