prestashop/github-webhook-parser

将 Github API v3 事件转换为 PHP 对象

0.1.0 2020-09-09 15:24 UTC

This package is auto-updated.

Last update: 2024-09-10 01:34:12 UTC


README

此库旨在将 Github API v3 事件转换为 PHP 对象

安装

通过 Composer

composer require prestashop/github-webhook-parser

用法

使用 WebhookHandler 类检索事件

$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();
}

测试

$ composer install
$ vendor/bin/phpunit

鸣谢

许可证

MIT 许可证(MIT)。请参阅 许可证文件 了解更多信息。