jacobknox / pokemon-tcg-sdk-php
这是对 Pokémon TCG SDK PHP 实现的更新。它是对 pokemontcg.io 的 Pokémon TCG API 的包装。
2.1.1
2022-11-08 23:41 UTC
Requires
- php: ^5.5 || ^5.6 || ^7.0 || ^7.3 || ^7.4 || ^8.0
- ext-json: *
- doctrine/inflector: ^1.1 || ^2.0
- guzzlehttp/guzzle: ^6.2 || ^7.2
Requires (Dev)
- dms/phpunit-arraysubset-asserts: ^0.2.1
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-23 20:57:35 UTC
README
这是 Pokémon TCG SDK PHP 实现。它是对 pokemontcg.io 的 Pokémon TCG API 的包装。
安装
composer require jacobknox/pokemon-tcg-sdk-php
用法
设置 ApiKey 和选项
Pokemon::Options(['verify' => true]);
Pokemon::ApiKey('<YOUR_API_KEY_HERE>');
通过 id 查找卡片
$card = Pokemon::Card()->find('xy1-1');
通过查询参数过滤卡片
$cards = Pokemon::Card()->where(['set.name' => 'generations'])->where(['supertype' => 'pokemon'])->all();
$cards = Pokemon::Card()->where([
'set.name' => 'roaring skies',
'subtypes' => 'ex'
])->all();
通过更复杂的查询参数过滤卡片
$cards = Pokemon::Card()->where(['types' => ['OR', 'fire', 'water'])->where(['supertype' => 'pokemon'])->all();
$cards = Pokemon::Card()->where([
'types' => ['OR', 'fire', 'water'],
'subtypes' => 'ex'
])->all();
排序卡片
有四种方法可以排序卡片。您可以使用适合您的方法。请注意,它们将首先按数组/列表的第一个项目排序,然后按第二个,依此类推,直到数组/列表的末尾。
指定属性和是否按升序排序
$cards = Pokemon::Card()->orderBy(['name' => 1, 'number' => -1])->all();
表示升序的允许值:1,'ascending',''。表示降序的允许值:-1,'descending','-'。
指定具有排序指示符的属性('-' 表示降序,没有表示升序)
$cards = Pokemon::Card()->orderBy(['name', '-number'])->all();
指定逗号分隔的属性列表
$cards = Pokemon::Card()->orderBy(['name,-number'])->all();
获取所有卡片
$cards = Pokemon::Card()->all();
分页查询卡片
$cards = Pokemon::Card()->where([
'set.legalities.standard' => 'legal'
])->page(8)->pageSize(100)->all();
获取卡片分页信息
$pagination = Pokemon::Card()->where([
'set.legalities.standard' => 'legal'
])->pagination();
通过套装代码查找套装
$set = Pokemon::Set()->find('base1');
通过查询参数过滤套装
$set = Pokemon::Set()->where(['legalities.standard' => 'legal'])->all();
分页查询套装
$set = Pokemon::Set()->page(2)->pageSize(10)->all();
获取套装分页信息
$pagination = Pokemon::Set()->pagination();
获取所有套装
$sets = Pokemon::Set()->all();
获取所有类型
$types = Pokemon::Type()->all();
获取所有子类型
$subtypes = Pokemon::Subtype()->all();
获取所有超类型
$supertypes = Pokemon::Supertype()->all();
获取所有稀有度
$supertypes = Pokemon::Rarity()->all();