Completed
Push — master ( dd0453...7030c1 )
by Edgar
02:30
created

Object   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 46
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __set() 0 4 1
A __get() 0 7 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 = array();
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
        return $this->attributes[$name];
42
    }
43
44
    /**
45
     * Get the instance as an array.
46
     *
47
     * @return array
48
     */
49
    public function toArray()
50
    {
51
        return $this->attributes;
52
    }
53
}
54