Internal::systemServiceId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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