CommentPayload.php
1 year ago
PostPayload.php
2 years ago
UserPayload.php
3 years ago
index.php
3 years ago
UserPayload.php
42 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Integrations\WordPress\Payloads; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Automation\Engine\Integration\Payload; |
| 9 | use WP_User; |
| 10 | |
| 11 | class UserPayload implements Payload { |
| 12 | /** @var WP_User */ |
| 13 | private $user; |
| 14 | |
| 15 | public function __construct( |
| 16 | WP_User $user |
| 17 | ) { |
| 18 | $this->user = $user; |
| 19 | } |
| 20 | |
| 21 | public function getId(): int { |
| 22 | return $this->user->ID; |
| 23 | } |
| 24 | |
| 25 | public function getUser(): WP_User { |
| 26 | return $this->user; |
| 27 | } |
| 28 | |
| 29 | public function getEmail(): ?string { |
| 30 | return $this->user->user_email ?: null; |
| 31 | } |
| 32 | |
| 33 | public function exists(): bool { |
| 34 | return $this->user->exists(); |
| 35 | } |
| 36 | |
| 37 | /** @return string[] */ |
| 38 | public function getRoles(): array { |
| 39 | return $this->user->roles; |
| 40 | } |
| 41 | } |
| 42 |