Skip to content

Commit

Permalink
changed CS rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Emre Çalışkan committed Jan 8, 2025
1 parent 8910c51 commit dc27804
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 60 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'statement_indentation' => false,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
Expand Down
92 changes: 46 additions & 46 deletions src/Carbon/Traits/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,102 +913,102 @@ public function get($name)

return is_numeric($value) ? (int) $value : $value;

// @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language
// @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language
case $name === 'dayName':
return $this->getTranslatedDayName();
// @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language
// @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language
case $name === 'shortDayName':
return $this->getTranslatedShortDayName();
// @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language
// @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language
case $name === 'minDayName':
return $this->getTranslatedMinDayName();
// @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language
// @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language
case $name === 'monthName':
return $this->getTranslatedMonthName();
// @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language
// @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language
case $name === 'shortMonthName':
return $this->getTranslatedShortMonthName();
// @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
// @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
case $name === 'meridiem':
return $this->meridiem(true);
// @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
// @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
case $name === 'upperMeridiem':
return $this->meridiem();
// @property-read int current hour from 1 to 24
// @property-read int current hour from 1 to 24
case $name === 'noZeroHour':
return $this->hour ?: 24;
// @property int
// @property int
case $name === 'milliseconds':
// @property int
// @property int
case $name === 'millisecond':
// @property int
// @property int
case $name === 'milli':
return (int) floor(((int) $this->rawFormat('u')) / 1000);

// @property int 1 through 53
// @property int 1 through 53
case $name === 'week':
return (int) $this->week();

// @property int 1 through 53
// @property int 1 through 53
case $name === 'isoWeek':
return (int) $this->isoWeek();

// @property int year according to week format
// @property int year according to week format
case $name === 'weekYear':
return (int) $this->weekYear();

// @property int year according to ISO week format
// @property int year according to ISO week format
case $name === 'isoWeekYear':
return (int) $this->isoWeekYear();

// @property-read int 51 through 53
// @property-read int 51 through 53
case $name === 'weeksInYear':
return $this->weeksInYear();

// @property-read int 51 through 53
// @property-read int 51 through 53
case $name === 'isoWeeksInYear':
return $this->isoWeeksInYear();

// @property-read int 1 through 5
// @property-read int 1 through 5
case $name === 'weekOfMonth':
return (int) ceil($this->day / static::DAYS_PER_WEEK);

// @property-read int 1 through 5
// @property-read int 1 through 5
case $name === 'weekNumberInMonth':
return (int) ceil(($this->day + $this->avoidMutation()->startOfMonth()->dayOfWeekIso - 1) / static::DAYS_PER_WEEK);

// @property-read int 0 through 6
// @property-read int 0 through 6
case $name === 'firstWeekDay':
return $this->localTranslator ? ($this->getTranslationMessage('first_day_of_week') ?? 0) : static::getWeekStartsAt();

// @property-read int 0 through 6
// @property-read int 0 through 6
case $name === 'lastWeekDay':
return $this->localTranslator ? (($this->getTranslationMessage('first_day_of_week') ?? 0) + static::DAYS_PER_WEEK - 1) % static::DAYS_PER_WEEK : static::getWeekEndsAt();

// @property int 1 through 366
// @property int 1 through 366
case $name === 'dayOfYear':
return 1 + (int) ($this->rawFormat('z'));

// @property-read int 365 or 366
// @property-read int 365 or 366
case $name === 'daysInYear':
return $this->isLeapYear() ? 366 : 365;

// @property int does a diffInYears() with default parameters
// @property int does a diffInYears() with default parameters
case $name === 'age':
return $this->diffInYears();

// @property-read int the quarter of this instance, 1 - 4
// @call isSameUnit
// @property-read int the quarter of this instance, 1 - 4
// @call isSameUnit
case $name === 'quarter':
return (int) ceil($this->month / static::MONTHS_PER_QUARTER);

// @property-read int the decade of this instance
// @call isSameUnit
// @property-read int the decade of this instance
// @call isSameUnit
case $name === 'decade':
return (int) ceil($this->year / static::YEARS_PER_DECADE);

// @property-read int the century of this instance
// @call isSameUnit
// @property-read int the century of this instance
// @call isSameUnit
case $name === 'century':
$factor = 1;
$year = $this->year;
Expand All @@ -1019,8 +1019,8 @@ public function get($name)

return (int) ($factor * ceil($year / static::YEARS_PER_CENTURY));

