Completed
Push — master ( 6ffc3f...4609e3 )
by Antonio
51:14 queued 46:44
created

EmailTrait::getEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-qrcode-component 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 http://www.ramirezcobos.com/
23
 * @link http://www.2amigos.us/
24
 * @package dosamigos\qrcode\traits
25
 */
26
trait EmailTrait
27
{
28
    /**
29
     * @var string a valid email
30
     */
31
    protected $email;
32
33
    /**
34
     * @param string $value the email
35
     *
36
     * @throws InvalidConfigException
37
     */
38
    public function setEmail($value)
39
    {
40
        $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...
41
42
        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
43
            throw new InvalidConfigException('Email seems incorrect.');
44
        }
45
46
        $this->email = $value;
47
    }
48
49
    /**
50
     * @return string the email
51
     */
52
    public function getEmail()
53
    {
54
        return $this->email;
55
    }
56
}
57