YetiForceCompany/YetiForceCRM

View on GitHub
include/fields/DateTimeField.php

Summary

Maintainability
B
4 hrs
Test Coverage
C
76%

The class DateTimeField has an overall complexity of 55 which is very high. The configured complexity threshold is 50.
Open

class DateTimeField
{
    protected $datetime;
    private static $cache = [];

Severity: Minor
Found in include/fields/DateTimeField.php by phpmd

Function __convertToUserFormat has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public static function __convertToUserFormat($date, $format)
    {
        \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date) . ' | ' . $format);
        if (!\is_array($date)) {
            $date = explode(' ', $date);
Severity: Minor
Found in include/fields/DateTimeField.php - About 2 hrs 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

Method __convertToUserFormat has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function __convertToUserFormat($date, $format)
    {
        \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date) . ' | ' . $format);
        if (!\is_array($date)) {
            $date = explode(' ', $date);
Severity: Major
Found in include/fields/DateTimeField.php - About 2 hrs to fix

    The method __convertToUserFormat() has an NPath complexity of 240. The configured NPath complexity threshold is 200.
    Open

        public static function __convertToUserFormat($date, $format)
        {
            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date) . ' | ' . $format);
            if (!\is_array($date)) {
                $date = explode(' ', $date);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    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 __convertToUserFormat() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
    Open

        public static function __convertToUserFormat($date, $format)
        {
            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date) . ' | ' . $format);
            if (!\is_array($date)) {
                $date = explode(' ', $date);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    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

    Missing class import via use statement (line '304', column '17').
    Open

                    $date = new DateTime($this->datetime);
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

                $date = new DateTime($this->datetime);
    Severity: Minor
    Found in include/fields/DateTimeField.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 getDisplayDate has a boolean flag argument $convertTimeZone, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getDisplayDate($user = null, bool $convertTimeZone = true): string
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Missing class import via use statement (line '264', column '25').
    Open

            $targetTimeZone = new DateTimeZone($targetTimeZoneName);
    Severity: Minor
    Found in include/fields/DateTimeField.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 convertToDBTimeZone has a boolean flag argument $formatDate, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public static function convertToDBTimeZone($value, $user = null, $formatDate = true)
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    The method getDBInsertTimeValue has a boolean flag argument $convertTimeZone, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getDBInsertTimeValue(bool $convertTimeZone = true)
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Missing class import via use statement (line '256', column '25').
    Open

            $sourceTimeZone = new DateTimeZone($sourceTimeZoneName);
    Severity: Minor
    Found in include/fields/DateTimeField.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

    Missing class import via use statement (line '262', column '21').
    Open

            $myDateTime = new DateTime($time, $sourceTimeZone);
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

                $date = new DateTime($this->datetime);
    Severity: Minor
    Found in include/fields/DateTimeField.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 getDisplayTime has a boolean flag argument $convertTimeZone, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getDisplayTime($user = null, bool $convertTimeZone = true, bool $fullTime = false): string
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    The method getDisplayTime has a boolean flag argument $fullTime, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getDisplayTime($user = null, bool $convertTimeZone = true, bool $fullTime = false): string
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Avoid using static access to class '\App\Log' in method '__convertToDBFormat'.
    Open

                \App\Log::trace('End ' . __METHOD__);
    Severity: Minor
    Found in include/fields/DateTimeField.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 'Users_Privileges_Model' in method 'convertToUserTimeZone'.
    Open

            $current_user = Users_Privileges_Model::getCurrentUserPrivilegesModel();
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'getFullcalenderTime'.
    Open

            \App\Log::trace('Exiting getDisplayTime method ...');
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'convertToDBFormat'.
    Open

            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date));
    Severity: Minor
    Found in include/fields/DateTimeField.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 'convertToDBFormat'.
    Open

                $user = \App\User::getCurrentUserModel();
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'convertTimeZone'.
    Open

            \App\Log::trace('End ' . __METHOD__);
    Severity: Minor
    Found in include/fields/DateTimeField.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 'sanitizeDate'.
    Open

                $user = \App\User::getCurrentUserModel();
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'getDBInsertDateTimeValue'.
    Open

            \App\Log::trace(__METHOD__);
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'convertToDBFormat'.
    Open

            \App\Log::trace('End ' . __METHOD__);
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'convertToUserTimeZone'.
    Open

            \App\Log::trace('Start ' . __METHOD__ . "($value) method ...");
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

            } else {
                $date = new DateTime($this->datetime);
            }
    Severity: Minor
    Found in include/fields/DateTimeField.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

    Avoid using static access to class 'Vtiger_Time_UIType' in method 'getDisplayTime'.
    Open

                $time = Vtiger_Time_UIType::getTimeValueInAMorPM($time);
    Severity: Minor
    Found in include/fields/DateTimeField.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\Fields\DateTime' in method 'sanitizeDate'.
    Open

            return \App\Fields\DateTime::sanitizeDbFormat($value, $user->getDetail('date_format'));
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'getDisplayDateTimeValue'.
    Open

            \App\Log::trace(__METHOD__);
    Severity: Minor
    Found in include/fields/DateTimeField.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\Config' in method 'convertToUserTimeZone'.
    Open

            $timeZone = \is_object($user) ? $user->time_zone : App\Config::main('default_timezone');
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

                } else {
                    $date = new DateTime($this->datetime);
                }
    Severity: Minor
    Found in include/fields/DateTimeField.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

    Avoid using static access to class '\App\Log' in method '__convertToUserFormat'.
    Open

            \App\Log::trace('End ' . __METHOD__);
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

            } else {
                $insert_date = self::convertToDBFormat($value[0]);
            }
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

            } else {
                $userDate = $date[0];
            }
    Severity: Minor
    Found in include/fields/DateTimeField.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

    Avoid using static access to class 'App\Fields\DateTime' in method 'convertToUserTimeZone'.
    Open

            $return = self::convertTimeZone($value, App\Fields\DateTime::getTimeZone(), $timeZone);
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'getFullcalenderTime'.
    Open

            \App\Log::trace('Entering getDisplayTime(' . $this->datetime . ') method ...');
    Severity: Minor
    Found in include/fields/DateTimeField.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\Fields\DateTime' in method 'convertToDBTimeZone'.
    Open

            return self::convertTimeZone($value, $timeZone, App\Fields\DateTime::getTimeZone());
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

            } else {
                $date = new DateTime($this->datetime);
            }
    Severity: Minor
    Found in include/fields/DateTimeField.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

    Avoid using static access to class '\App\Log' in method 'convertTimeZone'.
    Open

            \App\Log::trace('Start ' . __METHOD__ . "($time, $sourceTimeZoneName, $targetTimeZoneName)");
    Severity: Minor
    Found in include/fields/DateTimeField.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\Fields\Date' in method '__convertToDBFormat'.
    Open

            return \App\Fields\Date::sanitizeDbFormat($date, $format);
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method '__convertToUserFormat'.
    Open

            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date) . ' | ' . $format);
    Severity: Minor
    Found in include/fields/DateTimeField.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\Log' in method 'convertToUserTimeZone'.
    Open

            \App\Log::trace('End ' . __METHOD__);
    Severity: Minor
    Found in include/fields/DateTimeField.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 'convertToDBTimeZone'.
    Open

                $user = \App\User::getCurrentUserModel();
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Define a constant instead of duplicating this literal "Start " 4 times.
    Open

            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date));
    Severity: Critical
    Found in include/fields/DateTimeField.php by sonar-php

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

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

    Define a constant instead of duplicating this literal "yyyy-mm-dd" 4 times.
    Open

                $format = 'yyyy-mm-dd';
    Severity: Critical
    Found in include/fields/DateTimeField.php by sonar-php

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

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

    Define a constant instead of duplicating this literal "H:i:s" 3 times.
    Open

            return $date->format('H:i:s');
    Severity: Critical
    Found in include/fields/DateTimeField.php by sonar-php

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

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

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

            $format = $user->getDetail('date_format');
    Severity: Critical
    Found in include/fields/DateTimeField.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.

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

            if ('12' === \App\User::getCurrentUserModel()->getDetail('hour_format')) {
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
    Open

        private static function sanitizeDate(string $value, $user): string
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

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

                $user = \App\User::getCurrentUserModel();
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Reference to undeclared property \Users->time_zone
    Open

            $timeZone = \is_object($user) ? $user->time_zone : App\Config::main('default_timezone');
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Argument 2 (user) is \CRMEntity|\Users but \DateTimeField::sanitizeDate() takes \App\User|null defined at /code/include/fields/DateTimeField.php:353
    Open

                $value = self::sanitizeDate($value, $user);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Argument 1 (timezone) is \type but \DateTimeZone::__construct() takes string
    Open

            $targetTimeZone = new DateTimeZone($targetTimeZoneName);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Reference to undeclared property \DateTimeField->date
    Open

            $this->date = null;
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Saw an @param annotation for user, but it was not found in the param list of function convertToUserFormat(string $date) : string
    Open

         * @param Users  $user
    Severity: Info
    Found in include/fields/DateTimeField.php by phan

    When fetching an array index from a value of type \DateTime[], found an array index of type \type, but expected the index to be of type int|string
    Open

            $myDateTime = self::$cache[$time][$targetTimeZoneName];
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Saw an @param annotation for user, but the param list of function getDBInsertDateValue() is empty
    Open

         * @param $user -- value :: Type Users
    Severity: Info
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('End ' . __METHOD__);
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Suspicious type \type of a variable or expression used to build a string. (Expected type to be able to cast to a string)
    Open

            \App\Log::trace('Start ' . __METHOD__ . "($time, $sourceTimeZoneName, $targetTimeZoneName)");
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Argument 1 (time) is string but \DateTimeField::convertTimeZone() takes \type defined at /code/include/fields/DateTimeField.php:253
    Open

            $return = self::convertTimeZone($value, App\Fields\DateTime::getTimeZone(), $timeZone);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Argument 1 (time) is string but \DateTimeField::convertTimeZone() takes \type defined at /code/include/fields/DateTimeField.php:253
    Open

            return self::convertTimeZone($value, $timeZone, App\Fields\DateTime::getTimeZone());
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Parameter $value has undeclared type \type
    Open

        public function __construct($value)
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

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

                $user = \App\User::getCurrentUserModel();
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('Start ' . __METHOD__ . "($value) method ...");
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date) . ' | ' . $format);
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('End ' . __METHOD__);
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date));
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to undeclared method \Users::getDetail
    Open

            $timeZone = $user->getDetail('time_zone');
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Argument 3 (targetTimeZoneName) is string but \DateTimeField::convertTimeZone() takes \type defined at /code/include/fields/DateTimeField.php:253
    Open

            return self::convertTimeZone($value, $timeZone, App\Fields\DateTime::getTimeZone());
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Parameter $sourceTimeZoneName has undeclared type \type
    Open

        public static function convertTimeZone($time, $sourceTimeZoneName, $targetTimeZoneName)
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
    Open

        public function getDisplayDate($user = null, bool $convertTimeZone = true): string
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Argument 2 (user) is \App\User|null but \DateTimeField::convertToUserTimeZone() takes \Users defined at /code/include/fields/DateTimeField.php:216
    Open

                    $date = self::convertToUserTimeZone($this->datetime, $user);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Reference to undeclared property \DateTimeField->time
    Open

            $this->time = null;
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('Start ' . __METHOD__ . "($time, $sourceTimeZoneName, $targetTimeZoneName)");
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('Entering getDisplayTime(' . $this->datetime . ') method ...');
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Parameter $targetTimeZoneName has undeclared type \type
    Open

        public static function convertTimeZone($time, $sourceTimeZoneName, $targetTimeZoneName)
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Parameter $time has undeclared type \type
    Open

        public static function convertTimeZone($time, $sourceTimeZoneName, $targetTimeZoneName)
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Argument 1 (timezone) is \type but \DateTimeZone::__construct() takes string
    Open

            $sourceTimeZone = new DateTimeZone($sourceTimeZoneName);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Saw misspelled annotation @returns. Did you mean @return?
    Open

         * @returns $insert_date -- insert_date :: Type string
    Severity: Info
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('End ' . __METHOD__);
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Saw an @param annotation for user, but the param list of function getDBInsertDateTimeValue() : string is empty
    Open

         * @param Users $user
    Severity: Info
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace(__METHOD__);
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace(__METHOD__);
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

                \App\Log::trace('End ' . __METHOD__);
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Argument 2 (user) is \App\User|null but \DateTimeField::convertToUserTimeZone() takes \Users defined at /code/include/fields/DateTimeField.php:216
    Open

                $date = self::convertToUserTimeZone($this->datetime, $user);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

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

                $user = \App\User::getCurrentUserModel();
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('End ' . __METHOD__);
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
    Open

        public function getDisplayTime($user = null, bool $convertTimeZone = true, bool $fullTime = false): string
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('Exiting getDisplayTime method ...');
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

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

            return \App\Fields\DateTime::sanitizeDbFormat($value, $user->getDetail('date_format'));
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

    Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
    Open

        public function getDisplayFullDateTimeValue($user = null): string
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
    Open

        public static function convertToDBFormat($date, $user = null)
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

    Argument 2 (sourceTimeZoneName) is string but \DateTimeField::convertTimeZone() takes \type defined at /code/include/fields/DateTimeField.php:253
    Open

            $return = self::convertTimeZone($value, App\Fields\DateTime::getTimeZone(), $timeZone);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phan

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

            $format = $user->getDetail('date_format');
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

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

                $format = \App\User::getCurrentUserModel()->getDetail('date_format') ?: 'yyyy-mm-dd';
    Severity: Critical
    Found in include/fields/DateTimeField.php by phan

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

    class DateTimeField

    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 23 and the first side effect is on line 11.
    Open

    <?php

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

            [$y, $m, $d] = array_pad(explode($separator, $date[0]), 3, null);
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

            [$y, $m, $d] = array_pad(explode($separator, $date[0]), 3, null);
    Severity: Minor
    Found in include/fields/DateTimeField.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

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

            [$y, $m, $d] = array_pad(explode($separator, $date[0]), 3, null);
    Severity: Minor
    Found in include/fields/DateTimeField.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

        {

    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

                $insert_date = self::convertToDBFormat($value[0]);

    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 $this->getDisplayDate($user) . ' ' . $this->getDisplayTime($user, true, true);

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

         * @param \App\User $user

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

        public function __construct($value)

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

         *

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

            \App\Log::trace(__METHOD__);

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

         * Get full datetime value (with seconds).

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

        protected $datetime;

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

            $this->date = null;

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

         */

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

            $insert_date = '';

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

        public function getDisplayDateTimeValue($user = null)

    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 getDisplayFullDateTimeValue($user = null): string

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

            $this->time = null;

    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    $date

    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 $user -- value :: Type Users

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

            return $this->getDisplayDate($user) . ' ' . $this->getDisplayTime($user);

    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

        /**

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

         * @param Users $user

    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

        }

    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($value)) {

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

            $this->datetime = $value;

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

            if (!empty($value[1])) {

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

        }

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

         * @returns $insert_date -- insert_date :: Type string

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

                $date = self::convertToDBTimeZone($this->datetime);

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

                $insert_date = $date->format('Y-m-d');

    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 type $value

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

        public function getDBInsertDateValue()

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

            return $insert_date;

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

        public function getDBInsertDateTimeValue()

    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 $this->getDisplayDate($user) . ' ' . $this->getFullcalenderTime($user);

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

        private static $cache = [];

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

            $value = explode(' ', $this->datetime, 2);

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

         * @return string

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

            \App\Log::trace(__METHOD__);

    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 App\User|null $user

    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 getFullcalenderDateTimevalue($user = null)

    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 $this->getDBInsertDateValue() . ' ' . $this->getDBInsertTimeValue();

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

        {

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

                $value = date('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

        }

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

        /** Function to set date values compatible to database (YY_MM_DD).

    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 string

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

        }

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

                $format = 'yyyy-mm-dd';

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

                $userDate = self::__convertToUserFormat($date, $format);

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

        public static function __convertToUserFormat($date, $format)

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

            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date));

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

            } elseif (false !== strpos($date[0], '/')) {

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

                    break;

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

            if (empty($user)) {

    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

            $current_user = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

                $user = $current_user;

    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

        /**

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

         * @param string $date

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

        public static function convertToDBFormat($date, $user = null)

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

         * @param Users  $user

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

            $format = $user->getDetail('date_format');

    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

            $userDate = '';

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

                case 'dd-mm-yyyy':

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

        {

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

                    $date[0] = $d . '-' . $m . '-' . $y;

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

                    $date[0] = $m . '-' . $d . '-' . $y;

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

                case 'yyyy-mm-dd':

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

                case 'dd.mm.yyyy':

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

                case 'mm.dd.yyyy':

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

                $userDate = $date[0];

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

                    break;

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

        }

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

                    break;

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

            return $return;

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

         * @param Users  $user

    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

         * @param type $time

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

        public static function convertToUserTimeZone($value, $user = null)

    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($user)) {

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

                return $date;

    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

         * @param string $format

    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 string

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

                    break;

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

        public static function __convertToDBFormat($date, $format)

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

                case 'yyyy.mm.dd':

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

         * @param string $date

    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 (!\is_array($date)) {

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

         * @param string $value

    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 = self::convertTimeZone($value, App\Fields\DateTime::getTimeZone(), $timeZone);

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

            $timeZone = \is_object($user) ? $user->time_zone : App\Config::main('default_timezone');

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

                $user = \App\User::getCurrentUserModel();

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

         * @return DateTime

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

            return $return;

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

                $format = \App\User::getCurrentUserModel()->getDetail('date_format') ?: 'yyyy-mm-dd';

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

         * @param Users  $user

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

        public static function convertToDBTimeZone($value, $user = null, $formatDate = true)

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

                    $date[0] = $m . '/' . $d . '/' . $y;

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

        {

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

                    break;

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

            return self::convertTimeZone($value, $timeZone, App\Fields\DateTime::getTimeZone());

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

        public static function convertTimeZone($time, $sourceTimeZoneName, $targetTimeZoneName)

    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 = self::__convertToDBFormat($date, $format);

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

            \App\Log::trace('End ' . __METHOD__);

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

        }

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

            switch ($format) {

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

                case 'mm/dd/yyyy':

    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($format)) {

    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($date)) {

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

                $format = 'yyyy-mm-dd';

    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 string

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

         * @param string $date

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

                \App\Log::trace('End ' . __METHOD__);

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

            }

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

                $separator = '.';

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

                case 'dd/mm/yyyy':

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

            if (!empty($date)) {

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

                    break;

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

                case 'yyyy/mm/dd':

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

            $separator = '-';

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

            \App\Log::trace('Start ' . __METHOD__ . "($value) method ...");

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

                case 'mm-dd-yyyy':

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

            }

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

                    $date[0] = $m . '.' . $d . '.' . $y;

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

         * @param type $sourceTimeZoneName

    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

         * @param type $targetTimeZoneName

    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 $format

    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 \App\Fields\Date::sanitizeDbFormat($date, $format);

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

        public static function convertToUserFormat($date)

    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

            }

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

                    break;

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

                default:

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

         * @param string $value

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

                $user = \App\User::getCurrentUserModel();

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

                $value = self::sanitizeDate($value, $user);

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

        }

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

            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date) . ' | ' . $format);

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

                $date = explode(' ', $date);

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

            } elseif (false !== strpos($date[0], '.')) {

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

            \App\Log::trace('End ' . __METHOD__);

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

         * @return string

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

         * @param mixed  $formatDate

    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 (false !== strpos($date[0], '-')) {

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

                $separator = '-';

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

                    $date[0] = $y . '.' . $m . '.' . $d;

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

            if (isset($date[1]) && '' != $date[1]) {

    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

        {

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

            return $userDate;

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

                    $date[0] = $y . '-' . $m . '-' . $d;

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

                    $date[0] = $d . '/' . $m . '/' . $y;

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

            \App\Log::trace('Start ' . __METHOD__ . "($time, $sourceTimeZoneName, $targetTimeZoneName)");

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

         * @return string

    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 ('' == $format) {

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

        {

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

                    break;

    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 ($formatDate) {

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

         */

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

                    $date[0] = $d . '.' . $m . '.' . $y;

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

                    $date[0] = $y . '/' . $m . '/' . $d;

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

            \App\Log::trace('End ' . __METHOD__);

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

            if (empty($user)) {

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

            $timeZone = $user->getDetail('time_zone');

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

         */

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

                $separator = '/';

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

            [$y, $m, $d] = array_pad(explode($separator, $date[0]), 3, null);

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

                    break;

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

                    break;

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

                $userDate = $date[0] . ' ' . $date[1];

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

            return $userDate;

    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 string

    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

            }

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

            $myDateTime = self::$cache[$time][$targetTimeZoneName];

    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 string

    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 bool $convertTimeZone

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

                    $date = self::convertToUserTimeZone($this->datetime, $user);

    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

        }

    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 bool           $convertTimeZone

    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

            }

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

            return $date->format('H:i:s');

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

            return self::convertToUserFormat($date_value);

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

         * Get display time.

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

        {

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

                $user = \App\User::getCurrentUserModel();

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

            $sourceTimeZone = new DateTimeZone($sourceTimeZoneName);

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

            if ('24:00' == $time) {

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

            $time = str_replace('.', '-', $time);

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

            $targetTimeZone = new DateTimeZone($targetTimeZoneName);

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

            if ($convertTimeZone) {

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

                $date = new DateTime($this->datetime);

    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 string

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

        public function getDisplayDate($user = null, bool $convertTimeZone = true): string

    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 getDisplayTime($user = null, bool $convertTimeZone = true, bool $fullTime = false): string

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

            $time = $fullTime ? $date->format('H:i:s') : $date->format('H:i');

    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 getDBInsertTimeValue(bool $convertTimeZone = true)

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

            \App\Log::trace('Exiting getDisplayTime method ...');

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

            return \App\Fields\DateTime::sanitizeDbFormat($value, $user->getDetail('date_format'));

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

        }

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

            $myDateTime = new DateTime($time, $sourceTimeZone);

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

         * Function to set time values compatible to database (GMT).

    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

                    $date = new DateTime($this->datetime);

    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

            if ('12' === \App\User::getCurrentUserModel()->getDetail('hour_format')) {

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

         * @return string $value

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

            if (empty($user)) {

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

                return $value;

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

            $time = str_replace('/', '-', $time);

    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 (isset($date_value[1]) && '' != $date_value[1]) {

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

                $date = self::convertToUserTimeZone($this->datetime, $user);

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

                $date = new DateTime($this->datetime);

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

            if (\strlen($value) < 8) {

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

            $value = str_replace('T', ' ', $value);

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

                $time = '00:00';

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

            if ($convertTimeZone) {

    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         $value

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

            // convert this to target timezone using the DateTimeZone object

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

            self::$cache[$time][$targetTimeZoneName] = $myDateTime;

    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

         * Sanitize date.

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

         */

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

            $myDateTime->setTimeZone($targetTimeZone);

    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 App\User|null $user

    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

                }

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

            return $time;

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

            }

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

            \App\Log::trace('End ' . __METHOD__);

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

                if ($convertTimeZone) {

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

                $date_value = $date->format('Y-m-d');

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

         * @param bool           $fullTime        (with seconds)

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

            //Convert time to user preferred value

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

        private static function sanitizeDate(string $value, $user): string

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

                $date = self::convertToDBTimeZone($this->datetime);

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

         * This function returns the date in user specified format.

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

            $date_value = explode(' ', $this->datetime);

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

        /**

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

            $time = $date->format('H:i:s');

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

            return $time;

    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 \App\User|null $user

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

         * @param bool          $convertTimeZone

    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 \App\User|null $user

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

                $time = Vtiger_Time_UIType::getTimeValueInAMorPM($time);

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

        public function getFullcalenderTime($user = null)

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

            return $myDateTime;

    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

        {

    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

            \App\Log::trace('Entering getDisplayTime(' . $this->datetime . ') method ...');

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

            $date = self::convertToUserTimeZone($this->datetime, $user);

    The variable $date_value is not named in camelCase.
    Open

        public function getDisplayDate($user = null, bool $convertTimeZone = true): string
        {
            $date_value = explode(' ', $this->datetime);
            if (isset($date_value[1]) && '' != $date_value[1]) {
                if ($convertTimeZone) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $current_user is not named in camelCase.
    Open

        public static function convertToUserTimeZone($value, $user = null)
        {
            $current_user = Users_Privileges_Model::getCurrentUserPrivilegesModel();
            \App\Log::trace('Start ' . __METHOD__ . "($value) method ...");
            if (empty($user)) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $date_value is not named in camelCase.
    Open

        public function getDisplayDate($user = null, bool $convertTimeZone = true): string
        {
            $date_value = explode(' ', $this->datetime);
            if (isset($date_value[1]) && '' != $date_value[1]) {
                if ($convertTimeZone) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $current_user is not named in camelCase.
    Open

        public static function convertToUserTimeZone($value, $user = null)
        {
            $current_user = Users_Privileges_Model::getCurrentUserPrivilegesModel();
            \App\Log::trace('Start ' . __METHOD__ . "($value) method ...");
            if (empty($user)) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $insert_date is not named in camelCase.
    Open

        public function getDBInsertDateValue()
        {
            $value = explode(' ', $this->datetime, 2);
            $insert_date = '';
            if (!empty($value[1])) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $insert_date is not named in camelCase.
    Open

        public function getDBInsertDateValue()
        {
            $value = explode(' ', $this->datetime, 2);
            $insert_date = '';
            if (!empty($value[1])) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $insert_date is not named in camelCase.
    Open

        public function getDBInsertDateValue()
        {
            $value = explode(' ', $this->datetime, 2);
            $insert_date = '';
            if (!empty($value[1])) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $date_value is not named in camelCase.
    Open

        public function getDisplayDate($user = null, bool $convertTimeZone = true): string
        {
            $date_value = explode(' ', $this->datetime);
            if (isset($date_value[1]) && '' != $date_value[1]) {
                if ($convertTimeZone) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $date_value is not named in camelCase.
    Open

        public function getDisplayDate($user = null, bool $convertTimeZone = true): string
        {
            $date_value = explode(' ', $this->datetime);
            if (isset($date_value[1]) && '' != $date_value[1]) {
                if ($convertTimeZone) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $date_value is not named in camelCase.
    Open

        public function getDisplayDate($user = null, bool $convertTimeZone = true): string
        {
            $date_value = explode(' ', $this->datetime);
            if (isset($date_value[1]) && '' != $date_value[1]) {
                if ($convertTimeZone) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $insert_date is not named in camelCase.
    Open

        public function getDBInsertDateValue()
        {
            $value = explode(' ', $this->datetime, 2);
            $insert_date = '';
            if (!empty($value[1])) {
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The method __convertToUserFormat is not named in camelCase.
    Open

        public static function __convertToUserFormat($date, $format)
        {
            \App\Log::trace('Start ' . __METHOD__ . ' ' . serialize($date) . ' | ' . $format);
            if (!\is_array($date)) {
                $date = explode(' ', $date);
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method __convertToDBFormat is not named in camelCase.
    Open

        public static function __convertToDBFormat($date, $format)
        {
            if (empty($date)) {
                \App\Log::trace('End ' . __METHOD__);
    
    
    Severity: Minor
    Found in include/fields/DateTimeField.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status