YetiForceCompany/YetiForceCRM

View on GitHub
app/Process.php

Summary

Maintainability
A
0 mins
Test Coverage
B
81%

Avoid using static access to class 'App\Session' in method 'init'.
Open

        self::$events = Session::get('processEvents') ?? [];
Severity: Minor
Found in app/Process.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'App\Session' in method 'writeSession'.
Open

        Session::set('processEvents', self::$events);
Severity: Minor
Found in app/Process.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Define a constant instead of duplicating this literal "priority" 3 times.
Open

        if (empty($event['priority'])) {
Severity: Critical
Found in app/Process.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "execution" 3 times.
Open

        if (empty($event['execution'])) {
Severity: Critical
Found in app/Process.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Spaces must be used for alignment; tabs are not allowed
Open

     * ]);
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    public static function addEvent(array $event): void
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * @return array
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    public static function getEvents(): array
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        $priority = array_column($events, 'priority');
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    'execution' => 'once',
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    'type' => 'notify',
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        if (empty($event['execution'])) {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    'execution' => 'once',
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        self::writeSession();
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            throw new Exceptions\AppException('Incorrect data');
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * @param string $name
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        return isset(self::$events[$name]);
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        if ($writeSession) {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    'notify' => [
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *        'text' => 'test',
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        $events = [];
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    'type' => 'notify',
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *        'text' => 'test',
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            self::writeSession();
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *        'type' => 'info' // alert, notice, info, success, error
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    ]
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * @return void
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * Get events.
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        foreach (self::$events as $name => $row) {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

                unset(self::$events[$name]);
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * alert, notice, info, success, error
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            $event['priority'] = 5;
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * Remove event.
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * Write session data.
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * @return void
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    private static function writeSession(): void
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        if (empty($event['name']) || empty($event['type'])) {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        if (empty($event['priority'])) {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    public static function removeEvent(string $name): void
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        if (isset(self::$events[$name])) {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            if ('once' === $row['execution']) {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    ]
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        self::$events[$event['name']] = $event;
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        return $events;
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *        'type' => 'info' // alert, notice, info, success, error
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            unset(self::$events[$name]);
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * Has event.
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * @param array $event
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    'notify' => [
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            $event['execution'] = 'constant';
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            $events[] = $row;
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        array_multisort($priority, SORT_DESC, $events);
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        Session::set('processEvents', self::$events);
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * @param string $name
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    public static function hasEvent(string $name): bool
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

                $writeSession = true;
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     *    'name' => 'notify test',
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

     * @return void
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

            self::writeSession();
Severity: Minor
Found in app/Process.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

        $writeSession = false;
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * @var string
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    public static $startTime;
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    public static $requestMode;
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * CRM root directory.
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * Request process type.
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * @var string
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * Request start time.
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * @var int
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    public static $rootDirectory;
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * Request mode.
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    public static $processType;
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * Request process name.
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    public static $processName;
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * @var string
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *    'name' => 'notify test',
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * Add event.
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    public static function init(): void
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * @var string
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

        self::$events = Session::get('processEvents') ?? [];
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    private static $events = [];
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * App\Process::addEvent([
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * List of events.
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * @var array
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * Initialization of events.
Severity: Minor
Found in app/Process.php by phpcodesniffer

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

     * @return void
Severity: Minor
Found in app/Process.php by phpcodesniffer

There are no issues that match your filters.

Category
Status