Object   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 47
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __set() 0 4 1
A __get() 0 8 2
A toArray() 0 4 1
1
<?php
2
3
namespace Inbounder\Parsers\Objects;
4
5
use Exception as MissingAttributeException;
6
use Illuminate\Contracts\Support\Arrayable;
7
8
class Object implements Arrayable
9
{
10
    /**
11
     * Attributes.
12
     */
13
    protected $attributes = [];
14
15
    /**
16
     * Constructor.
17
     */
18
    public function __construct($email, $name = null, $mailboxHash = null)
19
    {
20
        $this->attributes['email'] = $email;
21
        $this->attributes['name'] = $name;
22
        $this->attributes['mailboxHash'] = $mailboxHash;
23
    }
24
25
    /**
26
     * Setter.
27
     */
28
    public function __set($name, $value)
29
    {
30
        $this->attributes[$name] = $value;
31
    }
32
33
    /**
34
     * Getter.
35
     */
36
    public function __get($name)
37
    {
38
        if (!array_key_exists($name, $this->attributes)) {
39
            throw new MissingAttributeException("The attribute $name does not exists.", 1);
40
        }
41
42
        return $this->attributes[$name];
43
    }
44
45
    /**
46
     * Get the instance as an array.
47
     *
48
     * @return array
49
     */
50
    public function toArray()
51
    {
52
        return $this->attributes;
53
    }
54
}
55