YetiForceCompany/YetiForceCRM

View on GitHub
app/Utils/BusinessHours.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '36', column '22').
Open

        $dataReader = (new \App\Db\Query())->from('s_#__business_hours')->createCommand(\App\Db::getInstance('admin'))->query();
Severity: Minor
Found in app/Utils/BusinessHours.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

Avoid using static access to class '\App\Cache' in method 'getBusinessHours'.
Open

        if (\App\Cache::has($cacheName, '')) {
Severity: Minor
Found in app/Utils/BusinessHours.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 'getBusinessHours'.
Open

            return \App\Cache::get($cacheName, '');
Severity: Minor
Found in app/Utils/BusinessHours.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 'getBusinessHours'.
Open

        $dataReader = (new \App\Db\Query())->from('s_#__business_hours')->createCommand(\App\Db::getInstance('admin'))->query();
Severity: Minor
Found in app/Utils/BusinessHours.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 'getBusinessHours'.
Open

        return \App\Cache::save($cacheName, '', $businessHours);
Severity: Minor
Found in app/Utils/BusinessHours.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

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

        $dataReader = (new \App\Db\Query())->from('s_#__business_hours')->createCommand(\App\Db::getInstance('admin'))->query();
Severity: Critical
Found in app/Utils/BusinessHours.php by phan

Returning type bool but getBusinessHours() is declared to return array
Open

        return \App\Cache::save($cacheName, '', $businessHours);
Severity: Minor
Found in app/Utils/BusinessHours.php by phan

Avoid variables with short names like $id. Configured minimum length is 3.
Open

    public static function getBusinessHoursById(int $id = self::DEFAULT_BUSINESS_HOURS_ID): ?array
Severity: Minor
Found in app/Utils/BusinessHours.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

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

     * Default business hours ID.
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

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

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

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

    public const DEFAULT_BUSINESS_HOURS_ID = 0;
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

        $cacheName = 'Date::getBusinessHours';
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

        $dataReader = (new \App\Db\Query())->from('s_#__business_hours')->createCommand(\App\Db::getInstance('admin'))->query();
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

        return \App\Cache::save($cacheName, '', $businessHours);
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

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

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

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

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

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

        $businessHours = [];
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

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

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

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

            if ($row['default']) {
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

     * Get default business hours.
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

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

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

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

            $businessHours[$row['id']] = $row;
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

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

        return self::getBusinessHours()[$id] ?? null;
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

                $businessHours[self::DEFAULT_BUSINESS_HOURS_ID] = $row;
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

    public static function getBusinessHours(): array
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

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

    public static function getBusinessHoursById(int $id = self::DEFAULT_BUSINESS_HOURS_ID): ?array
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

Line exceeds 120 characters; contains 128 characters
Open

        $dataReader = (new \App\Db\Query())->from('s_#__business_hours')->createCommand(\App\Db::getInstance('admin'))->query();
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

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

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

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

        if (\App\Cache::has($cacheName, '')) {
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

     * @return array|null
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

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

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

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

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

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

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

        while ($row = $dataReader->read()) {
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

     * @param int $id
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

            return \App\Cache::get($cacheName, '');
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

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

     * Get business hours by id.
Severity: Minor
Found in app/Utils/BusinessHours.php by phpcodesniffer

There are no issues that match your filters.

Category
Status