Function mail_decode_part
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function mail_decode_part($connection, $message_number, $part, $prefix)
{
$attachment = array();
if ($part->ifdparameters) {
- Read upRead up
- Create a ticketCreate a ticket
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 getAllWebfiles
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAllWebfiles()
{
$webfileArray = array();
- Create a ticketCreate a ticket
Method mail_decode_part
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function mail_decode_part($connection, $message_number, $part, $prefix)
{
$attachment = array();
if ($part->ifdparameters) {
- Create a ticketCreate a ticket
Method imap_login
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function imap_login($host, $port, $user, $pass, $folder = "INBOX", $ssl = false)
- Create a ticketCreate a ticket
The method mail_mime_to_array has a boolean flag argument $parse_headers, which is a certain sign of a Single Responsibility Principle violation. Open
private function mail_mime_to_array($imap, $mid, $parse_headers = false)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method imap_login has a boolean flag argument $ssl, which is a certain sign of a Single Responsibility Principle violation. Open
private function imap_login($host, $port, $user, $pass, $folder = "INBOX", $ssl = false)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid unused private methods such as 'mail_get_parts'. Open
private function mail_get_parts($imap, $mid, $part, $prefix)
{
$attachments = array();
$attachments[$prefix] = mail_decode_part($imap, $mid, $part, $prefix);
if (isset($part->parts)) // multipart
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
Avoid unused private methods such as 'pop3_stat'. Open
private function pop3_stat($connection)
{
$check = imap_mailboxmsginfo($connection);
return ((array)$check);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
Avoid unused private methods such as 'pop3_retr'. Open
private function pop3_retr($connection, $message)
{
return (imap_fetchheader($connection, $message, FT_PREFETCHTEXT));
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
Avoid unused private methods such as 'mail_parse_headers'. Open
private function mail_parse_headers($headers)
{
$result = array();
$headers = preg_replace('/\r\n\s+/m', '', $headers);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
Avoid unused private methods such as 'mail_mime_to_array'. Open
private function mail_mime_to_array($imap, $mid, $parse_headers = false)
{
$mail = imap_fetchstructure($imap, $mid);
$mail = mail_get_parts($imap, $mid, $mail, 0);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
Avoid unused private methods such as 'mail_decode_part'. Open
private function mail_decode_part($connection, $message_number, $part, $prefix)
{
$attachment = array();
if ($part->ifdparameters) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
Avoid unused parameters such as '$count'. Open
public function getLatestWebfiles($count = 5)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused private methods such as 'pop3_dele'. Open
private function pop3_dele($connection, $message)
{
return (imap_delete($connection, $message));
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
Avoid excessively long variable names like $completeNumberOfMessages. Keep variable name length under 20. Open
$completeNumberOfMessages = $MC->Nmsgs;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $numberOfMessagesToShow. Keep variable name length under 20. Open
$numberOfMessagesToShow = 4;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
The parameter $parse_headers is not named in camelCase. Open
private function mail_mime_to_array($imap, $mid, $parse_headers = false)
{
$mail = imap_fetchstructure($imap, $mid);
$mail = mail_get_parts($imap, $mid, $mail, 0);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $message_number is not named in camelCase. Open
private function mail_decode_part($connection, $message_number, $part, $prefix)
{
$attachment = array();
if ($part->ifdparameters) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Avoid variables with short names like $MC. Configured minimum length is 3. Open
$MC = imap_check($this->connection);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $m_oMailAccount is not named in camelCase. Open
class MImapDatastore extends MAbstractDatastore
implements MISingleDatasourceDatastore
{
/**@var MMailAccount **/
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The variable $parse_headers is not named in camelCase. Open
private function mail_mime_to_array($imap, $mid, $parse_headers = false)
{
$mail = imap_fetchstructure($imap, $mid);
$mail = mail_get_parts($imap, $mid, $mail, 0);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $message_number is not named in camelCase. Open
private function mail_decode_part($connection, $message_number, $part, $prefix)
{
$attachment = array();
if ($part->ifdparameters) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $MC is not named in camelCase. Open
private function imap_getlist()
{
$result = array();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $MC is not named in camelCase. Open
private function imap_getlist()
{
$result = array();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method imap_login is not named in camelCase. Open
private function imap_login($host, $port, $user, $pass, $folder = "INBOX", $ssl = false)
{
$ssl = ($ssl == false) ? "/novalidate-cert" : "/ssl";
return (imap_open("{" . "$host:$port/imap4$ssl" . "}$folder", $user, $pass));
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method pop3_stat is not named in camelCase. Open
private function pop3_stat($connection)
{
$check = imap_mailboxmsginfo($connection);
return ((array)$check);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method imap_getlist is not named in camelCase. Open
private function imap_getlist()
{
$result = array();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method mail_decode_part is not named in camelCase. Open
private function mail_decode_part($connection, $message_number, $part, $prefix)
{
$attachment = array();
if ($part->ifdparameters) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method pop3_dele is not named in camelCase. Open
private function pop3_dele($connection, $message)
{
return (imap_delete($connection, $message));
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method mail_parse_headers is not named in camelCase. Open
private function mail_parse_headers($headers)
{
$result = array();
$headers = preg_replace('/\r\n\s+/m', '', $headers);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method pop3_retr is not named in camelCase. Open
private function pop3_retr($connection, $message)
{
return (imap_fetchheader($connection, $message, FT_PREFETCHTEXT));
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method mail_get_parts is not named in camelCase. Open
private function mail_get_parts($imap, $mid, $part, $prefix)
{
$attachments = array();
$attachments[$prefix] = mail_decode_part($imap, $mid, $part, $prefix);
if (isset($part->parts)) // multipart
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method mail_mime_to_array is not named in camelCase. Open
private function mail_mime_to_array($imap, $mid, $parse_headers = false)
{
$mail = imap_fetchstructure($imap, $mid);
$mail = mail_get_parts($imap, $mid, $mail, 0);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}