Browse Source

Use match().

ADmad 3 years ago
parent
commit
bf3a033955
2 changed files with 14 additions and 20 deletions
  1. 8 9
      src/Core/App.php
  2. 6 11
      src/Core/Configure/Engine/IniConfig.php

+ 8 - 9
src/Core/App.php

@@ -193,15 +193,14 @@ class App
             return (array)Configure::read('App.paths.' . $type);
         }
 
-        if ($type === 'templates') {
-            return [Plugin::templatePath($plugin)];
-        }
-
-        if ($type === 'locales') {
-            return [Plugin::path($plugin) . 'resources' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR];
-        }
-
-        throw new CakeException('Only path types `templates` and `locales` are supported for plugins.');
+        return match ($type) {
+            'templates' => [Plugin::templatePath($plugin)],
+            'locales' => [Plugin::path($plugin) . 'resources' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR],
+            default => throw new CakeException(sprintf(
+                'Invalid type `%s`. Only path types `templates` and `locales` are supported for plugins.',
+                $type
+            ))
+        };
     }
 
     /**

+ 6 - 11
src/Core/Configure/Engine/IniConfig.php

@@ -190,16 +190,11 @@ class IniConfig implements ConfigEngineInterface
      */
     protected function _value(mixed $value): string
     {
-        if ($value === null) {
-            return 'null';
-        }
-        if ($value === true) {
-            return 'true';
-        }
-        if ($value === false) {
-            return 'false';
-        }
-
-        return (string)$value;
+        return match ($value) {
+            null => 'null',
+            true => 'true',
+            false => 'false',
+            default => (string)$value
+        };
     }
 }