• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AJenbo / agcms / 21420560247

28 Jan 2026 12:59AM UTC coverage: 52.306% (-1.4%) from 53.72%
21420560247

push

github

AJenbo
Bump phpunit/phpunit from 9.6.11 to 9.6.33 in /application

Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.6.11 to 9.6.33.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/9.6.33/ChangeLog-9.6.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.6.11...9.6.33)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 9.6.33
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

3039 of 5810 relevant lines covered (52.31%)

12.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.67
/application/inc/Models/Email.php
1
<?php
2

3
namespace App\Models;
4

5
use App\Exceptions\InvalidInput;
6
use App\Services\DbService;
7
use App\Services\EmailService;
8

9
class Email extends AbstractEntity
10
{
11
    /**  Table name in database. */
12
    public const TABLE_NAME = 'emails';
13

14
    private EmailService $emailService;
15

16
    // Backed by DB
17

18
    /** @var string Subject */
19
    private string $subject = '';
20

21
    /** @var string HTML body */
22
    private string $body = '';
23

24
    /** @var string Semder name */
25
    private string $senderName = '';
26

27
    /** @var string Semder email address */
28
    private string $senderAddress = '';
29

30
    /** @var string Recipient name */
31
    private string $recipientName = '';
32

33
    /** @var string Recipient email address */
34
    private string $recipientAddress = '';
35

36
    private int $timestamp;
37

38
    public function __construct(array $data = [])
39
    {
40
        $this->emailService = app(EmailService::class);
6✔
41

42
        $this->setTimestamp(valint($data['timestamp'] ?? time()))
6✔
43
            ->setSubject(valstring($data['subject']))
6✔
44
            ->setBody(valstring($data['body']))
6✔
45
            ->setSenderName(valstring($data['senderName']))
6✔
46
            ->setSenderAddress(valstring($data['senderAddress']))
6✔
47
            ->setRecipientName(valstring($data['recipientName']))
6✔
48
            ->setRecipientAddress(valstring($data['recipientAddress']))
6✔
49
            ->setId(intOrNull($data['id'] ?? null));
6✔
50
    }
51

52
    /**
53
     * Set created time.
54
     *
55
     * @return $this
56
     */
57
    public function setTimestamp(int $timestamp): self
58
    {
59
        $this->timestamp = $timestamp;
6✔
60

61
        return $this;
6✔
62
    }
63

64
    /**
65
     * Get creation time.
66
     */
67
    public function getTimestamp(): int
68
    {
69
        return $this->timestamp;
×
70
    }
71

72
    /**
73
     * @throws InvalidInput
74
     *
75
     * @return $this
76
     */
77
    public function setSubject(string $subject): self
78
    {
79
        if (!$subject) {
6✔
80
            throw new InvalidInput(_('Subject required.'));
×
81
        }
82

83
        $this->subject = $subject;
6✔
84

85
        return $this;
6✔
86
    }
87

88
    public function getSubject(): string
89
    {
90
        return $this->subject;
6✔
91
    }
92

93
    /**
94
     * @throws InvalidInput
95
     *
96
     * @return $this
97
     */
98
    public function setBody(string $body): self
99
    {
100
        if (!$body) {
6✔
101
            throw new InvalidInput(_('Email body is required.'));
×
102
        }
103

104
        $this->body = $body;
6✔
105

106
        return $this;
6✔
107
    }
108

109
    public function getBody(): string
110
    {
111
        return $this->body;
6✔
112
    }
113

114
    /**
115
     * @throws InvalidInput
116
     *
117
     * @return $this
118
     */
119
    public function setSenderName(string $senderName): self
120
    {
121
        if (!$senderName) {
6✔
122
            throw new InvalidInput(_('Sender name required.'));
×
123
        }
124

125
        $this->senderName = $senderName;
6✔
126

127
        return $this;
6✔
128
    }
129

130
    public function getSenderName(): string
131
    {
132
        return $this->senderName;
4✔
133
    }
134

135
    /**
136
     * @throws InvalidInput
137
     *
138
     * @return $this
139
     */
140
    public function setSenderAddress(string $senderAddress): self
141
    {
142
        if (!$this->emailService->valideMail($senderAddress)) {
6✔
143
            throw new InvalidInput(_('Sender address is not valid.'));
×
144
        }
145

146
        $this->senderAddress = $senderAddress;
6✔
147

148
        return $this;
6✔
149
    }
150

151
    public function getSenderAddress(): string
152
    {
153
        return $this->senderAddress;
6✔
154
    }
155

156
    /**
157
     * @throws InvalidInput
158
     *
159
     * @return $this
160
     */
161
    public function setRecipientName(string $recipientName): self
162
    {
163
        if (!$recipientName) {
6✔
164
            throw new InvalidInput(_('Recipient name required.'));
×
165
        }
166

167
        $this->recipientName = $recipientName;
6✔
168

169
        return $this;
6✔
170
    }
171

172
    public function getRecipientName(): string
173
    {
174
        return $this->recipientName;
6✔
175
    }
176

177
    /**
178
     * @throws InvalidInput
179
     *
180
     * @return $this
181
     */
182
    public function setRecipientAddress(string $recipientAddress): self
183
    {
184
        if (!$this->emailService->valideMail($recipientAddress)) {
6✔
185
            throw new InvalidInput(_('Recipient address is not valid.'));
×
186
        }
187

188
        $this->recipientAddress = $recipientAddress;
6✔
189

190
        return $this;
6✔
191
    }
192

193
    public function getRecipientAddress(): string
194
    {
195
        return $this->recipientAddress;
6✔
196
    }
197

198
    // ORM related functions
199

200
    public static function mapFromDB(array $data): array
201
    {
202
        $from = explode('<', $data['from']);
×
203
        $senderAddress = mb_trim($from[0]);
×
204
        $senderName = mb_substr($from[1], 0, -1);
×
205

206
        $to = explode('<', $data['to']);
×
207
        $recipientAddress = mb_trim($to[0]);
×
208
        $recipientName = mb_substr($to[1], 0, -1);
×
209

210
        return [
×
211
            'id'               => $data['id'],
×
212
            'timestamp'        => strtotime($data['date']) + app(DbService::class)->getTimeOffset(),
×
213
            'subject'          => $data['subject'],
×
214
            'body'             => $data['body'],
×
215
            'senderName'       => $senderName,
×
216
            'senderAddress'    => $senderAddress,
×
217
            'recipientName'    => $recipientName,
×
218
            'recipientAddress' => $recipientAddress,
×
219
        ];
×
220
    }
221

222
    public function getDbArray(): array
223
    {
224
        $this->setTimestamp(time());
6✔
225

226
        $db = app(DbService::class);
6✔
227

228
        return [
6✔
229
            'date'    => $db->getNowValue(),
6✔
230
            'subject' => $db->quote($this->subject),
6✔
231
            'body'    => $db->quote($this->body),
6✔
232
            'from'    => $db->quote($this->senderAddress . '<' . $this->senderName . '>'),
6✔
233
            'to'      => $db->quote($this->recipientAddress . '<' . $this->recipientName . '>'),
6✔
234
        ];
6✔
235
    }
236
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc