Skip to content

Commit 9ce3379

Browse files
javiereguiluzderrabus
authored andcommitted
Simplify some code with null coalesce operator
1 parent 2d7d406 commit 9ce3379

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

DateFormatter/IntlDateFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti
142142
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported');
143143
}
144144

145-
$this->datetype = null !== $datetype ? $datetype : self::FULL;
146-
$this->timetype = null !== $timetype ? $timetype : self::FULL;
145+
$this->datetype = $datetype ?? self::FULL;
146+
$this->timetype = $timetype ?? self::FULL;
147147

148148
if ('' === ($pattern ?? '')) {
149149
$pattern = $this->getDefaultPattern();

Tests/DateFormatter/AbstractIntlDateFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ protected function getDefaultDateFormatter($pattern = null)
933933
protected function getDateTime($timestamp, $timeZone)
934934
{
935935
$dateTime = new \DateTime();
936-
$dateTime->setTimestamp(null === $timestamp ? time() : $timestamp);
936+
$dateTime->setTimestamp($timestamp ?? time());
937937
$dateTime->setTimezone(new \DateTimeZone($timeZone ?: getenv('TZ') ?: 'UTC'));
938938

939939
return $dateTime;

Util/GitRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static function exec(string $command, string $customErrorMessage = null)
9595
exec(sprintf('%s 2>&1', $command), $output, $result);
9696

9797
if (0 !== $result) {
98-
throw new RuntimeException(null !== $customErrorMessage ? $customErrorMessage : sprintf('The "%s" command failed.', $command));
98+
throw new RuntimeException($customErrorMessage ?? sprintf('The "%s" command failed.', $command));
9999
}
100100

101101
return $output;

0 commit comments

Comments
 (0)