GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Pull Request — master (#3)
by Sascha
05:02
created

Mail   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 184
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 90.7%

Importance

Changes 0
Metric Value
wmc 17
lcom 2
cbo 3
dl 0
loc 184
ccs 39
cts 43
cp 0.907
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A setSender() 0 4 1
A setFrom() 0 4 1
A sender() 0 8 2
A hasSender() 0 4 1
A hasFrom() 0 4 1
A content() 0 4 1
A recipients() 0 4 1
A ccs() 0 4 1
A bccs() 0 4 1
A attachments() 0 4 1
A getSubject() 0 4 1
A setSubject() 0 4 1
A replyTos() 0 4 1
A from() 0 8 2
1
<?php
2
3
namespace Conversio\Mail;
4
5
use Conversio\Mail\Address\Address;
6
use Conversio\Mail\Address\AddressContainer;
7
use Conversio\Mail\Attachment\AttachmentContainer;
8
use Exception;
9
10
/**
11
 * Class Mail
12
 * @package Conversio\Mail
13
 */
14
class Mail
15
{
16
    /**
17
     * @var Address
18
     */
19
    private $sender;
20
21
    /**
22
     * @var Address
23
     */
24
    private $from;
25
26
    /**
27
     * @var string
28
     */
29
    private $subject = '';
30
31
    /**
32
     * @var Content
33
     */
34
    private $content;
35
36
    /**
37
     * @var AddressContainer
38
     */
39
    private $recipients;
40
41
    /**
42
     * @var AddressContainer
43
     */
44
    private $ccs;
45
46
    /**
47
     * @var AddressContainer
48
     */
49
    private $bccs;
50
51
    /**
52
     * @var AttachmentContainer
53
     */
54
    private $attachments;
55
56
    /**
57
     * @var AddressContainer
58
     */
59
    private $replyTos;
60
61
    /**
62
     * Mail constructor.
63
     *
64
     */
65 8
    public function __construct()
66
    {
67 8
        $this->content     = new Content();
68 8
        $this->recipients  = new AddressContainer();
69 8
        $this->ccs         = new AddressContainer();
70 8
        $this->bccs        = new AddressContainer();
71 8
        $this->replyTos    = new AddressContainer();
72 8
        $this->attachments = new AttachmentContainer();
73 8
    }
74
75
    /**
76
     * @param Address $sender
77
     */
78 1
    public function setSender(Address $sender)
79
    {
80 1
        $this->sender = $sender;
81 1
    }
82
83
    /**
84
     * @param Address $from
85
     *
86
     */
87 1
    public function setFrom(Address $from)
88
    {
89 1
        $this->from = $from;
90 1
    }
91
92
    /**
93
     * @return Address
94
     * @throws Exception
95
     */
96 1
    public function from(): Address
97
    {
98 1
        if (!$this->hasFrom()) {
99
            throw new Exception('There is no from given');
100
        }
101
102 1
        return $this->from;
103
    }
104
105
    /**
106
     * @return Address
107
     * @throws Exception
108
     */
109 1
    public function sender(): Address
110
    {
111 1
        if (!$this->hasSender()) {
112
            throw new Exception('There is no sender given');
113
        }
114
115 1
        return $this->sender;
116
    }
117
118
    /**
119
     * @return bool
120
     */
121 1
    public function hasSender(): bool
122
    {
123 1
        return $this->sender !== null;
124
    }
125
126
    /**
127
     * @return bool
128
     */
129 1
    public function hasFrom(): bool
130
    {
131 1
        return $this->from !== null;
132
    }
133
134
    /**
135
     * @return Content
136
     */
137 1
    public function content(): Content
138
    {
139 1
        return $this->content;
140
    }
141
142
    /**
143
     * @return AddressContainer
144
     */
145 1
    public function recipients(): AddressContainer
146
    {
147 1
        return $this->recipients;
148
    }
149
150
    /**
151
     * @return AddressContainer
152
     */
153 1
    public function ccs(): AddressContainer
154
    {
155 1
        return $this->ccs;
156
    }
157
158
    /**
159
     * @return AddressContainer
160
     */
161 1
    public function bccs(): AddressContainer
162
    {
163 1
        return $this->bccs;
164
    }
165
166
    /**
167
     * @return AttachmentContainer
168
     */
169 1
    public function attachments(): AttachmentContainer
170
    {
171 1
        return $this->attachments;
172
    }
173
174
    /**
175
     * @return string
176
     */
177 1
    public function getSubject(): string
178
    {
179 1
        return $this->subject;
180
    }
181
182
    /**
183
     * @param string $subject
184
     */
185 1
    public function setSubject(string $subject)
186
    {
187 1
        $this->subject = $subject;
188 1
    }
189
190
    /**
191
     * @return AddressContainer
192
     */
193
    public function replyTos(): AddressContainer
194
    {
195
        return $this->replyTos;
196
    }
197
}