phattarachai/thaidate

View on GitHub

Showing 20 of 20 total issues

There must be one blank line after the last USE statement; 2 found;
Open

use Phattarachai\Thaidate\Thaidate;
Severity: Minor
Found in src/function.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }
Severity: Minor
Found in src/function.php by phpcodesniffer

The closing brace for the class must go on the next line after the body
Open

}
Severity: Minor
Found in src/Thaidate.php by phpcodesniffer

The closing brace for the class must go on the next line after the body
Open

}

Blank line found at start of control structure
Open

        if (str_contains($format, 'y')) {
Severity: Minor
Found in src/Thaidate.php by phpcodesniffer

Avoid too many return statements within this method.
Open

        return $format;
Severity: Major
Found in src/Thaidate.php - About 30 mins to fix

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

    function thaidate(string $format = 'j F Y', $timestamp = 'now', bool $buddhistEra = true)
    Severity: Minor
    Found in src/function.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 '\Illuminate\Support\Carbon' in method 'boot'.
    Open

            Carbon::macro('thaidate', function ($format = 'j F Y') {
                return thaidate($format, $this->timestamp);
            });
    Severity: Minor
    Found in src/ThaidateServiceProvider.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

    Line exceeds 120 characters; contains 123 characters
    Open

         * @param string $format The format as same as PHP date function format. See http://php.net/manual/en/function.date.php
    Severity: Minor
    Found in src/Thaidate.php by phpcodesniffer

    Line exceeds 120 characters; contains 172 characters
    Open

        public $longDays = ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์'];
    Severity: Minor
    Found in src/Thaidate.php by phpcodesniffer

    Argument 2 (replace) is int but \str_replace() takes array|string
    Open

                return str_replace('y', $year, $format);
    Severity: Minor
    Found in src/Thaidate.php by phan

    Reference to undeclared property \Phattarachai\Thaidate\ThaidateServiceProvider->timestamp
    Open

                return thaidate($format, $this->timestamp);
    Severity: Minor
    Found in src/ThaidateServiceProvider.php by phan

    Argument 2 (replace) is float|int but \str_replace() takes array|string
    Open

                return str_replace('o', (date('o', $timestamp) + 543), $format);
    Severity: Minor
    Found in src/Thaidate.php by phan

    When fetching an array index from a value of type array{0:'อา.',1:'จ.',2:'อ.',3:'พ.',4:'พฤ.',5:'ศ.',6:'ส.'}, found an array index of type false|string, but expected the index to be of type int
    Open

                return str_replace('D', $this->shortDays[$this->dayNum($timestamp)], $format);
    Severity: Minor
    Found in src/Thaidate.php by phan

    Doc-block of monthNum contains declared return type string which is incompatible with the return type int declared in the signature
    Open

         * @return false|int|string
    Severity: Minor
    Found in src/Thaidate.php by phan

    When fetching an array index from a value of type array{0:'อาทิตย์',1:'จันทร์',2:'อังคาร',3:'พุธ',4:'พฤหัสบดี',5:'ศุกร์',6:'เสาร์'}, found an array index of type false|string, but expected the index to be of type int
    Open

                return str_replace('l', $this->longDays[$this->dayNum($timestamp)], $format);
    Severity: Minor
    Found in src/Thaidate.php by phan

    Class extends undeclared class \Carbon\Laravel\ServiceProvider
    Open

    class ThaidateServiceProvider extends ServiceProvider
    Severity: Critical
    Found in src/ThaidateServiceProvider.php by phan

    Doc-block of monthNum contains declared return type false which is incompatible with the return type int declared in the signature
    Open

         * @return false|int|string
    Severity: Minor
    Found in src/Thaidate.php by phan

    Argument 2 (replace) is float|int but \str_replace() takes array|string
    Open

                return str_replace('Y', (date('Y', $timestamp) + 543), $format);
    Severity: Minor
    Found in src/Thaidate.php by phan

    Call to method macro from undeclared class \Illuminate\Support\Carbon
    Open

            Carbon::macro('thaidate', function ($format = 'j F Y') {
    Severity: Critical
    Found in src/ThaidateServiceProvider.php by phan
    Severity
    Category
    Status
    Source
    Language