app/Fields/TimePeriod.php
Avoid using static access to class '\App\Language' in method 'getLabel'. Open
Open
return $time[0] . ' ' . \App\Language::translate(static::$unitLabels[$time[1]]);
- 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
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Get time period label.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public static function getLabel(string $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public static $unitLabels = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$multiplier = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
case 'H':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
[$number,$timePeriod] = explode(':', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'd' => 'LBL_DAYS',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Unit labels.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'H' => 'LBL_HOURS',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$time = explode(':', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
case 'd':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$multiplier = 60 * 24;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Convert to minutes.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
switch ($timePeriod) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public static function convertToMinutes(string $value): int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param string $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$multiplier = 60;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'i' => 'LBL_MINUTES',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param string $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $number * $multiplier;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $time[0] . ' ' . \App\Language::translate(static::$unitLabels[$time[1]]);
- Exclude checks