YetiForceCompany/YetiForceCRM

View on GitHub
app/Company.php

Summary

Maintainability
A
35 mins
Test Coverage
F
14%

Function getSize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getSize(): string
    {
        $count = User::getNumberOfUsers();
        $return = 'Micro';
        $last = 0;
Severity: Minor
Found in app/Company.php - About 35 mins to fix

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 static access to class 'App\Cache' in method 'getCompany'.
Open

        if (Cache::staticHas('CompanyGet', '')) {
Severity: Minor
Found in app/Company.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\User' in method 'compareSize'.
Open

        return $size >= User::getNumberOfUsers();
Severity: Minor
Found in app/Company.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\Cache' in method 'getCompany'.
Open

        Cache::staticSave('CompanyGet', '', $row, Cache::LONG);
Severity: Minor
Found in app/Company.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\Cache' in method 'getCompany'.
Open

            return Cache::staticGet('CompanyGet', '');
Severity: Minor
Found in app/Company.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\Db' in method 'getCompany'.
Open

        $row = (new Db\Query())->from('s_#__companies')->one(Db::getInstance('admin'));
Severity: Minor
Found in app/Company.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\User' in method 'getSize'.
Open

        $count = User::getNumberOfUsers();
Severity: Minor
Found in app/Company.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

syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST)
Open

    public static array $sizes = [
Severity: Critical
Found in app/Company.php by phan

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

    /** @var string Edit view URL */
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

    public const EDIT_VIEW_URL = 'index.php?parent=Settings&module=Companies&view=Edit';
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        return $row;
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        $return = 'Micro';
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        $last = 0;
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        if (0 === $size) {
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

        'Medium' => 250,
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

        if (!$row) {
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

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

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

    ];
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

    public static function getSize(): string
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

            return true;
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

     * @var int[]
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        'Micro' => 20,
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

     * @return array|bool
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

            throw new Exceptions\DbException('LBL_RECORD_NOT_FOUND');
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        Cache::staticSave('CompanyGet', '', $row, Cache::LONG);
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

        foreach (self::$sizes as $size => $value) {
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

            if (0 !== $value && $count <= $value && $count > $last) {
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

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

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

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

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

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

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

            $last = $value;
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

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

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

        return $size >= User::getNumberOfUsers();
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

     * Classification of enterprises due to their size.
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

     * @return string
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

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

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

    public static array $sizes = [
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        'Corporation' => 0,
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

     * @throws \App\Exceptions\DbException
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        $count = User::getNumberOfUsers();
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

     * Function to get the instance of the Company model.
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

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

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

    public static function getCompany()
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

            return Cache::staticGet('CompanyGet', '');
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

            if (0 === $value && $count > 1000) {
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

                $return = $size;
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

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

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

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

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

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

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

        $row = (new Db\Query())->from('s_#__companies')->one(Db::getInstance('admin'));
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

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

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

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

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

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

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

     * Get company size.
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

                return $size;
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

    public static function compareSize(string $package): bool
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        'Small' => 50,
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        if (Cache::staticHas('CompanyGet', '')) {
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

        $size = self::$sizes[$package] ?? '';
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

        'Large' => 1000,
Severity: Minor
Found in app/Company.php by phpcodesniffer

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

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

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

     * Compare company size.
Severity: Minor
Found in app/Company.php by phpcodesniffer

There are no issues that match your filters.

Category
Status