]> source.dussan.org Git - nextcloud-server.git/commitdiff
Replace if/else with return match 38622/head
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>
Fri, 2 Jun 2023 17:38:03 +0000 (19:38 +0200)
committerGit'Fellow <12234510+solracsf@users.noreply.github.com>
Wed, 1 Nov 2023 09:33:42 +0000 (10:33 +0100)
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
lib/private/Files/FileInfo.php

index 7800074460b09df8ffb33e52d611652812e3199e..21284aca49d54b71beb61d567f2a0d9628170a5b 100644 (file)
@@ -121,21 +121,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,
+               };
        }
 
        /**