Merge pull request #38622 from nextcloud/ifElseReturnMatch

Replace if/else with return match
This commit is contained in:
Git'Fellow 2023-11-15 00:05:52 +01:00 committed by GitHub
commit e0cafc8fe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -123,21 +123,14 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
*/
#[\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,
};
}
/**