YetiForceCompany/YetiForceCRM

View on GitHub
app/Mail/ScannerAction/Base.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid assigning values to variables in if clauses and the like (line '59', column '7').
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')];
Severity: Minor
Found in app/Mail/ScannerAction/Base.php by phpmd

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

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * Action priority.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    protected $scannerEngine;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $priority = 9;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var \App\Mail\ScannerEngine\Base

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * Constructor.

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->scannerEngine = $scannerEngine;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

            $mailForExceptions = (0 === $this->scannerEngine->getMailType()) ? $this->scannerEngine->get('to_email') : [$this->scannerEngine->get('from_email')];

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param \App\Mail\ScannerEngine\Base $scannerEngine

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $type

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($exceptions = $this->scannerEngine->getExceptions()[$type] ?? false) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var int

Spaces must be used to indent lines; tabs are not allowed
Open

    public function __construct(\App\Mail\ScannerEngine\Base $scannerEngine)

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return void

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Scanner engine instance.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check exceptions.

Spaces must be used to indent lines; tabs are not allowed
Open

    public function checkExceptions(string $type): bool

Spaces must be used to indent lines; tabs are not allowed
Open

        return $return;

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Line exceeds 120 characters; contains 161 characters
Open

            $mailForExceptions = (0 === $this->scannerEngine->getMailType()) ? $this->scannerEngine->get('to_email') : [$this->scannerEngine->get('from_email')];

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

        $return = false;

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

            $return = (bool) array_intersect($exceptions, $mailForExceptions);

Spaces must be used to indent lines; tabs are not allowed
Open

     * Main function to execute action.

Spaces must be used to indent lines; tabs are not allowed
Open

    abstract public function process(): void;

There are no issues that match your filters.

Category
Status