GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Configuration::getRecipientOverride()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * @license https://github.com/f500/swiftmailer-sparkpost/blob/master/LICENSE Proprietary
5
 */
6
7
namespace SwiftSparkPost;
8
9
/**
10
 * @copyright Future500 B.V.
11
 * @author    Jasper N. Brouwer <[email protected]>
12
 */
13
final class Configuration
14
{
15
    use OptionsSanitizingCapabilities;
16
17
    /**
18
     * @var string
19
     */
20
    private $recipientOverride;
21
22
    /**
23
     * @var bool
24
     */
25
    private $overrideGmailStyle;
26
27
    /**
28
     * @var array
29
     */
30
    private $options;
31
32
    /**
33
     * @var float
34
     */
35
    private $ipPoolProbability;
36
37
    /**
38
     * @return Configuration
39
     */
40 63
    public static function newInstance()
41
    {
42 63
        return new self();
43
    }
44
45 102
    public function __construct()
46
    {
47 102
        $this->recipientOverride  = '';
48 102
        $this->overrideGmailStyle = false;
49 102
        $this->options            = [Option::TRANSACTIONAL => true];
50 102
        $this->ipPoolProbability  = 1.0;
51 102
    }
52
53 63
    public function overrideRecipients()
54
    {
55 63
        return $this->recipientOverride !== '';
56
    }
57
58
    /**
59
     * @return bool
60
     */
61 18
    public function overrideGmailStyle()
62
    {
63 18
        return $this->overrideGmailStyle;
64
    }
65
66
    /**
67
     * @param bool $overrideGmailStyle
68
     *
69
     * @return Configuration
70
     */
71 9
    public function setOverrideGmailStyle($overrideGmailStyle)
72
    {
73 9
        $this->overrideGmailStyle = (bool) $overrideGmailStyle;
74
75 9
        return $this;
76
    }
77
78
    /**
79
     * @return string
80
     */
81 21
    public function getRecipientOverride()
82
    {
83 21
        return $this->recipientOverride;
84
    }
85
86
    /**
87
     * @param string $recipientOverride
88
     *
89
     * @return Configuration
90
     * @throws Exception
91
     */
92 24
    public function setRecipientOverride($recipientOverride)
93
    {
94 24
        if (!$recipientOverride) {
95 3
            return $this;
96
        }
97
98 21
        if (!filter_var($recipientOverride, FILTER_VALIDATE_EMAIL)) {
99 3
            throw new Exception('Recipient override must be a valid email address');
100
        }
101
102 18
        $this->recipientOverride = (string) $recipientOverride;
103
104 18
        return $this;
105
    }
106
107
    /**
108
     * @return array
109
     */
110 66
    public function getOptions()
111
    {
112 66
        return $this->options;
113
    }
114
115
    /**
116
     * @param array $options
117
     *
118
     * @return Configuration
119
     */
120 27
    public function setOptions(array $options)
121
    {
122 27
        $this->options = array_merge(
123 27
            $this->options,
124 27
            $this->sanitizeOptions($options)
125 8
        );
126
127 24
        return $this;
128
    }
129
130
    /**
131
     * @return float
132
     */
133 63
    public function getIpPoolProbability()
134
    {
135 63
        return $this->ipPoolProbability;
136
    }
137
138
    /**
139
     * @param float $ipPoolProbability
140
     *
141
     * @return Configuration
142
     * @throws Exception
143
     */
144 18
    public function setIpPoolProbability($ipPoolProbability)
145
    {
146 18
        if ($ipPoolProbability < 0 || $ipPoolProbability > 1) {
147 6
            throw new Exception('IP pool probability must be between 0 and 1');
148
        }
149
150 12
        $this->ipPoolProbability = (float) $ipPoolProbability;
151
152 12
        return $this;
153
    }
154
}
155