Skip to content

Commit

Permalink
Simplify some code with null coalesce operator
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz authored and derrabus committed Jul 18, 2021
1 parent 9da2a51 commit 0b693cf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion EventListener/DebugHandlersListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $

$this->exceptionHandler = $exceptionHandler;
$this->logger = $logger;
$this->levels = null === $levels ? \E_ALL : $levels;
$this->levels = $levels ?? \E_ALL;
$this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null));
$this->scream = $scream;
$this->fileLinkFormat = $fileLinkFormat;
Expand Down
6 changes: 1 addition & 5 deletions Profiler/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,7 @@ public function setUrl($url)
*/
public function getTime()
{
if (null === $this->time) {
return 0;
}

return $this->time;
return $this->time ?? 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
$bundle
->expects($this->any())
->method('getName')
->willReturn(null === $bundleName ? \get_class($bundle) : $bundleName)
->willReturn($bundleName ?? \get_class($bundle))
;

$bundle
Expand Down

0 comments on commit 0b693cf

Please sign in to comment.