Skip to content

Commit

Permalink
Merge pull request #38622 from nextcloud/ifElseReturnMatch
Browse files Browse the repository at this point in the history
Replace if/else with return match
  • Loading branch information
solracsf authored Nov 14, 2023
2 parents 9e7fc23 + 3bedfdf commit e0cafc8
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions lib/private/Files/FileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,14 @@ public function offsetUnset($offset): void {
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset) {
if ($offset === 'type') {
return $this->getType();
} elseif ($offset === 'etag') {
return $this->getEtag();
} elseif ($offset === 'size') {
return $this->getSize();
} elseif ($offset === 'mtime') {
return $this->getMTime();
} elseif ($offset === 'permissions') {
return $this->getPermissions();
} elseif (isset($this->data[$offset])) {
return $this->data[$offset];
} else {
return null;
}
return match ($offset) {
'type' => $this->getType(),
'etag' => $this->getEtag(),
'size' => $this->getSize(),
'mtime' => $this->getMTime(),
'permissions' => $this->getPermissions(),
default => $this->data[$offset] ?? null,
};
}

/**
Expand Down

0 comments on commit e0cafc8

Please sign in to comment.