ikwattro / github-event
Github Api Public Events to PHP Objects Mapper
Requires
- php: ~5.4
- symfony/config: ~2.6
- symfony/dependency-injection: ~2.6
- symfony/yaml: ~2.6
Requires (Dev)
- phpspec/phpspec: ~2.1
- phpunit/phpunit: ~4.0
README
Github Api Public Events to PHP Objects
Transforms the Github API Public Events into PHP Objects
Installation
Require the library in your composer.json
composer require ikwattro/github-event
Usage
Building the EventHandler
The application need to be built through the factory constructor, currently there is no need for such factory design but it aims to be extensible for future usages.
use Ikwattro\GithubEvent\EventHandler; $eventHandler = EventHandler::create() ->build();
Passing events
The mainpoint of the library is the handleEvent
method that takes the GithubEvent as argument in an array format (json_decoded).
Once passed, you'll receive in return the corresponding PHP Object instance corresponding to the event.
$events = json_decode('events.json', true); foreach ($events as $e) { $event = $eventHandler->handleEvent($e); }
Working with Events
An event object may contain more than the current event, for e.g., a CreateEvent
will contain the payload of the event, but also
the associated Repository object, RepositoryOwner, ... .
Please refer to the source code for discovering what is inside each event.
Currently supported events
- WatchEvent
- IssuesEvent
- IssueCommentEvent
- CreateEvent
- PushEvent
- ForkEvent
- PullRequestEvent
License
The library is licensed under the MIT License