__construct accesses the super-global variable $_ENV. Open
private function __construct()
{
$this->mailEngine = $_ENV['mail']['engine'];
$this->mailHost = $_ENV['mail']['host'];
$this->mailPort = $_ENV['mail']['port'];
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
__construct accesses the super-global variable $_ENV. Open
private function __construct()
{
$this->mailEngine = $_ENV['mail']['engine'];
$this->mailHost = $_ENV['mail']['host'];
$this->mailPort = $_ENV['mail']['port'];
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
__construct accesses the super-global variable $_ENV. Open
private function __construct()
{
$this->mailEngine = $_ENV['mail']['engine'];
$this->mailHost = $_ENV['mail']['host'];
$this->mailPort = $_ENV['mail']['port'];
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
__construct accesses the super-global variable $_ENV. Open
private function __construct()
{
$this->mailEngine = $_ENV['mail']['engine'];
$this->mailHost = $_ENV['mail']['host'];
$this->mailPort = $_ENV['mail']['port'];
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
__construct accesses the super-global variable $_ENV. Open
private function __construct()
{
$this->mailEngine = $_ENV['mail']['engine'];
$this->mailHost = $_ENV['mail']['host'];
$this->mailPort = $_ENV['mail']['port'];
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
__construct accesses the super-global variable $_ENV. Open
private function __construct()
{
$this->mailEngine = $_ENV['mail']['engine'];
$this->mailHost = $_ENV['mail']['host'];
$this->mailPort = $_ENV['mail']['port'];
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method corePHPMailer
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function corePHPMailer($options)
{
$options = null;
$this->mailHeaders[] = "MIME-Version: 1.0";
$this->mailHeaders[] = "Content-Type: ".$this->mailContentType;
Method setEngine
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function setEngine($engine, $host=null, $port=null, $user=null, $password=null, $encryption=null)
Function corePHPMailer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function corePHPMailer($options)
{
$options = null;
$this->mailHeaders[] = "MIME-Version: 1.0";
$this->mailHeaders[] = "Content-Type: ".$this->mailContentType;
- 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 using undefined variables such as '$options' which will lead to PHP notices. Open
$options['ssl']['verify_peer'] = false;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$options' which will lead to PHP notices. Open
->send($options);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using short method names like Mailer::cc(). The configured minimum method name length is 3. Open
public function cc($cc)
{
if(is_array($cc))
{
foreach ($cc as $copy)
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid using short method names like Mailer::to(). The configured minimum method name length is 3. Open
public function to($recipients)
{
if(is_array($recipients))
{
foreach ($recipients as $recipient)
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid variables with short names like $cc. Configured minimum length is 3. Open
public function cc($cc)
- Read upRead up
- 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;
}
}
}