Install the RiftConnector via composer:
$ composer require ecn/riftconnector:0.1.*
The RiftConnector comes along with a RiftService
class that allows easy access to shards, zones and events.
To get a running RiftService instance, pass a connector instance to the constructor:
<?php
use GuzzleHttp\Client;
use Ecn\RiftConnector\Connector;
use Ecn\RiftConnector\RiftService;
$connector = new Connector(new Client(), Connector::EU_SERVER);
$service = new RiftService($connector);
To retrieve a shard object, use the getShard()
method:
// returns a Shard object
$shard = $service->getShard('Brutwacht');
You can query zones from the shard object:
// returns an array of Zone objects
$zones = $shard->getZones();
Alternatively, you can retrieve zones directly from the RiftService:
// returns an array of Zone objects
$zones = $service->getZones('Brutwacht');
Similar to zones, events can be retrieved from the shard object or from the RiftConnector directly:
// returns an array of Event objects
$events = $shard->getEvents();
// returns an array of Event objects
$events = $service->getEvents('Brutwacht');
Additionally, you can check a zone directly for an event:
$zones = $shard->getZones();
if ($zones[0]->hasEvent()) {
$event = $zones[0]->getEvent();
}