EmailTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 31
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setEmail() 0 10 2
A getEmail() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/qrcode-library project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\QrCode\Traits;
13
14
use Da\QrCode\Exception\InvalidConfigException;
15
16
/**
17
 * EmailTrait
18
 *
19
 * Provides methods to handle the email property
20
 *
21
 * @author Antonio Ramirez <[email protected]>
22
 * @link https://www.2amigos.us/
23
 * @package dosamigos\qrcode\traits
24
 */
25
trait EmailTrait
26
{
27
    /**
28
     * @var string a valid email
29
     */
30
    private $email;
31
32
    /**
33
     * @param string $value the email
34
     *
35
     * @throws InvalidConfigException
36
     */
37
    public function setEmail(string $value): void
38
    {
39
        $error = null;
0 ignored issues
show
Unused Code introduced by
$error is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
40
41
        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
42
            throw new InvalidConfigException('Email seems incorrect.');
43
        }
44
45
        $this->email = $value;
46
    }
47
48
    /**
49
     * @return string the email
50
     */
51
    public function getEmail(): string
52
    {
53
        return $this->email;
54
    }
55
}
56