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.
Passed
Push — master ( ed2944...746095 )
by Alex
03:36
created

Assistant   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 150
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 83.78%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 5
dl 0
loc 150
ccs 31
cts 37
cp 0.8378
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A listen() 0 4 1
A listenTo() 0 7 1
A __construct() 0 4 1
A from() 0 6 1
A to() 0 6 1
A write() 0 6 1
A writeHtml() 0 6 1
A copyTo() 0 6 1
A blindTo() 0 6 1
A withSubject() 0 6 1
A withAttachment() 0 6 1
A getMail() 0 4 1
A sendThrough() 0 4 1
1
<?php
2
3
namespace Conversio\Mail\Assistant;
4
5
use Conversio\Mail\Address\Address;
6
use Conversio\Mail\Attachment\AttachmentInterface;
7
use Conversio\Mail\Mail;
8
use Conversio\Mail\Pipeline\MailPipelineInterface;
9
use Conversio\Mail\Pipeline\ProcessResult;
10
11
/**
12
 * Class Assistant
13
 * @package Conversio\Mail\Assitant
14
 */
15
final class Assistant
16
{
17
    /**
18
     * @var Mail $mail
19
     */
20
    private $mail;
21
22
    /**
23
     * @return Assistant
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
24
     */
25 8
    public static function listen(): self
26
    {
27 8
        return new self();
28
    }
29
30
    /**
31
     * @param Address $sender
32
     *
33
     * @return Assistant
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
34
     */
35 1
    public static function listenTo(Address $sender): self
36
    {
37 1
        $assistant = self::listen();
38 1
        $assistant->from($sender);
39
40 1
        return $assistant;
41
    }
42
43
    /**
44
     * Assistant constructor.
45
     */
46 8
    public function __construct()
47
    {
48 8
        $this->mail = new Mail();
49 8
    }
50
51
    /**
52
     * @param Address $sender
53
     *
54
     * @return Assistant
55
     */
56 1
    public function from(Address $sender): self
57
    {
58 1
        $this->mail->setSender($sender);
59
60 1
        return $this;
61
    }
62
63
    /**
64
     * @param Address $to
65
     *
66
     * @return Assistant
67
     */
68
    public function to(Address $to): self
69
    {
70
        $this->mail->recipients()->addAddress($to);
71
72
        return $this;
73
    }
74
75
    /**
76
     * @param string $content
77
     *
78
     * @return Assistant
79
     */
80 1
    public function write(string $content): self
81
    {
82 1
        $this->mail->content()->setText($content);
83
84 1
        return $this;
85
    }
86
87
    /**
88
     * @param string $html
89
     *
90
     * @return Assistant
91
     */
92 1
    public function writeHtml(string $html): self
93
    {
94 1
        $this->mail->content()->setHtml($html);
95
96 1
        return $this;
97
    }
98
99
    /**
100
     * @param Address $address
101
     *
102
     * @return Assistant
103
     */
104 1
    public function copyTo(Address $address): self
105
    {
106 1
        $this->mail->ccs()->addAddress($address);
107
108 1
        return $this;
109
    }
110
111
    /**
112
     * @param Address $address
113
     *
114
     * @return Assistant
115
     */
116 1
    public function blindTo(Address $address): self
117
    {
118 1
        $this->mail->bccs()->addAddress($address);
119
120 1
        return $this;
121
    }
122
123
    /**
124
     * @param string $subject
125
     *
126
     * @return Assistant
127
     */
128 1
    public function withSubject(string $subject): self
129
    {
130 1
        $this->mail->setSubject($subject);
131
132 1
        return $this;
133
    }
134
135
    /**
136
     * @param AttachmentInterface $attachment
137
     *
138
     * @return Assistant
139
     */
140
    public function withAttachment(AttachmentInterface $attachment): self
141
    {
142
        $this->mail->attachments()->addAttachment($attachment);
143
144
        return $this;
145
    }
146
147
    /**
148
     * @return Mail
149
     */
150 7
    public function getMail(): Mail
151
    {
152 7
        return $this->mail;
153
    }
154
155
    /**
156
     * @param MailPipelineInterface $pipeline
157
     *
158
     * @return ProcessResult
159
     */
160 1
    public function sendThrough(MailPipelineInterface $pipeline): ProcessResult
161
    {
162 1
        return $pipeline->process($this->getMail());
163
    }
164
}