Internal   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 30
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canUseService() 0 3 1
A systemServiceId() 0 3 1
A sendEmail() 0 8 2
1
<?php
2
3
namespace kalanis\EmailApi\Services;
4
5
6
use kalanis\EmailApi\Interfaces;
7
use kalanis\EmailApi\Basics;
8
9
10
/**
11
 * Class Internal
12
 * Make and send each mail
13
 */
14
class Internal implements Interfaces\ISending
15
{
16 1
    public function canUseService(): bool
17
    {
18 1
        return true;
19
    }
20
21 1
    public function systemServiceId(): int
22
    {
23 1
        return 1;
24
    }
25
26
    /**
27
     * Send mail directly via php - no hurdles anywhere, no security too
28
     *
29
     * @param Interfaces\IContent $content
30
     * @param Interfaces\IEmailUser $to
31
     * @param Interfaces\IEmailUser $from
32
     * @param Interfaces\IEmailUser $replyTo
33
     * @param bool $toDisabled
34
     * @return Basics\Result
35
     */
36 1
    public function sendEmail(Interfaces\IContent $content, Interfaces\IEmailUser $to, ?Interfaces\IEmailUser $from = null, ?Interfaces\IEmailUser $replyTo = null, $toDisabled = false): Basics\Result
37
    {
38 1
        if (!empty($content->getAttachments())) {
39 1
            return new Basics\Result(false, 'No attachments available for simple mailing');
40
        }
41
        // @codeCoverageIgnoreStart
42
        $result = mail($to->getEmail(), $content->getSubject(), $content->getHtmlBody());
43
        return new Basics\Result(boolval($result), strval($result));
44
        // @codeCoverageIgnoreEnd
45
    }
46
}
47