NewsletterLinkPayload.php
2 years ago
SegmentPayload.php
3 years ago
SubscriberPayload.php
3 years ago
index.php
3 years ago
SegmentPayload.php
38 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Integrations\MailPoet\Payloads; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Automation\Engine\Integration\Payload; |
| 9 | use MailPoet\Entities\SegmentEntity; |
| 10 | use MailPoet\InvalidStateException; |
| 11 | |
| 12 | class SegmentPayload implements Payload { |
| 13 | /** @var SegmentEntity */ |
| 14 | private $segment; |
| 15 | |
| 16 | public function __construct( |
| 17 | SegmentEntity $segment |
| 18 | ) { |
| 19 | $this->segment = $segment; |
| 20 | } |
| 21 | |
| 22 | public function getId(): int { |
| 23 | $id = $this->segment->getId(); |
| 24 | if (!$id) { |
| 25 | throw new InvalidStateException(); |
| 26 | } |
| 27 | return $id; |
| 28 | } |
| 29 | |
| 30 | public function getName(): string { |
| 31 | return $this->segment->getName(); |
| 32 | } |
| 33 | |
| 34 | public function getType(): string { |
| 35 | return $this->segment->getType(); |
| 36 | } |
| 37 | } |
| 38 |