File class-phpmailer.php
has 1118 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*~ class.phpmailer.php
.---------------------------------------------------------------------------.
| Software: PHPMailer - PHP email class |
| Version: 2.0.4 |
PHPMailer
has 63 functions (exceeds 20 allowed). Consider refactoring. Open
class PHPMailer {
/////////////////////////////////////////////////
// PROPERTIES, PUBLIC
/////////////////////////////////////////////////
Function WrapText
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
function WrapText($message, $length, $qp_mode = false) {
$soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
// If utf-8 encoding is used, we will need to make sure we don't
// split multibyte characters when we wrap
$is_utf8 = (strtolower($this->CharSet) == "utf-8");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function EncodeQP
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
$lines = preg_split('/(?:\r\n|\r|\n)/', $input);
$eol = "\r\n";
$escape = '=';
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method _mime_types
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _mime_types($ext = '') {
$mimes = array(
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
Function MailSend
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function MailSend($header, $body) {
$to = '';
for($i = 0; $i < count($this->to); $i++) {
if($i != 0) { $to .= ', '; }
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function MsgHTML
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function MsgHTML($message,$basedir='') {
preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
if(isset($images[2])) {
foreach($images[2] as $i => $url) {
// do not change urls for absolute images (thanks to corvuscorax)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function SmtpSend
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function SmtpSend($header, $body) {
include_once($this->PluginDir . 'class-smtp.php');
$error = '';
$bad_rcpt = array();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function SmtpConnect
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function SmtpConnect() {
if($this->smtp == NULL) {
$this->smtp = new SMTP();
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function CreateHeader
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function CreateHeader() {
$result = '';
/* Set the boundaries */
$uniq_id = md5(uniqid(time()));
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method WrapText
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
function WrapText($message, $length, $qp_mode = false) {
$soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
// If utf-8 encoding is used, we will need to make sure we don't
// split multibyte characters when we wrap
$is_utf8 = (strtolower($this->CharSet) == "utf-8");
Method CreateBody
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function CreateBody() {
$result = '';
if ($this->sign_key_file) {
$result .= $this->GetMailMIME();
}
Function CreateBody
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function CreateBody() {
$result = '';
if ($this->sign_key_file) {
$result .= $this->GetMailMIME();
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method SmtpSend
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SmtpSend($header, $body) {
include_once($this->PluginDir . 'class-smtp.php');
$error = '';
$bad_rcpt = array();
Method CreateHeader
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function CreateHeader() {
$result = '';
/* Set the boundaries */
$uniq_id = md5(uniqid(time()));
Function AttachAll
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function AttachAll() {
/* Return text of body */
$mime = array();
/* Add all attachments */
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function EncodeHeader
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function EncodeHeader ($str, $position = 'text') {
$x = 0;
switch (strtolower($position)) {
case 'phrase':
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method EncodeHeader
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function EncodeHeader ($str, $position = 'text') {
$x = 0;
switch (strtolower($position)) {
case 'phrase':
Method EncodeQP
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
$lines = preg_split('/(?:\r\n|\r|\n)/', $input);
$eol = "\r\n";
$escape = '=';
Method AttachAll
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function AttachAll() {
/* Return text of body */
$mime = array();
/* Add all attachments */
Method SmtpConnect
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SmtpConnect() {
if($this->smtp == NULL) {
$this->smtp = new SMTP();
}
Method MailSend
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function MailSend($header, $body) {
$to = '';
for($i = 0; $i < count($this->to); $i++) {
if($i != 0) { $to .= ', '; }
Method Send
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Send() {
$header = '';
$body = '';
$result = true;
Method MsgHTML
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function MsgHTML($message,$basedir='') {
preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
if(isset($images[2])) {
foreach($images[2] as $i => $url) {
// do not change urls for absolute images (thanks to corvuscorax)
Function SetMessageType
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function SetMessageType() {
if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
$this->message_type = 'plain';
} else {
if(count($this->attachment) > 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function UTF8CharBoundary
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function UTF8CharBoundary($encodedText, $maxLength) {
$foundSplitPos = false;
$lookBack = 3;
while (!$foundSplitPos) {
$lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function Send
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function Send() {
$header = '';
$body = '';
$result = true;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method AddEmbeddedImage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
Function EncodeString
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function EncodeString ($str, $encoding = 'base64') {
$encoded = '';
switch(strtolower($encoding)) {
case 'base64':
/* chunk_split is found in PHP >= 3.0.6 */
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function GetMailMIME
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function GetMailMIME() {
$result = '';
switch($this->message_type) {
case 'plain':
$result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return true;