YetiForceCompany/YetiForceCRM

View on GitHub
app/Pauser.php

Summary

Maintainability
A
0 mins
Test Coverage
B
87%

Missing class import via use statement (line '65', column '15').
Open

        $val = (new \App\Db\Query())->select(['value'])->from(self::TABLE_NAME)->where(['key' => $this->key])->scalar();
Severity: Minor
Found in app/Pauser.php by phpmd

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 setValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $result = $dbCommand->update(self::TABLE_NAME, ['value' => $value], ['key' => $this->key])->execute();
        }
Severity: Minor
Found in app/Pauser.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Remove this unused "TABLE_NAME" private field.
Open

    private const TABLE_NAME = 's_#__pauser';
Severity: Major
Found in app/Pauser.php by sonar-php

If a private field is declared but not used in the program, it can be considered dead code and should therefore be removed. This will improve maintainability because developers will not wonder what the variable is used for.

Noncompliant Code Example

class MyClass {
  private $foo = 4;                       //foo is unused

  public function compute($a) {
    return $a * 4;
  }
}

Compliant Solution

class MyClass {

  public function compute($a) {
    return $a * 4;
  }
}

See

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

        $val = (new \App\Db\Query())->select(['value'])->from(self::TABLE_NAME)->where(['key' => $this->key])->scalar();
Severity: Critical
Found in app/Pauser.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.

Assigning null to property but \App\Pauser->value is string
Open

        $this->value = null;
Severity: Minor
Found in app/Pauser.php by phan

Call to undeclared method \App\Db::createCommand
Open

        return (bool) \App\Db::getInstance()->createCommand()->delete(self::TABLE_NAME, ['key' => $this->key])->execute();
Severity: Critical
Found in app/Pauser.php by phan

Call to undeclared method \App\Db\Query::select
Open

        $val = (new \App\Db\Query())->select(['value'])->from(self::TABLE_NAME)->where(['key' => $this->key])->scalar();
Severity: Critical
Found in app/Pauser.php by phan

Call to undeclared method \App\Db::createCommand
Open

        $dbCommand = \App\Db::getInstance()->createCommand();
Severity: Critical
Found in app/Pauser.php by phan

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

    /** Table name. */
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

    /** @var string Entry name */
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

        return $this;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

     * Set value.
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

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

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

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

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

     * @return string|null
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

    public function getValue(): ?string
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

        return $this->value;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

     * Return object instance.
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

     * Set key name.
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

        return $instance;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

     * @return self
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

Line exceeds 120 characters; contains 122 characters
Open

        return (bool) \App\Db::getInstance()->createCommand()->delete(self::TABLE_NAME, ['key' => $this->key])->execute();
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

        $this->key = $key;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

        return $this;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

    public function destroy(): bool
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

        return (bool) \App\Db::getInstance()->createCommand()->delete(self::TABLE_NAME, ['key' => $this->key])->execute();
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

     * @return self
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

        if (null === $this->value) {
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

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

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

    private $key;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

            $result = $dbCommand->insert(self::TABLE_NAME, ['value' => $value, 'key' => $this->key])->execute();
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

        return (bool) $result;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

     * Get value.
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

        $instance->setKey($key)->load();
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

     * Load data from database.
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

     * @return self
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

    public function setValue(string $value): bool
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

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

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

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

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

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

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

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

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

    private const TABLE_NAME = 's_#__pauser';
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

    private $value;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

    public static function getInstance(string $key): self
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

        } else {
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

            $result = $dbCommand->update(self::TABLE_NAME, ['value' => $value], ['key' => $this->key])->execute();
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

     * Remove key from database.
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

        $val = (new \App\Db\Query())->select(['value'])->from(self::TABLE_NAME)->where(['key' => $this->key])->scalar();
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

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

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

        $dbCommand = \App\Db::getInstance()->createCommand();
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

        $this->value = false === $val ? null : $val;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

Line exceeds 120 characters; contains 136 characters
Open

 * It stores data about the last executed element of a given process in order to resume it at a later time while maintaining continuity.
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

        $instance = new self();
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

            $this->value = $value;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

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

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

    private function setKey(string $key): self
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

    private function load(): self
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

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

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

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

        $this->value = null;
Severity: Minor
Found in app/Pauser.php by phpcodesniffer

There are no issues that match your filters.

Category
Status