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