| Total Complexity | 6 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class Webhook |
||
| 8 | { |
||
| 9 | const HEADER_HMAC_SIGNATURE = 'X-Shopify-Hmac-Sha256'; |
||
| 10 | const HEADER_SHOP_DOMAIN = 'X-Shopify-Shop-Domain'; |
||
| 11 | const HEADER_TOPIC = 'X-Shopify-Topic'; |
||
| 12 | |||
| 13 | protected string $domain; |
||
| 14 | protected string $topic; |
||
| 15 | protected array $payload; |
||
| 16 | |||
| 17 | public function __construct(string $domain, string $topic, array $payload) |
||
| 22 | } |
||
| 23 | |||
| 24 | public function domain(): string |
||
| 25 | { |
||
| 26 | return $this->domain; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function eventName(): string |
||
| 30 | { |
||
| 31 | return 'shopify-webhooks.'.str_replace('/', '-', $this->topic()); |
||
| 32 | } |
||
| 33 | |||
| 34 | public function payload(): array |
||
| 35 | { |
||
| 36 | return $this->payload; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function topic(): string |
||
| 40 | { |
||
| 41 | return $this->topic; |
||
| 42 | } |
||
| 43 | |||
| 44 | public static function fromRequest(Request $request): self |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |