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.
Completed
Push — master ( f1190a...dffc02 )
by Jasper
05:53 queued 03:20
created

Configuration::overrideGmailStyle()   A

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 60
    public static function newInstance()
41
    {
42 60
        return new self();
43
    }
44
45 96
    public function __construct()
46
    {
47 96
        $this->recipientOverride  = '';
48 96
        $this->overrideGmailStyle = false;
49 96
        $this->options            = [Option::TRANSACTIONAL => true];
50 96
        $this->ipPoolProbability  = 1.0;
51 96
    }
52
53 60
    public function overrideRecipients()
54
    {
55 60
        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 18
    public function getRecipientOverride()
82
    {
83 18
        return $this->recipientOverride;
84
    }
85
86
    /**
87
     * @param string $recipientOverride
88
     *
89
     * @return Configuration
90
     * @throws Exception
91
     */
92 21
    public function setRecipientOverride($recipientOverride)
93
    {
94 21
        if (!filter_var($recipientOverride, FILTER_VALIDATE_EMAIL)) {
95 3
            throw new Exception('Recipient override must be a valid email address');
96
        }
97
98 18
        $this->recipientOverride = (string) $recipientOverride;
99
100 18
        return $this;
101
    }
102
103
    /**
104
     * @return array
105
     */
106 63
    public function getOptions()
107
    {
108 63
        return $this->options;
109
    }
110
111
    /**
112
     * @param array $options
113
     *
114
     * @return Configuration
115
     */
116 27
    public function setOptions(array $options)
117
    {
118 27
        $this->options = array_merge(
119 27
            $this->options,
120 27
            $this->sanitizeOptions($options)
121
        );
122
123 24
        return $this;
124
    }
125
126
    /**
127
     * @return float
128
     */
129 60
    public function getIpPoolProbability()
130
    {
131 60
        return $this->ipPoolProbability;
132
    }
133
134
    /**
135
     * @param float $ipPoolProbability
136
     *
137
     * @return Configuration
138
     * @throws Exception
139
     */
140 18
    public function setIpPoolProbability($ipPoolProbability)
141
    {
142 18
        if ($ipPoolProbability < 0 || $ipPoolProbability > 1) {
143 6
            throw new Exception('IP pool probability must be between 0 and 1');
144
        }
145
146 12
        $this->ipPoolProbability = (float) $ipPoolProbability;
147
148 12
        return $this;
149
    }
150
}
151