FapiLevels.php
2 years ago
FapiMemberTools.php
2 years ago
FapiMembership.php
2 years ago
FapiTermEnvelope.php
2 years ago
FapiMembership.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | namespace FapiMember\Deprecated; |
| 4 | |
| 5 | use DateTimeImmutable; |
| 6 | use FapiMember\FapiMemberPlugin; |
| 7 | use JsonSerializable; |
| 8 | |
| 9 | /** @deprecated */ |
| 10 | final class FapiMembership implements JsonSerializable { |
| 11 | |
| 12 | |
| 13 | /** @var int */ |
| 14 | public $level; |
| 15 | |
| 16 | /** @var DateTimeImmutable|null */ |
| 17 | public $registered; |
| 18 | |
| 19 | /** @var DateTimeImmutable|null */ |
| 20 | public $until; |
| 21 | |
| 22 | /** @var bool */ |
| 23 | public $isUnlimited = false; |
| 24 | |
| 25 | /** |
| 26 | * @param int $level |
| 27 | * @param DateTimeImmutable|null $registered |
| 28 | * @param DateTimeImmutable|null $until |
| 29 | * @param bool $isUnlimited |
| 30 | */ |
| 31 | public function __construct( $level, $registered = null, $until = null, $isUnlimited = false ) { |
| 32 | if ( $until === false ) { |
| 33 | $until = null; |
| 34 | } |
| 35 | |
| 36 | if ( $registered === false ) { |
| 37 | $registered = null; |
| 38 | } |
| 39 | |
| 40 | $this->level = $level; |
| 41 | $this->registered = $registered; |
| 42 | $this->until = $until; |
| 43 | $this->isUnlimited = $isUnlimited; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @return array<mixed> |
| 48 | */ |
| 49 | public function jsonSerialize(): array { |
| 50 | return array( |
| 51 | 'level' => $this->level, |
| 52 | 'registered' => $this->registered === null ? null : $this->registered->format( FapiMemberPlugin::DATE_TIME_FORMAT ), |
| 53 | 'until' => $this->until === null ? null : $this->until->format( FapiMemberPlugin::DATE_TIME_FORMAT ), |
| 54 | 'isUnlimited' => $this->isUnlimited, |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | } |
| 59 |