app/Mail/ScannerAction/Base.php
Avoid assigning values to variables in if clauses and the like (line '59', column '7'). Open
Open
public function checkExceptions(string $type): bool
{
$return = false;
if ($exceptions = $this->scannerEngine->getExceptions()[$type] ?? false) {
$mailForExceptions = (0 === $this->scannerEngine->getMailType()) ? $this->scannerEngine->get('to_email') : [$this->scannerEngine->get('from_email')];
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Action priority.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected $scannerEngine;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public static $priority = 9;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var \App\Mail\ScannerEngine\Base
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->scannerEngine = $scannerEngine;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$mailForExceptions = (0 === $this->scannerEngine->getMailType()) ? $this->scannerEngine->get('to_email') : [$this->scannerEngine->get('from_email')];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param \App\Mail\ScannerEngine\Base $scannerEngine
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($exceptions = $this->scannerEngine->getExceptions()[$type] ?? false) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function __construct(\App\Mail\ScannerEngine\Base $scannerEngine)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Scanner engine instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Check exceptions.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function checkExceptions(string $type): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Line exceeds 120 characters; contains 161 characters Open
Open
$mailForExceptions = (0 === $this->scannerEngine->getMailType()) ? $this->scannerEngine->get('to_email') : [$this->scannerEngine->get('from_email')];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$return = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$return = (bool) array_intersect($exceptions, $mailForExceptions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Main function to execute action.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
abstract public function process(): void;
- Exclude checks