kodedphp /
cache-simple
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * This file is part of the Koded package. |
||
| 4 | * |
||
| 5 | * (c) Mihail Binev <[email protected]> |
||
| 6 | * |
||
| 7 | * Please view the LICENSE distributed with this source code |
||
| 8 | * for the full copyright and license information. |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Koded\Caching\Configuration; |
||
| 12 | |||
| 13 | use Koded\Stdlib\{Config, Configuration}; |
||
| 14 | use Koded\Caching\CacheException; |
||
| 15 | use Throwable; |
||
| 16 | use function join; |
||
| 17 | use function ucfirst; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Class ConfigFactory |
||
| 21 | * |
||
| 22 | * @property int|null $ttl Default Time-To-Live seconds for the cached items |
||
| 23 | * |
||
| 24 | */ |
||
| 25 | class ConfigFactory extends Config |
||
| 26 | { |
||
| 27 | 560 | public function __construct(array $parameters = []) |
|
| 28 | { |
||
| 29 | 560 | parent::__construct(); |
|
| 30 | 560 | $parameters && $this->import($parameters); |
|
|
0 ignored issues
–
show
|
|||
| 31 | } |
||
| 32 | |||
| 33 | 560 | public function build(string $context): Configuration |
|
| 34 | { |
||
| 35 | try { |
||
| 36 | 560 | $class = join('\\', [__NAMESPACE__, ucfirst($context) . 'Configuration']); |
|
| 37 | 560 | return new $class($this->toArray()); |
|
| 38 | // @codeCoverageIgnoreStart |
||
| 39 | } catch (CacheException $e) { |
||
| 40 | throw $e; |
||
| 41 | // @codeCoverageIgnoreEnd |
||
| 42 | 125 | } catch (Throwable) { |
|
| 43 | 125 | return new class($this->toArray()) extends CacheConfiguration {}; |
|
| 44 | } |
||
| 45 | } |
||
| 46 | } |
||
| 47 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.