Completed
Push — master ( cafe6d...6b87b2 )
by Adam
07:21 queued 01:33
created

MailerConfiguration::getEncrypt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CoreBundle\Entity;
14
15
/**
16
 * Class MailerConfiguration
17
 *
18
 * @author  Adam Piotrowski <[email protected]>
19
 */
20
class MailerConfiguration
21
{
22
    protected $from = '';
23
    protected $host = '';
24
    protected $port = 587;
25
    protected $encrypt = 'tls';
26
    protected $user = '';
27
    protected $pass = '';
28
    protected $bcc  = '';
29
    
30
    public function getFrom(): string
31
    {
32
        return $this->from;
33
    }
34
    
35
    public function setFrom(string $from)
36
    {
37
        $this->from = $from;
38
    }
39
    
40
    public function getHost(): string
41
    {
42
        return $this->host;
43
    }
44
    
45
    public function setHost(string $host)
46
    {
47
        $this->host = $host;
48
    }
49
    
50
    public function getPort(): int
51
    {
52
        return $this->port;
53
    }
54
    
55
    public function setPort(int $port)
56
    {
57
        $this->port = $port;
58
    }
59
    
60
    public function getUser(): string
61
    {
62
        return $this->user;
63
    }
64
    
65
    public function setUser(string $user)
66
    {
67
        $this->user = $user;
68
    }
69
    
70
    public function getPass(): string
71
    {
72
        return $this->pass;
73
    }
74
    
75
    public function setPass(string $pass)
76
    {
77
        $this->pass = $pass;
78
    }
79
    
80
    public function getBcc(): string
81
    {
82
        return $this->bcc;
83
    }
84
    
85
    public function setBcc(string $bcc)
86
    {
87
        $this->bcc = $bcc;
88
    }
89
90
    public function getEncrypt() : mixed
91
    {
92
        return $this->encrypt;
93
    }
94
95
    public function setEncrypt(string $encrypt = null)
96
    {
97
        if(!$encrypt or ($encrypt != 'ssl' and $encrypt != 'tls')){
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as or instead of || is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
Comprehensibility Best Practice introduced by
Using logical operators such as and instead of && is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
98
            $encrypt = null;
99
        }
100
101
        $this->encrypt = $encrypt;
102
    }
103
104
105
}
106