Message   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 5
Dependencies 0

Importance

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

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setRaw() 0 4 1
A setHeaders() 0 10 2
A setText() 0 4 1
A setHtml() 0 4 1
A setSubject() 0 4 1
A setFrom() 0 7 1
A setTo() 0 9 2
A setCc() 0 9 2
A setSource() 0 4 1
A setId() 0 4 1
A hasMetadata() 0 4 1
1
<?php
2
namespace AramisAuto\EmailController;
3
4
class Message
5
{
6
    public $id;
7
    public $raw;
8
    public $headers;
9
    public $text;
10
    public $html;
11
    public $subject;
12
    public $from = array();
13
    public $to = array();
14
    public $cc = array();
15
    public $source;
16
    public $metadata = array();
17
18
    public function setRaw($raw)
19
    {
20
        $this->raw = $raw;
21
    }
22
23
    public function setHeaders(array $headers)
24
    {
25
        // All headers must be case sensitive
26
        $headersLower = new \stdClass();
27
        foreach ($headers as $name => $value) {
28
            $nameLower = strtolower($name);
29
            $headersLower->$nameLower = $value;
30
        }
31
        $this->headers = $headersLower;
32
    }
33
34
    public function setText($text)
35
    {
36
        $this->text = $text;
37
    }
38
39
    public function setHtml($html)
40
    {
41
        $this->html = $html;
42
    }
43
44
    public function setSubject($subject)
45
    {
46
        $this->subject = $subject;
47
    }
48
49
    public function setFrom($email, $name = null)
50
    {
51
        $from = new \StdClass();
52
        $from->email = $email;
53
        $from->name = $name;
54
        $this->from = $from;
0 ignored issues
show
Documentation Bug introduced by
It seems like $from of type object<stdClass> is incompatible with the declared type array of property $from.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
55
    }
56
57
    public function setTo(array $tos)
58
    {
59
        $objTo = new \StdClass();
60
        foreach ($tos as $to) {
61
            $objTo->email = $to[0];
62
            $objTo->name = $to[1];
63
        }
64
        $this->to = $objTo;
0 ignored issues
show
Documentation Bug introduced by
It seems like $objTo of type object<stdClass> is incompatible with the declared type array of property $to.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
65
    }
66
67
    public function setCc(array $ccs)
68
    {
69
        $objCc = new \StdClass();
70
        foreach ($ccs as $cc) {
71
            $objCc->email = $cc[0];
72
            $objCc->name = $cc[1];
73
        }
74
        $this->cc = $objCc;
0 ignored issues
show
Documentation Bug introduced by
It seems like $objCc of type object<stdClass> is incompatible with the declared type array of property $cc.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
75
    }
76
77
    public function setSource($source)
78
    {
79
        $this->source = $source;
80
    }
81
82
    public function setId($id)
83
    {
84
        $this->id = $id;
85
    }
86
87
    public function hasMetadata($name)
88
    {
89
        return array_key_exists($name, $this->metadata);
90
    }
91
}
92