MailLiftMessage   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 87
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A __construct() 0 4 1
A body() 0 6 1
A sender() 0 6 1
A scheduleDelivery() 0 10 2
A toArray() 0 8 1
1
<?php
2
3
namespace NotificationChannels\MailLift;
4
5
use DateTime;
6
7
class MailLiftMessage
8
{
9
    /** @var string */
10
    protected $body;
11
12
    /** @var string */
13
    protected $sender;
14
15
    /** @var string|null */
16
    protected $scheduledDelivery;
17
18
    /**
19
     * @param string $body
20
     *
21
     * @return static
22
     */
23 3
    public static function create($body)
24
    {
25 3
        return new static($body);
26
    }
27
28
    /**
29
     * @param string $body
30
     */
31 8
    public function __construct($body)
32
    {
33 8
        $this->body = $body;
34 8
    }
35
36
    /**
37
     * Set the letter message body.
38
     *
39
     * @param $body
40
     *
41
     * @return $this
42
     */
43 1
    public function body($body)
44
    {
45 1
        $this->body = $body;
46
47 1
        return $this;
48
    }
49
50
    /**
51
     * Set the letter message sender.
52
     *
53
     * @param $sender
54
     *
55
     * @return $this
56
     */
57 3
    public function sender($sender)
58
    {
59 3
        $this->sender = $sender;
60
61 3
        return $this;
62
    }
63
64
    /**
65
     * Set the scheduled delivery date.
66
     *
67
     * @param string|DateTime $scheduledDelivery
68
     *
69
     * @return $this
70
     */
71 2
    public function scheduleDelivery($scheduledDelivery)
72
    {
73 2
        if (! $scheduledDelivery instanceof DateTime) {
74 1
            $scheduledDelivery = new DateTime($scheduledDelivery);
75 1
        }
76
77 2
        $this->scheduledDelivery = $scheduledDelivery->format('Y-m-d');
78
79 2
        return $this;
80
    }
81
82
    /**
83
     * @return array
84
     */
85 8
    public function toArray()
86
    {
87
        return [
88 8
            'MessageBody' => $this->body,
89 8
            'Sender' => $this->sender,
90 8
            'ScheduledDelivery' => $this->scheduledDelivery,
91 8
        ];
92
    }
93
}
94