php-mtg/mtg-api-com-scryfall-object

实现php-mtg/mtg-api-com-scryfall接口的库


README

实现php-mtg/mtg-api-com-scryfall接口的库。

coverage build status

安装

此库的安装通过composer进行,并且通过其自动加载器自动加载该库的所有类。

  • 他们的网站下载 composer.phar
  • 然后运行以下命令将此库作为依赖项安装
  • php composer.phar require php-mtg/mtg-api-com-scryfall-object ^7

基本用法

此库可以通过以下方式使用


use PhpMtg\Scryfall\ScryfallApiEndpoint;

/* @var $client \Psr\Http\Client\ClientInterface */

$endpoint = new ScryfallApiEndpoint($client);

$collection = $endpoint->getSets();

foreach($collection as $set)
{
	$page = 1;
	do
	{
		/** @var \PhpMtg\Scryfall\ScryfallApiPagination $pagination */
		$pagination = $endpoint->getCardsSearch($page, 'e='.$set->getId());
		
		foreach($pagination->getData() as $card)
		{
			// do something with $card
		}
		
		$page++;
	}
	while($pagination->hasMore());
}

许可证

MIT(见许可证文件)。