YetiForceCompany/YetiForceCRM

View on GitHub
modules/Calendar/actions/GetFreeTime.php

Summary

Maintainability
B
5 hrs
Test Coverage
F
0%

Method getFreeTimeInDay has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getFreeTimeInDay(string $day, string $activityType, int $ownerId = null)
    {
        $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);
        if (empty($activityType)) {
            $activityType = $currentUser->get('defaultactivitytype');
Severity: Major
Found in modules/Calendar/actions/GetFreeTime.php - About 3 hrs to fix

    Function getFreeTimeInDay has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getFreeTimeInDay(string $day, string $activityType, int $ownerId = null)
        {
            $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);
            if (empty($activityType)) {
                $activityType = $currentUser->get('defaultactivitytype');
    Severity: Minor
    Found in modules/Calendar/actions/GetFreeTime.php - About 1 hr 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

    The method getFreeTimeInDay() has an NPath complexity of 1824. The configured NPath complexity threshold is 200.
    Open

        public function getFreeTimeInDay(string $day, string $activityType, int $ownerId = null)
        {
            $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);
            if (empty($activityType)) {
                $activityType = $currentUser->get('defaultactivitytype');

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    The method getFreeTimeInDay() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
    Open

        public function getFreeTimeInDay(string $day, string $activityType, int $ownerId = null)
        {
            $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);
            if (empty($activityType)) {
                $activityType = $currentUser->get('defaultactivitytype');

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

    Reduce the number of returns of this function 4, down to the maximum allowed 3.
    Open

        public function getFreeTimeInDay(string $day, string $activityType, int $ownerId = null)

    Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

    Noncompliant Code Example

    With the default threshold of 3:

    function myFunction(){ // Noncompliant as there are 4 return statements
      if (condition1) {
        return true;
      } else {
        if (condition2) {
          return false;
        } else {
          return true;
        }
      }
      return false;
    }
    

    Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
    Open

        public function getFreeTimeInDay(string $day, string $activityType, int $ownerId = null)

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                $data['date_start'] = $startDate['day'] ? DateTimeField::convertToUserFormat($startDate['day']) : null;

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                $data['time_start'] = $startWorkHour;

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                $data['date_start'] = $request->getByType('dateStart', 'DateInUserFormat');

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                $data['time_end'] = $startWorkHour;

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

            $response->setResult($data);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                $data['time_start'] = $startDate['time_start'];

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                $data['time_end'] = $startDate['time_end'];

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    The class Calendar_GetFreeTime_Action has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
    Open

    class Calendar_GetFreeTime_Action extends Vtiger_BasicAjax_Action
    {
        /**
         * Function to check permission.
         *

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    Missing class import via use statement (line '115', column '18').
    Open

            $date->add(new DateInterval('PT' . $durationEvent . 'M0S'));

    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

    Missing class import via use statement (line '101', column '20').
    Open

                    $endTime = new DateTimeField($endHourFormat);

    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

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

                    $startTime = new DateTimeField($startTime);

    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

    Missing class import via use statement (line '120', column '20').
    Open

                    $date->add(new DateInterval('P1D'));

    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

    Missing class import via use statement (line '81', column '18').
    Open

                            ['<=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbEndDateTime],

    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

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

            $date = new DateTime($day . ' ' . $startTime);

    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

    Missing class import via use statement (line '147', column '19').
    Open

            $response = new Vtiger_Response();

    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

    Missing class import via use statement (line '124', column '18').
    Open

            $endTime = new DateTimeField(date_format($date, 'H:i:s'));

    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

    Missing class import via use statement (line '93', column '19').
    Open

                $date->add(new DateInterval('PT' . $durationEvent . 'M0S'));

    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

    Missing class import via use statement (line '77', column '18').
    Open

                            ['<=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbEndDateTime],

    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

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

            $dataReader = (new \App\Db\Query())->select(['date_start', 'time_start', 'time_end'])

    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

    Missing class import via use statement (line '76', column '18').
    Open

                            ['>=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbStartDateTime],

    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

    Missing class import via use statement (line '125', column '20').
    Open

            $startTime = new DateTimeField($startTime);

    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

    Missing class import via use statement (line '92', column '16').
    Open

                $date = new DateTime($row['date_start'] . ' ' . $startTime);

    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

    Missing class import via use statement (line '26', column '14').
    Open

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

    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

    Missing class import via use statement (line '80', column '18').
    Open

                            ['>=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbStartDateTime],

    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

    Missing class import via use statement (line '118', column '19').
    Open

                $date->add(new DateInterval('P1D'));

    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\Fields\DateTime' in method 'process'.
    Open

            if (\App\Fields\DateTime::getDiff($startWorkHour, $endWorkHour, 'minutes') > 0) {

    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 'DateTimeField' in method 'process'.
    Open

                $data['date_start'] = $startDate['day'] ? DateTimeField::convertToUserFormat($startDate['day']) : null;

    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 'process'.
    Open

            $currentUser = $request->isEmpty('ownerId') ? \App\User::getCurrentUserModel() : \App\User::getUserModel($request->getInteger('ownerId'));

    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\Config' in method 'getFreeTimeInDay'.
    Open

                while (\in_array(date_format($date, 'w'), App\Config::module('Calendar', 'HIDDEN_DAYS_IN_CALENDAR_VIEW'))) {

    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

    The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $data['time_start'] = $startWorkHour;
                $data['date_start'] = $request->getByType('dateStart', 'DateInUserFormat');
                $data['time_end'] = $startWorkHour;
            }

    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

    Avoid using static access to class 'Users_Privileges_Model' in method 'checkPermission'.
    Open

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

    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 'DateTimeField' in method 'getFreeTimeInDay'.
    Open

            $dbStartDateOject = DateTimeField::convertToDBTimeZone($day . ' ' . $startWorkHour, null, false);

    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\Fields\DateTime' in method 'getFreeTimeInDay'.
    Open

                    \App\Fields\DateTime::getDiff($startTime, $row['time_start'], 'minutes') >= $durationEvent &&

    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 'getFreeTimeInDay'.
    Open

            $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);

    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 'DateTimeField' in method 'getFreeTimeInDay'.
    Open

            $dbEndDateObject = DateTimeField::convertToDBTimeZone($day . ' ' . $endWorkHour, null, false);

    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\Fields\DateTime' in method 'getFreeTimeInDay'.
    Open

            if (\App\Fields\DateTime::getDiff($dbStartDateTime, $dbEndDateTime, 'minutes') < $durationEvent || strtotime($dbEndDateTime) < strtotime($dbStartDateTime)) {

    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 'DateTimeField' in method 'process'.
    Open

            $dateStart = DateTimeField::convertToDBFormat($request->getByType('dateStart', 'DateInUserFormat'));

    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 'getFreeTimeInDay'.
    Open

            $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);

    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\Json' in method 'getFreeTimeInDay'.
    Open

            $typeByDuration = \App\Json::decode($currentUser->getDetail('othereventduration'));

    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 'getFreeTimeInDay'.
    Open

            $db = App\Db::getInstance();

    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 'process'.
    Open

            $currentUser = $request->isEmpty('ownerId') ? \App\User::getCurrentUserModel() : \App\User::getUserModel($request->getInteger('ownerId'));

    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 "date_start" 5 times.
    Open

            $dataReader = (new \App\Db\Query())->select(['date_start', 'time_start', 'time_end'])

    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 "time_start" 9 times.
    Open

            $dataReader = (new \App\Db\Query())->select(['date_start', 'time_start', 'time_end'])

    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 "H:i:s" 4 times.
    Open

            $startTime = $dbStartDateOject->format('H:i:s');

    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 "Y-m-d" 3 times.
    Open

            $dbStartDate = $dbStartDateOject->format('Y-m-d');

    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 "time_end" 9 times.
    Open

            $dataReader = (new \App\Db\Query())->select(['date_start', 'time_start', 'time_end'])

    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 "minutes" 3 times.
    Open

            if (\App\Fields\DateTime::getDiff($dbStartDateTime, $dbEndDateTime, 'minutes') < $durationEvent || strtotime($dbEndDateTime) < strtotime($dbStartDateTime)) {

    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 "status" 3 times.
    Open

                        ['<>', 'status', 'PLL_POSTPONED'],

    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.

    Argument 1 (mixed) is string but \Users_Privileges_Model::hasModulePermission() takes int defined at /code/modules/Users/models/Privileges.php:101
    Open

            if (!$userPrivilegesModel->hasModulePermission($moduleName)) {

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

                            ['<=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbEndDateTime],
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

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

            $dataReader = (new \App\Db\Query())->select(['date_start', 'time_start', 'time_end'])
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

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

                            ['>=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbStartDateTime],
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Argument 1 (value) is string but \DateTimeField::__construct() takes \type defined at /code/include/fields/DateTimeField.php:31
    Open

                    $startTime = new DateTimeField($startTime);

    Variable $data was undeclared, but array fields are being added to it.
    Open

                $data['time_start'] = $startDate['time_start'];

    Argument 2 (user) is null but \DateTimeField::convertToDBTimeZone() takes \Users defined at /code/include/fields/DateTimeField.php:234
    Open

            $dbEndDateObject = DateTimeField::convertToDBTimeZone($day . ' ' . $endWorkHour, null, false);

    Call to method __construct from undeclared class \yii\db\Expression
    Open

                            ['<=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbEndDateTime],
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Call to method getCurrentUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

            $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Call to method getCurrentUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

            $currentUser = $request->isEmpty('ownerId') ? \App\User::getCurrentUserModel() : \App\User::getUserModel($request->getInteger('ownerId'));
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Variable $data was undeclared, but array fields are being added to it.
    Open

                $data['time_start'] = $startWorkHour;

    Call to method __construct from undeclared class \yii\db\Expression
    Open

                            ['>=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbStartDateTime],
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Call to method __construct from undeclared class \yii\db\Expression
    Open

                            ['<=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbEndDateTime],
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

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

                            ['<=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbEndDateTime],
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

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

                            ['>=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbStartDateTime],
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Call to method getUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

            $currentUser = $request->isEmpty('ownerId') ? \App\User::getCurrentUserModel() : \App\User::getUserModel($request->getInteger('ownerId'));
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Doc-block of $ownerId in getFreeTimeInDay is phpdoc param type int which is not a permitted replacement of the nullable param type ?int declared in the signature ('?T' should be documented as 'T|null' or '?T')
    Open

         * @param int    $ownerId

    Argument 2 (user) is null but \DateTimeField::convertToDBTimeZone() takes \Users defined at /code/include/fields/DateTimeField.php:234
    Open

            $dbStartDateOject = DateTimeField::convertToDBTimeZone($day . ' ' . $startWorkHour, null, false);

    Call to method __construct from undeclared class \yii\db\Expression
    Open

                            ['>=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbStartDateTime],
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Argument 1 (value) is string but \DateTimeField::__construct() takes \type defined at /code/include/fields/DateTimeField.php:31
    Open

            $endTime = new DateTimeField(date_format($date, 'H:i:s'));

    Call to method getUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

            $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);
    Severity: Critical
    Found in modules/Calendar/actions/GetFreeTime.php by phan

    Argument 1 (value) is string but \DateTimeField::__construct() takes \type defined at /code/include/fields/DateTimeField.php:31
    Open

                    $endTime = new DateTimeField($endHourFormat);

    Each class must be in a namespace of at least one level (a top-level vendor name)
    Open

    class Calendar_GetFreeTime_Action extends Vtiger_BasicAjax_Action

    The class Calendar_GetFreeTime_Action is not named in CamelCase.
    Open

    class Calendar_GetFreeTime_Action extends Vtiger_BasicAjax_Action
    {
        /**
         * Function to check permission.
         *

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

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

            $db = App\Db::getInstance();

    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

         * Function to check permission.

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

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

                return [];

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

            }

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

                    ['and',

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

                    ['or',

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

                        ['and',

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

                    ]

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

                $convertedStartTime = strtotime($startTime);

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

                    $endTime = new DateTimeField($endHourFormat);

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

                    $recordsEndTime = $row['time_end'];

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

            $date = new DateTime($day . ' ' . $startTime);

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

         *

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

         * @throws \App\Exceptions\NoPermitted

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

            $currentUser = empty($ownerId) ? \App\User::getCurrentUserModel() : \App\User::getUserModel($ownerId);

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

            $dbStartDate = $dbStartDateOject->format('Y-m-d');

    Line exceeds 120 characters; contains 165 characters
    Open

            if (\App\Fields\DateTime::getDiff($dbStartDateTime, $dbEndDateTime, 'minutes') < $durationEvent || strtotime($dbEndDateTime) < strtotime($dbStartDateTime)) {

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

                            ['<=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbEndDateTime],

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

                        ['and',

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

            $recordsEndTime = '';

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

                    \App\Fields\DateTime::getDiff($startTime, $row['time_start'], 'minutes') >= $durationEvent &&

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

            $endTime = new DateTimeField(date_format($date, 'H:i:s'));

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

            $dateStart = DateTimeField::convertToDBFormat($request->getByType('dateStart', 'DateInUserFormat'));

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

         * @param \App\Request $request

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

         * @param int    $ownerId

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

                            ['<=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbEndDateTime],

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

            $date->add(new DateInterval('PT' . $durationEvent . 'M0S'));

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

                return $this->getFreeTimeInDay(date_format($date, 'Y-m-d'), $activityType, $currentUser->getId());

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

         * Function to get free time in day.

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

            $typeByDuration = \App\Json::decode($currentUser->getDetail('othereventduration'));

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

                        ['<>', 'status', 'PLL_COMPLETED']

    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

                    $startTime = new DateTimeField($startTime);

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

                $startTime = $recordsEndTime;

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

            if ($formattedDate > strtotime($endWorkHour) || $formattedDate < strtotime($startWorkHour)) {

    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 function checkPermission(App\Request $request)

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

            $moduleName = $request->getModule();

    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

                            ['>=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbStartDateTime],

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

                            ['>=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbStartDateTime],

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

            while ($row = $dataReader->read()) {

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

                $date->add(new DateInterval('PT' . $durationEvent . 'M0S'));

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

            $startTime = new DateTimeField($startTime);

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

            if (!$userPrivilegesModel->hasModulePermission($moduleName)) {

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

        }

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

            $dbEndDateObject = DateTimeField::convertToDBTimeZone($day . ' ' . $endWorkHour, null, false);

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

            $dbStartDateTime = $dbStartDateOject->format('Y-m-d H:i:s');

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

            if (\App\Fields\DateTime::getDiff($dbStartDateTime, $dbEndDateTime, 'minutes') < $durationEvent || strtotime($dbEndDateTime) < strtotime($dbStartDateTime)) {

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

                    ['smownerid' => $currentUser->getId()],

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

                $date = new DateTime($row['date_start'] . ' ' . $startTime);

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

                    strtotime($endWorkHour) >= strtotime($endHourFormat)) {

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

                    return ['day' => $day, 'time_start' => $startTime->getDisplayTime(), 'time_end' => $endTime->getDisplayTime()];

    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

            $endWorkHour = $currentUser->getDetail('end_hour');

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

         *

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

         * @throws \App\Exceptions\AppException

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

            $endWorkHour = $currentUser->getDetail('end_hour');

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

                ->from('vtiger_activity')

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

                    ['deleted' => 0],

    Line exceeds 120 characters; contains 131 characters
    Open

                            ['<=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbEndDateTime],

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

                        ],

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

                $startTime = $row['time_end'];

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

        /** {@inheritdoc} */

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

            if (empty($activityType)) {

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

                $activityType = $currentUser->get('defaultactivitytype');

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

            $dbStartDateOject = DateTimeField::convertToDBTimeZone($day . ' ' . $startWorkHour, null, false);

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

                ->where([

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

                        ['<>', 'status', 'PLL_POSTPONED'],

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

                        ['and',

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

                    $convertedStartTime <= strtotime($row['time_start']) &&

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

            if (!empty($recordsEndTime)) {

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

                $date->add(new DateInterval('P1D'));

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

        }

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

            $currentUser = $request->isEmpty('ownerId') ? \App\User::getCurrentUserModel() : \App\User::getUserModel($request->getInteger('ownerId'));

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

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

         * @param string $activityType

    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 function getFreeTimeInDay(string $day, string $activityType, int $ownerId = null)

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

                    'and',

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

                    ],

    Line exceeds 120 characters; contains 137 characters
    Open

                            ['>=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbStartDateTime],

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

                ->createCommand()->query();

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

                }

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

                while (\in_array(date_format($date, 'w'), App\Config::module('Calendar', 'HIDDEN_DAYS_IN_CALENDAR_VIEW'))) {

    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 string $day

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

            $dbEndDateTime = $dbEndDateObject->format('Y-m-d H:i:s');

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

                }

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

                if (empty($recordsEndTime) || strtotime($row['time_end']) > strtotime($recordsEndTime)) {

    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

            $typeByDuration = array_column($typeByDuration, 'duration', 'activitytype');

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

            $db = App\Db::getInstance();

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

            $startTime = $dbStartDateOject->format('H:i:s');

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

                        ['<>', 'status', 'PLL_CANCELLED'],

    Line exceeds 120 characters; contains 135 characters
    Open

                            ['<=', new \yii\db\Expression('CONCAT(date_start, ' . $db->quoteValue(' ') . ', time_start)'), $dbEndDateTime],

    Line exceeds 120 characters; contains 133 characters
    Open

                            ['>=', new \yii\db\Expression('CONCAT(due_date, ' . $db->quoteValue(' ') . ', time_end)'), $dbStartDateTime],

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

            $startWorkHour = $currentUser->getDetail('start_hour');

    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

            $startWorkHour = $currentUser->getDetail('start_hour');

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

            $dbEndDate = $dbEndDateObject->format('Y-m-d');

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

                            ['<', 'date_start', $dbStartDate],

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

                    $convertedStartTime >= strtotime($recordsEndTime) &&

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

            $formattedDate = strtotime(date_format($date, 'H:i:s'));

    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 array

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

            $durationEvent = $typeByDuration[$activityType] ?? 0;

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

            $dataReader = (new \App\Db\Query())->select(['date_start', 'time_start', 'time_end'])

    Line exceeds 120 characters; contains 127 characters
    Open

                    return ['day' => $day, 'time_start' => $startTime->getDisplayTime(), 'time_end' => $endTime->getDisplayTime()];

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

                    $date->add(new DateInterval('P1D'));

    Line exceeds 120 characters; contains 146 characters
    Open

            $currentUser = $request->isEmpty('ownerId') ? \App\User::getCurrentUserModel() : \App\User::getUserModel($request->getInteger('ownerId'));

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

                            ['>', 'due_date', $dbEndDate],

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

                ])->orderBy(['time_start' => SORT_ASC])

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

                $endHourFormat = date_format($date, 'H:i:s');

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

            $dataReader->close();

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

            return ['day' => $day, 'time_start' => $startTime->getDisplayTime(), 'time_end' => $endTime->getDisplayTime()];

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

        {

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

            } else {

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

                $startDate = $this->getFreeTimeInDay($dateStart, $activityType, $currentUser->getId());

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

            }

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

                $data['time_start'] = $startDate['time_start'];

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

                $data['date_start'] = $request->getByType('dateStart', 'DateInUserFormat');

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

            if (\App\Fields\DateTime::getDiff($startWorkHour, $endWorkHour, 'minutes') > 0) {

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

                if (strtotime($startWorkHour) <= $convertedStartTime &&

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

        public function process(App\Request $request)

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

            $response = new Vtiger_Response();

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

                $data['time_end'] = $startWorkHour;

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

            $response->emit();

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

                $data['date_start'] = $startDate['day'] ? DateTimeField::convertToUserFormat($startDate['day']) : null;

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

                $data['time_start'] = $startWorkHour;

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

        }

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

            $activityType = $request->getByType('activitytype', 'Standard');

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

                $data['time_end'] = $startDate['time_end'];

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

            $response->setResult($data);

    Class name "Calendar_GetFreeTime_Action" is not in camel caps format
    Open

    class Calendar_GetFreeTime_Action extends Vtiger_BasicAjax_Action

    There are no issues that match your filters.

    Category
    Status