Method logBackTrace
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function logBackTrace($msg, $line = '', $file = '')
{
$backtrace = (function_exists('debug_backtrace') ? debug_backtrace() : []);
$this->log(
('' !== getenv('REQUEST_URI') ? ' '.getenv('REQUEST_URI') : '').
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($database = '', $user = '', $password = '', $host = 'localhost', $query = '', $port = '')
Method limitQuery
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function limitQuery($queryString, $numRows = '', $offset = 0, $line = '', $file = '')
Function fromTimestamp
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function fromTimestamp($timestamp)
{
if (preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})/', $timestamp, $parts)) {
$time = mktime($parts[4], $parts[5], $parts[6], $parts[2], $parts[3], $parts[1]);
} elseif (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $timestamp, $parts)) {
- 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 logBackTrace
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function logBackTrace($msg, $line = '', $file = '')
{
$backtrace = (function_exists('debug_backtrace') ? debug_backtrace() : []);
$this->log(
('' !== getenv('REQUEST_URI') ? ' '.getenv('REQUEST_URI') : '').
- 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
Missing class import via use statement (line '328', column '18'). Open
(new \MyAdmin\Mail())->adminMail($subject, $email, 'john@interserver.net', '');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '329', column '18'). Open
(new \MyAdmin\Mail())->adminMail($subject, $email, 'detain@interserver.net', '');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '314', column '27'). Open
$smarty = new \TFSmarty();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method halt() contains an exit expression. Open
die();
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method real_escape is not named in camelCase. Open
public function real_escape($string = '')
{
if ((!is_resource($this->linkId) || $this->linkId == 0) && !$this->connect()) {
return $this->escape($string);
}
- Read upRead up
- 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() {
}
}