Test Failed
Push — master ( 4112a3...6b8d5c )
by Florian
05:27
created

LogMailer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A send() 0 5 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Copyright (c) Phauthentic (https://github.com/Phauthentic)
5
 *
6
 * Licensed under The MIT License
7
 * For full copyright and license information, please see the LICENSE.txt
8
 * Redistributions of files must retain the above copyright notice.
9
 *
10
 * @copyright     Copyright (c) Phauthentic (https://github.com/Phauthentic)
11
 * @link          https://github.com/Phauthentic
12
 * @license       https://opensource.org/licenses/mit-license.php MIT License
13
 */
14
namespace Phauthentic\Email\Mailer;
15
16
use Phauthentic\Email\EmailInterface;
17
use Psr\Log\LoggerInterface;
18
use Psr\Log\LogLevel;
19
20
/**
21
 * Doesn't send emails but logs them instead
22
 */
23
class LogMailer implements MailerInterface
24
{
25
    /**
26
     * Logger
27
     *
28
     * @var \Psr\Log\LoggerInterface
29
     */
30
    protected $Logger;
31
32
    /**
33
     * Log Level
34
     *
35
     * @var string
36
     */
37
    protected $logLevel;
38
39
    /**
40
     * Constructor
41
     *
42
     * @param \Psr\Log\LoggerInterface
43
     */
44
    public function __construct(
45
        LoggerInterface $logger,
0 ignored issues
show
Unused Code introduced by
The parameter $logger is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

45
        /** @scrutinizer ignore-unused */ LoggerInterface $logger,

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
        $logLevel = LogLevel::INFO
47
    ) {
48
        $this->Logger;
49
        $this->logLevel = $logLevel;
50
    }
51
52
    /**
53
     * @inheritDoc
54
     */
55
    public function send(EmailInterface $email): bool
56
    {
57
        $this->Logger->log($this->logLevel, $email);
0 ignored issues
show
Bug introduced by
$email of type Phauthentic\Email\EmailInterface is incompatible with the type string expected by parameter $message of Psr\Log\LoggerInterface::log(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

57
        $this->Logger->log($this->logLevel, /** @scrutinizer ignore-type */ $email);
Loading history...
58
59
        return true;
60
    }
61
}
62