prestashop/github-webhook-parser

Converts Github API v3 events to PHP objects

0.1.0 2020-09-09 15:24 UTC

This package is auto-updated.

Last update: 2024-12-06 18:36:13 UTC


README

This lib aims to convert Github API v3 events to PHP objects

Install

Via Composer

composer require prestashop/github-webhook-parser

Usage

Use the WebhookHandler class to retrieve the event:

$payload = json_decode($request->getContent(), true);
$webhookHandler = new \PrestaShop\Github\WebhookHandler();

try {
    $event = $webhookHandler->handle($payload);
} catch (\PrestaShop\Github\Exception\EventNotHandledException $e) {
    ...
}

if ($event instanceof \PrestaShop\Github\Event\PullRequestEvent) {
    $action = $event->getAction();
    $pullRequest = $event->getPullRequest();
}

Testing

$ composer install
$ vendor/bin/phpunit

Credits

License

The MIT License (MIT). Please see License File for more information.