Showing 20 of 20 total issues
There must be one blank line after the last USE statement; 2 found; Open
Open
use Phattarachai\Thaidate\Thaidate;
- Exclude checks
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
Open
}
- Exclude checks
The closing brace for the class must go on the next line after the body Open
Open
}
- Exclude checks
The closing brace for the class must go on the next line after the body Open
Open
}
- Exclude checks
Blank line found at start of control structure Open
Open
if (str_contains($format, 'y')) {
- Exclude checks
Avoid too many return
statements within this method. Open
Open
return $format;
The method thaidate has a boolean flag argument $buddhistEra, which is a certain sign of a Single Responsibility Principle violation. Open
Open
function thaidate(string $format = 'j F Y', $timestamp = 'now', bool $buddhistEra = true)
- Read upRead up
- Exclude checks
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
Open
Carbon::macro('thaidate', function ($format = 'j F Y') {
return thaidate($format, $this->timestamp);
});
- Read upRead up
- Exclude checks
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
Open
* @param string $format The format as same as PHP date function format. See http://php.net/manual/en/function.date.php
- Exclude checks
Line exceeds 120 characters; contains 172 characters Open
Open
public $longDays = ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์'];
- Exclude checks
Argument 2 (replace)
is int
but \str_replace()
takes array|string
Open
Open
return str_replace('y', $year, $format);
- Exclude checks
Reference to undeclared property \Phattarachai\Thaidate\ThaidateServiceProvider->timestamp
Open
Open
return thaidate($format, $this->timestamp);
- Exclude checks
Argument 2 (replace)
is float|int
but \str_replace()
takes array|string
Open
Open
return str_replace('o', (date('o', $timestamp) + 543), $format);
- Exclude checks
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
Open
return str_replace('D', $this->shortDays[$this->dayNum($timestamp)], $format);
- Exclude checks
Doc-block of monthNum
contains declared return type string
which is incompatible with the return type int
declared in the signature Open
Open
* @return false|int|string
- Exclude checks
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
Open
return str_replace('l', $this->longDays[$this->dayNum($timestamp)], $format);
- Exclude checks
Class extends undeclared class \Carbon\Laravel\ServiceProvider
Open
Open
class ThaidateServiceProvider extends ServiceProvider
- Exclude checks
Doc-block of monthNum
contains declared return type false
which is incompatible with the return type int
declared in the signature Open
Open
* @return false|int|string
- Exclude checks
Argument 2 (replace)
is float|int
but \str_replace()
takes array|string
Open
Open
return str_replace('Y', (date('Y', $timestamp) + 543), $format);
- Exclude checks
Call to method macro
from undeclared class \Illuminate\Support\Carbon
Open
Open
Carbon::macro('thaidate', function ($format = 'j F Y') {
- Exclude checks