Skip to content

Commit

Permalink
Replace if/else with return match
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
  • Loading branch information
solracsf committed Nov 1, 2023
1 parent 5d05da0 commit 3bedfdf
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions lib/private/Files/FileInfo.php
Expand Up @@ -121,21 +121,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 3bedfdf

Please sign in to comment.