// @property-read int the millennium of this instance
// @call isSameUnit
// @property-read int the millennium of this instance
// @call isSameUnit
case $name === 'millennium':
$factor = 1;
$year = $this->year;
Expand All @@ -1031,41 +1031,41 @@ public function get($name)

return (int) ($factor * ceil($year / static::YEARS_PER_MILLENNIUM));

// @property int the timezone offset in seconds from UTC
// @property int the timezone offset in seconds from UTC
case $name === 'offset':
return $this->getOffset();

// @property int the timezone offset in minutes from UTC
// @property int the timezone offset in minutes from UTC
case $name === 'offsetMinutes':
return $this->getOffset() / static::SECONDS_PER_MINUTE;

// @property int the timezone offset in hours from UTC
// @property int the timezone offset in hours from UTC
case $name === 'offsetHours':
return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR;

// @property-read bool daylight savings time indicator, true if DST, false otherwise
// @property-read bool daylight savings time indicator, true if DST, false otherwise
case $name === 'dst':
return $this->rawFormat('I') === '1';

// @property-read bool checks if the timezone is local, true if local, false otherwise
// @property-read bool checks if the timezone is local, true if local, false otherwise
case $name === 'local':
return $this->getOffset() === $this->avoidMutation()->setTimezone(date_default_timezone_get())->getOffset();

// @property-read bool checks if the timezone is UTC, true if UTC, false otherwise
// @property-read bool checks if the timezone is UTC, true if UTC, false otherwise
case $name === 'utc':
return $this->getOffset() === 0;

// @property CarbonTimeZone $timezone the current timezone
// @property CarbonTimeZone $tz alias of $timezone
// @property CarbonTimeZone $timezone the current timezone
// @property CarbonTimeZone $tz alias of $timezone
case $name === 'timezone' || $name === 'tz':
return CarbonTimeZone::instance($this->getTimezone());

// @property-read string $timezoneName the current timezone name
// @property-read string $tzName alias of $timezoneName
// @property-read string $timezoneName the current timezone name
// @property-read string $tzName alias of $timezoneName
case $name === 'timezoneName' || $name === 'tzName':
return $this->getTimezone()->getName();

// @property-read string locale of the current instance
// @property-read string locale of the current instance
case $name === 'locale':
return $this->getTranslatorLocale();

Expand Down Expand Up @@ -2630,13 +2630,13 @@ public function __call($method, $parameters)
case 'Utc':
case 'UTC':
return $this->utc;
// @call is Check if the current instance has non-UTC timezone.
// @call is Check if the current instance has non-UTC timezone.
case 'Local':
return $this->local;
// @call is Check if the current instance is a valid date.
// @call is Check if the current instance is a valid date.
case 'Valid':
return $this->year !== 0;
// @call is Check if the current instance is in a daylight saving time.
// @call is Check if the current instance is in a daylight saving time.
case 'DST':
return $this->dst;
}
Expand Down
28 changes: 14 additions & 14 deletions src/Carbon/Traits/Units.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function addRealUnit($unit, $value = 1)
// @call addRealUnit
case 'micro':

// @call addRealUnit
// @call addRealUnit
case 'microsecond':
/* @var CarbonInterface $this */
$diff = $this->microsecond + $value;
Expand All @@ -55,71 +55,71 @@ public function addRealUnit($unit, $value = 1)

return $this->tz('UTC')->modify("@$time.$microtime")->tz($tz);

// @call addRealUnit
// @call addRealUnit
case 'milli':
// @call addRealUnit
// @call addRealUnit
case 'millisecond':
return $this->addRealUnit('microsecond', $value * static::MICROSECONDS_PER_MILLISECOND);

// @call addRealUnit
// @call addRealUnit
case 'second':
break;

// @call addRealUnit
// @call addRealUnit
case 'minute':
$value *= static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'hour':
$value *= static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'day':
$value *= static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'week':
$value *= static::DAYS_PER_WEEK * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'month':
$value *= 30 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'quarter':
$value *= static::MONTHS_PER_QUARTER * 30 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'year':
$value *= 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'decade':
$value *= static::YEARS_PER_DECADE * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'century':
$value *= static::YEARS_PER_CENTURY * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

break;

// @call addRealUnit
// @call addRealUnit
case 'millennium':
$value *= static::YEARS_PER_MILLENNIUM * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE;

Expand Down

0 comments on commit dc27804

Please sign in to comment.