diff --git a/src/Manipulators/BaseManipulator.php b/src/Manipulators/BaseManipulator.php index d26ccd1..61df0e1 100644 --- a/src/Manipulators/BaseManipulator.php +++ b/src/Manipulators/BaseManipulator.php @@ -30,11 +30,9 @@ public function setParams(array $params) */ public function getParam(string $name): mixed { - if (array_key_exists($name, $this->params)) { - return $this->params[$name]; - } - - return null; + return array_key_exists($name, $this->params) + ? $this->params[$name] + : null; } /** diff --git a/src/ServerFactory.php b/src/ServerFactory.php index ac75653..eb08e7b 100644 --- a/src/ServerFactory.php +++ b/src/ServerFactory.php @@ -99,11 +99,7 @@ public function getSource(): FilesystemOperator */ public function getSourcePathPrefix(): ?string { - if (isset($this->config['source_path_prefix'])) { - return $this->config['source_path_prefix']; - } - - return null; + return $this->config['source_path_prefix'] ?? null; } /** @@ -133,11 +129,7 @@ public function getCache(): FilesystemOperator */ public function getCachePathPrefix(): ?string { - if (isset($this->config['cache_path_prefix'])) { - return $this->config['cache_path_prefix']; - } - - return null; + return $this->config['cache_path_prefix'] ?? null; } /** @@ -145,11 +137,7 @@ public function getCachePathPrefix(): ?string */ public function getTempDir(): ?string { - if (isset($this->config['temp_dir'])) { - return $this->config['temp_dir']; - } - - return null; + return $this->config['temp_dir'] ?? null; } /** @@ -169,11 +157,7 @@ public function getCachePathCallable(): ?\Closure */ public function getGroupCacheInFolders(): bool { - if (isset($this->config['group_cache_in_folders'])) { - return $this->config['group_cache_in_folders']; - } - - return true; + return $this->config['group_cache_in_folders'] ?? true; } /** @@ -183,11 +167,7 @@ public function getGroupCacheInFolders(): bool */ public function getCacheWithFileExtensions(): bool { - if (isset($this->config['cache_with_file_extensions'])) { - return $this->config['cache_with_file_extensions']; - } - - return false; + return $this->config['cache_with_file_extensions'] ?? false; } /** @@ -217,11 +197,7 @@ public function getWatermarks(): ?FilesystemOperator */ public function getWatermarksPathPrefix(): ?string { - if (isset($this->config['watermarks_path_prefix'])) { - return $this->config['watermarks_path_prefix']; - } - - return null; + return $this->config['watermarks_path_prefix'] ?? null; } /** @@ -250,15 +226,11 @@ public function getImageManager(): ImageManager $driver = $this->config['driver']; } - if ('gd' === $driver) { - $manager = ImageManager::gd(); - } elseif ('imagick' === $driver) { - $manager = ImageManager::imagick(); - } else { - $manager = ImageManager::withDriver($driver); - } - - return $manager; + return match ($driver) { + 'gd' => ImageManager::gd(), + 'imagick' => ImageManager::imagick(), + default => ImageManager::withDriver($driver), + }; } /** @@ -294,11 +266,7 @@ public function getManipulators(): array */ public function getMaxImageSize(): ?int { - if (isset($this->config['max_image_size'])) { - return $this->config['max_image_size']; - } - - return null; + return $this->config['max_image_size'] ?? null; } /** @@ -308,11 +276,7 @@ public function getMaxImageSize(): ?int */ public function getDefaults(): array { - if (isset($this->config['defaults'])) { - return $this->config['defaults']; - } - - return []; + return $this->config['defaults'] ?? []; } /** @@ -322,11 +286,7 @@ public function getDefaults(): array */ public function getPresets(): array { - if (isset($this->config['presets'])) { - return $this->config['presets']; - } - - return []; + return $this->config['presets'] ?? []; } /** @@ -336,11 +296,7 @@ public function getPresets(): array */ public function getBaseUrl(): ?string { - if (isset($this->config['base_url'])) { - return $this->config['base_url']; - } - - return null; + return $this->config['base_url'] ?? null; } /** @@ -350,11 +306,7 @@ public function getBaseUrl(): ?string */ public function getResponseFactory(): ?ResponseFactoryInterface { - if (isset($this->config['response'])) { - return $this->config['response']; - } - - return null; + return $this->config['response'] ?? null; } /**