@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @var array<string, Closure> |
| 33 | 33 | */ |
| 34 | - protected $aAdapters = []; |
|
| 34 | + protected $aAdapters = [ ]; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @var array |
| 38 | 38 | */ |
| 39 | - private $aCurrentAdapter = []; |
|
| 39 | + private $aCurrentAdapter = [ ]; |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @var Config|null |
| 43 | 43 | */ |
| 44 | - protected Config|null $xConfig = null; |
|
| 44 | + protected Config | null $xConfig = null; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * The constructor |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | * @param Closure|null $xConfigGetter |
| 50 | 50 | * @param Translator|null $xTranslator |
| 51 | 51 | */ |
| 52 | - public function __construct(private Closure|null $xConfigGetter = null, |
|
| 53 | - protected Translator|null $xTranslator = null) |
|
| 52 | + public function __construct(private Closure | null $xConfigGetter = null, |
|
| 53 | + protected Translator | null $xTranslator = null) |
|
| 54 | 54 | { |
| 55 | 55 | $this->registerDefaults(); |
| 56 | 56 | |
| 57 | - if($xTranslator !== null) |
|
| 57 | + if ($xTranslator !== null) |
|
| 58 | 58 | { |
| 59 | 59 | $this->loadTranslations($xTranslator); |
| 60 | 60 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function translator(): Translator |
| 93 | 93 | { |
| 94 | - if($this->xTranslator !== null) |
|
| 94 | + if ($this->xTranslator !== null) |
|
| 95 | 95 | { |
| 96 | 96 | return $this->xTranslator; |
| 97 | 97 | } |
@@ -108,25 +108,25 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return void |
| 110 | 110 | */ |
| 111 | - public function register(string $sAdapter, Closure|string $xFactory): void |
|
| 111 | + public function register(string $sAdapter, Closure | string $xFactory): void |
|
| 112 | 112 | { |
| 113 | - if(isset($this->aAdapters[$sAdapter])) |
|
| 113 | + if (isset($this->aAdapters[ $sAdapter ])) |
|
| 114 | 114 | { |
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if(is_string($xFactory)) |
|
| 118 | + if (is_string($xFactory)) |
|
| 119 | 119 | { |
| 120 | 120 | // The adapter is an alias. |
| 121 | - if(!isset($this->aAdapters[$xFactory])) |
|
| 121 | + if (!isset($this->aAdapters[ $xFactory ])) |
|
| 122 | 122 | { |
| 123 | 123 | Logger::error("Jaxon Storage: adapter '{$xFactory}' not configured."); |
| 124 | 124 | throw new Exception($this->translator()->trans('errors.storage.adapter')); |
| 125 | 125 | } |
| 126 | - $xFactory = $this->aAdapters[$xFactory]; |
|
| 126 | + $xFactory = $this->aAdapters[ $xFactory ]; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $this->aAdapters[$sAdapter] = $xFactory; |
|
| 129 | + $this->aAdapters[ $sAdapter ] = $xFactory; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return self |
| 149 | 149 | */ |
| 150 | - public function adapter(string $sAdapter, array $aAdapterOptions = []): self |
|
| 150 | + public function adapter(string $sAdapter, array $aAdapterOptions = [ ]): self |
|
| 151 | 151 | { |
| 152 | 152 | $this->aCurrentAdapter = [ |
| 153 | 153 | 'adapter' => $sAdapter, |
@@ -163,19 +163,19 @@ discard block |
||
| 163 | 163 | * @return Filesystem |
| 164 | 164 | * @throws Exception |
| 165 | 165 | */ |
| 166 | - public function make(string $sRootDir, array $aOptions = []): Filesystem |
|
| 166 | + public function make(string $sRootDir, array $aOptions = [ ]): Filesystem |
|
| 167 | 167 | { |
| 168 | - $sAdapter = $this->aCurrentAdapter['adapter'] ?? ''; |
|
| 169 | - if(!isset($this->aAdapters[$sAdapter])) |
|
| 168 | + $sAdapter = $this->aCurrentAdapter[ 'adapter' ] ?? ''; |
|
| 169 | + if (!isset($this->aAdapters[ $sAdapter ])) |
|
| 170 | 170 | { |
| 171 | 171 | Logger::error("Jaxon Storage: adapter '$sAdapter' not configured."); |
| 172 | 172 | throw new Exception($this->translator()->trans('errors.storage.adapter')); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | // Make the adapter. |
| 176 | - $xAdapter = $this->aAdapters[$sAdapter]($sRootDir, $this->aCurrentAdapter['options']); |
|
| 176 | + $xAdapter = $this->aAdapters[ $sAdapter ]($sRootDir, $this->aCurrentAdapter[ 'options' ]); |
|
| 177 | 177 | // Reset the current adapter. |
| 178 | - $this->aCurrentAdapter = []; |
|
| 178 | + $this->aCurrentAdapter = [ ]; |
|
| 179 | 179 | |
| 180 | 180 | return new Filesystem($xAdapter, ...$aOptions); |
| 181 | 181 | } |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | private function config(): Config |
| 188 | 188 | { |
| 189 | - if($this->xConfig !== null) |
|
| 189 | + if ($this->xConfig !== null) |
|
| 190 | 190 | { |
| 191 | 191 | return $this->xConfig; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if($this->xConfigGetter === null) |
|
| 194 | + if ($this->xConfigGetter === null) |
|
| 195 | 195 | { |
| 196 | 196 | Logger::error("Jaxon Storage: No config getter set."); |
| 197 | 197 | throw new Exception($this->translator()->trans('errors.storage.getter')); |
@@ -209,19 +209,19 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | $xConfig = $this->config(); |
| 211 | 211 | |
| 212 | - $aOptions = $xConfig->getOption("adapters.$sAdapter", []); |
|
| 213 | - if(!is_array($aOptions)) |
|
| 212 | + $aOptions = $xConfig->getOption("adapters.$sAdapter", [ ]); |
|
| 213 | + if (!is_array($aOptions)) |
|
| 214 | 214 | { |
| 215 | 215 | Logger::error("Jaxon Storage: incorrect values in 'adapters.$sAdapter' options."); |
| 216 | 216 | throw new Exception($this->translator()->trans('errors.storage.options')); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if(count($aOptions) === 2 && |
|
| 220 | - is_string($aOptions['alias'] ?? null) && |
|
| 221 | - is_array($aOptions['options'] ?? null)) |
|
| 219 | + if (count($aOptions) === 2 && |
|
| 220 | + is_string($aOptions[ 'alias' ] ?? null) && |
|
| 221 | + is_array($aOptions[ 'options' ] ?? null)) |
|
| 222 | 222 | { |
| 223 | - $this->register($sAdapter, $aOptions['alias']); |
|
| 224 | - $aOptions = $aOptions['options']; |
|
| 223 | + $this->register($sAdapter, $aOptions[ 'alias' ]); |
|
| 224 | + $aOptions = $aOptions[ 'options' ]; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return $this->adapter($sAdapter, $aOptions); |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $sAdapter = $xConfig->getOption("stores.$sOptionName.adapter"); |
| 241 | 241 | $sRootDir = $xConfig->getOption("stores.$sOptionName.dir"); |
| 242 | - $aOptions = $xConfig->getOption("stores.$sOptionName.options", []); |
|
| 243 | - if(!is_string($sAdapter) || !is_string($sRootDir) || !is_array($aOptions)) |
|
| 242 | + $aOptions = $xConfig->getOption("stores.$sOptionName.options", [ ]); |
|
| 243 | + if (!is_string($sAdapter) || !is_string($sRootDir) || !is_array($aOptions)) |
|
| 244 | 244 | { |
| 245 | 245 | Logger::error("Jaxon Storage: incorrect values in 'stores.$sOptionName' options."); |
| 246 | 246 | throw new Exception($this->translator()->trans('errors.storage.options')); |