magiclegacy / search-client
Search Client for magic card in ElasticSearch engine
1.0.0
2021-11-17 23:37 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
- eureka/component-curl: ^2.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/log: ^1.1
- thecodingmachine/safe: ^1.3
Requires (Dev)
- phpunit/phpcov: ^8.1.0
- phpunit/phpunit: ^9.3
- squizlabs/php_codesniffer: ^3.5
README
Search Client for magic card in ElasticSearch engine
Supported search (related to Atomic Card from mtgjson.org, with some minor field renaming):
/atomic/_search
: ElasticSearch index with nameatomic
for all atomics cards
Composer
composer require magiclegacy/search-client
Usage in application
<?php namespace Application; use MagicLegacy\Component\Search\Client\SearchClient; use Eureka\Component\Curl; use Nyholm\Psr7\Factory\Psr17Factory; use Psr\Log\NullLogger; require_once __DIR__ . '/../vendor/autoload.php'; //~ Declare tier required services (included as dependencies) $httpFactory = new Psr17Factory(); $searchClient = new SearchClient( new Curl\HttpClient(), $httpFactory, $httpFactory, $httpFactory, new NullLogger() ); $cards = $searchClient->searchAtomicCards('name:llanowar types:creature power:1 OR power:2'); foreach ($cards as $card) { echo (string) $card->getName() . ' - ' . $card->getPower() . '/' . $card->getToughness() . PHP_EOL; }
see: example.php
The output will be:
Llanowar Cavalry - 1/4
Llanowar Druid - 1/2
Llanowar Elite - 1/1
Llanowar Elves - 1/1
Llanowar Mentor - 1/1
Llanowar Scout - 1/3
Llanowar Vanguard - 1/1
Llanowar Dead - 2/2
Llanowar Empath - 2/2
Llanowar Knight - 2/2
SearchClient
About Atomic Cards
Available methods:
SearchClient::searchAtomicCards()
:AtomicCard[]