PluginProbe ʕ •ᴥ•ʔ
FAPI Member / 2.2.24
FAPI Member v2.2.24
2.2.33 2.2.32 trunk 1.9.47 2.1.18 2.2.24 2.2.25 2.2.26 2.2.28 2.2.29 2.2.30 2.2.31
fapi-member / src / Model / Page.php
fapi-member / src / Model Last commit date
Enums 11 months ago ApiConnection.php 11 months ago MemberLevel.php 11 months ago MemberSection.php 11 months ago Membership.php 11 months ago MembershipChange.php 11 months ago Page.php 11 months ago Settings.php 11 months ago User.php 11 months ago
Page.php
57 lines
1 <?php declare(strict_types=1);
2
3 namespace FapiMember\Model;
4
5 use FapiMember\Library\SmartEmailing\Types\IntType;
6 use FapiMember\Library\SmartEmailing\Types\StringType;
7
8 class Page
9 {
10 private int|string $id;
11 private string $title;
12 private string $type;
13 private string|null $url;
14
15 public function __construct(array $data)
16 {
17 $this->title = StringType::extract($data, 'title');
18 $this->type = StringType::extract($data, 'type');
19 $this->url = StringType::extractOrNull($data, 'url');
20
21 if ($this->type === 'cpt') {
22 $this->id = StringType::extract($data, 'id');
23 } else{
24 $this->id = IntType::extract($data, 'id');
25 }
26 }
27
28 public function getId(): int|string
29 {
30 return $this->id;
31 }
32
33 public function getTitle(): string
34 {
35 return $this->title;
36 }
37
38 public function getType(): string
39 {
40 return $this->type;
41 }
42
43 /**
44 * @return array<mixed>
45 */
46 public function toArray(): array
47 {
48 return [
49 'id' => $this->id,
50 'title' => $this->title,
51 'type' => $this->type,
52 'url' => $this->url,
53 ];
54 }
55
56 }
57