Total Complexity | 11 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
20 | class Address { |
||
21 | |||
22 | /** |
||
23 | * Address attributes |
||
24 | * @var string $personal |
||
25 | * @var string $mailbox |
||
26 | * @var string $host |
||
27 | * @var string $mail |
||
28 | * @var string $full |
||
29 | */ |
||
30 | public $personal = ""; |
||
31 | public $mailbox = ""; |
||
32 | public $host = ""; |
||
33 | public $mail = ""; |
||
34 | public $full = ""; |
||
35 | |||
36 | /** |
||
37 | * Address constructor. |
||
38 | * @param object $object |
||
39 | */ |
||
40 | public function __construct($object) { |
||
41 | if (property_exists($object, "personal")){ $this->personal = $object->personal; } |
||
42 | if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; } |
||
43 | if (property_exists($object, "host")){ $this->host = $object->host; } |
||
44 | if (property_exists($object, "mail")){ $this->mail = $object->mail; } |
||
45 | if (property_exists($object, "full")){ $this->full = $object->full; } |
||
46 | } |
||
47 | |||
48 | |||
49 | /** |
||
50 | * Return the stringified address |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | public function __toString() { |
||
55 | return $this->full ?: ""; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Return the serialized address |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | public function __serialize(){ |
||
70 | ]; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Convert instance to array |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | public function toArray(): array { |
||
79 | return $this->__serialize(); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Return the stringified attribute |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | public function toString(): string { |
||
89 | } |
||
90 | } |