Address   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 11
eloc 20
c 2
b 0
f 2
dl 0
loc 69
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __serialize() 0 7 1
A __construct() 0 6 6
A toString() 0 2 1
A toArray() 0 2 1
A __toString() 0 2 2
1
<?php
2
/*
3
* File:     Address.php
4
* Category: -
5
* Author:   M. Goldenbaum
6
* Created:  01.01.21 21:17
7
* Updated:  -
8
*
9
* Description:
10
*  -
11
*/
12
13
namespace Webklex\PHPIMAP;
14
15
/**
16
 * Class Address
17
 *
18
 * @package Webklex\PHPIMAP
19
 */
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(){
64
        return [
65
            "personal" => $this->personal,
66
            "mailbox" => $this->mailbox,
67
            "host" => $this->host,
68
            "mail" => $this->mail,
69
            "full" => $this->full,
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 {
88
        return $this->__toString();
89
    }
90
}