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.

Nip_Mailer::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 3
nop 0
dl 0
loc 18
ccs 0
cts 11
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
class Nip_Mailer
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
    protected $_mail;
7
8
    public function __construct()
9
    {
10
        $this->_mail = new PHPMailer();
11
        $this->_mail->CharSet = "UTF-8";
12
//		$this->_mail->SMTPDebug = true;
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
13
14
        $config = Nip_Config::instance()->parse(CONFIG_PATH.'smtp.ini');
15
        if ($config->SMTP->host) {
16
            $this->_mail->IsSMTP();
17
            if ($config->SMTP->username) {
18
                $this->authSMTP($config->SMTP->host, $config->SMTP->username, $config->SMTP->password);
19
            } else {
20
                $this->_mail->Host = $config->SMTP->host;
21
            }
22
        }
23
24
        $this->setFrom($config->EMAIL->from, $config->EMAIL->from_name);
25
    }
26
27
    /**
28
     * @param string $host
29
     * @param string $username
30
     * @param string $password
31
     * @return $this
32
     */
33
    public function authSMTP($host, $username, $password)
34
    {
35
        $this->_mail->IsSMTP();
36
37
        $this->_mail->SMTPAuth = true;
38
        $this->_mail->Host = $host;
39
        $this->_mail->Username = $username;
40
        $this->_mail->Password = $password;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @param string $address
47
     * @param string|bool $name
48
     * @return $this
49
     */
50
    public function setFrom($address, $name = false)
51
    {
52
        $this->_mail->From = $address;
53
        if ($name) {
54
            $this->_mail->FromName = $name;
55
        }
56
57
        return $this;
58
    }
59
60
    public function IsHTML($bool)
61
    {
62
        $this->_mail->IsHTML($bool);
63
    }
64
65
    /**
66
     * Sets flag to show SMTP debugging information
67
     * @return $this
68
     */
69
    public function debugSMTP()
70
    {
71
        $this->_mail->SMTPDebug = PHP_INT_MAX;
72
73
        return $this;
74
    }
75
76
    /**
77
     * @param string $address
78
     * @param string|bool $name
79
     * @return $this
80
     */
81
    public function addTo($address, $name = false)
82
    {
83
        $this->_mail->AddAddress($address, $name);
84
85
        return $this;
86
    }
87
88
    /**
89
     * @param string $address
90
     * @param string $name
91
     * @return $this
92
     */
93
    public function addBCC($address, $name = '')
94
    {
95
        $this->_mail->AddBCC($address, $name);
96
97
        return $this;
98
    }
99
100
    /**
101
     * @param string $address
102
     * @param string $name
103
     * @return $this
104
     */
105
    public function addReplyTo($address, $name = false)
106
    {
107
        $this->_mail->AddReplyTo($address, $name);
108
109
        return $this;
110
    }
111
112
    /**
113
     * @return $this
114
     */
115
    public function clearAllRecipients()
116
    {
117
        $this->_mail->ClearAllRecipients();
118
119
        return $this;
120
    }
121
122
    /**
123
     * @param string $subject
124
     * @return $this
125
     */
126
    public function setSubject($subject)
127
    {
128
        $this->_mail->Subject = $subject;
129
130
        return $this;
131
    }
132
133
    /**
134
     * Adds attachment
135
     *
136
     * @param string $path
137
     * @param string $name
138
     * @return $this
139
     */
140
    public function addAttachment($path, $name = '')
141
    {
142
        $this->_mail->AddAttachment($path, $name);
143
144
        return $this;
145
    }
146
147
    public function send()
148
    {
149
        $return = $this->_mail->Send();
150
151
        if (!$return) {
152
            $return = $this->_mail->ErrorInfo;
153
        }
154
155
        return $return;
156
    }
157
158
159
    public function setBody($body)
160
    {
161
        $this->_mail->Body = $body;
162
163
        return $this;
164
    }
165
166
    public function getBody()
167
    {
168
        return $this->_mail->Body;
169
    }
170
171
    public function setAltBody($body)
172
    {
173
        $this->_mail->AltBody = $body;
174
175
        return $this;
176
    }
177
178
}