Mail   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 24
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
1
<?php
2
3
/**
4
 * This file is part of the Apix Project.
5
 *
6
 * (c) Franck Cassedanne <franck at ouarz.net>
7
 *
8
 * @license http://opensource.org/licenses/BSD-3-Clause  New BSD License
9
 */
10
11
namespace Apix\Log\Logger;
12
13
use Psr\Log\InvalidArgumentException;
14
15
/**
16
 * Minimalist mail based PSR-3 logger relying on PHP's error_log().
17
 *
18
 * @author Franck Cassedanne <franck at ouarz.net>
19
 */
20
class Mail extends ErrorLog
21
{
22
23
    /**
24
     * Constructor.
25
     *
26
     * @param  string      $email   The email to append to.
27
     * @param  string|null $headers A string of additional (mail) headers.
28
     * @throws Psr\Log\InvalidArgumentException If the email does not validate.
29
     */
30 12
    public function __construct($email, $headers = null)
31
    {
32 12
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
33 8
            throw new InvalidArgumentException(
34 8
                sprintf('"%s" is an invalid email address', $email)
35 2
            );
36
        }
37
38 4
        $this->destination = $email;
39 4
        $this->type = static::MAIL;
40 4
        $this->headers = (string) $headers;
41 1
    }
42
43
}
44