renttek / bitbucket-webhook-types
库,用于将bitbucket webhook有效负载转换为类型化对象
0.0.1
2023-06-01 18:33 UTC
Requires
- php: 8.2.*
- cuyz/valinor: ^1.4
- doctrine/collections: ^2.1
- symfony/uid: ^6.3
Requires (Dev)
- captainhook/captainhook: ^5.16
- captainhook/plugin-composer: ^5.3
- ergebnis/composer-normalize: ^2.31
- php-parallel-lint/php-console-highlighter: ^1.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-strict-rules: ^1.5
- roave/security-advisories: dev-latest
- symfony/var-dumper: 5.* || 6.*
- symplify/easy-coding-standard: ^11.3
- vimeo/psalm: ^5.12
README
此库提供了一种转换器以及用于bitbucket webhook有效负载的值对象。
安装
可以使用composer轻松安装此模块
composer require renttek/bitbucket-webhook-types
用法
$pullRequestCreatedPayload = '<webhook json here>'; $converter = new \Renttek\BitbucketWebhookTypes\Converter(); $pullRequestCreated = $converter->fromJson( \Renttek\BitbucketWebhookTypes\EventPayload\PullrequestCreated::class, $pullRequestCreatedPayload )
使用自定义映射器/配置
转换器使用 cuyz/valinor 构建,如果您想使用自定义映射器而不是默认映射器,可以将映射器传递给 \Renttek\BitbucketWebhookTypes\Converter 构造函数
$pullRequestCreatedPayload = '<webhook json here>'; $myAwesomeMapper = (new MapperBuilder()) ->supportDateFormats('Y-m-d\TH:i:s.uP') ->infer( ... ) ->registerConstructor( ... ) ->allowSuperfluousKeys() ->mapper(); $converter = new \Renttek\BitbucketWebhookTypes\Converter($myAwesomeMapper); $pullRequestCreated = $converter->fromJson( \Renttek\BitbucketWebhookTypes\EventPayload\PullrequestCreated::class, $pullRequestCreatedPayload )
致谢
我想感谢CuyZ团队和所有为valinor做出贡献的贡献者!