From 991aee5dd81091ab2a6d2daea793e731289201c6 Mon Sep 17 00:00:00 2001 From: misantron Date: Tue, 16 Jan 2018 22:24:59 +0300 Subject: [PATCH] Decoration --- .travis.yml | 2 +- src/Adapter/ConfigAdapterInterface.php | 4 ++++ src/Adapter/IniConfigAdapter.php | 4 ++++ src/Adapter/JsonConfigAdapter.php | 8 +++++--- src/Adapter/PhpConfigAdapter.php | 6 +++--- src/Adapter/XmlConfigAdapter.php | 4 ++++ src/Adapter/YamlConfigAdapter.php | 4 ++++ src/ConfigServiceProvider.php | 2 +- 8 files changed, 26 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a573f4..9481743 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: php php: - 7.0 - 7.1 - - nightly + - 7.2 sudo: false diff --git a/src/Adapter/ConfigAdapterInterface.php b/src/Adapter/ConfigAdapterInterface.php index ce859ee..360113a 100644 --- a/src/Adapter/ConfigAdapterInterface.php +++ b/src/Adapter/ConfigAdapterInterface.php @@ -3,6 +3,10 @@ namespace Misantron\Silex\Provider\Adapter; +/** + * Interface ConfigAdapterInterface + * @package Misantron\Silex\Provider\Adapter + */ interface ConfigAdapterInterface { /** diff --git a/src/Adapter/IniConfigAdapter.php b/src/Adapter/IniConfigAdapter.php index 047f762..668b9a7 100644 --- a/src/Adapter/IniConfigAdapter.php +++ b/src/Adapter/IniConfigAdapter.php @@ -3,6 +3,10 @@ namespace Misantron\Silex\Provider\Adapter; +/** + * Class IniConfigAdapter + * @package Misantron\Silex\Provider\Adapter + */ class IniConfigAdapter implements ConfigAdapterInterface { /** diff --git a/src/Adapter/JsonConfigAdapter.php b/src/Adapter/JsonConfigAdapter.php index e1d6da6..3ae6c48 100644 --- a/src/Adapter/JsonConfigAdapter.php +++ b/src/Adapter/JsonConfigAdapter.php @@ -3,6 +3,10 @@ namespace Misantron\Silex\Provider\Adapter; +/** + * Class JsonConfigAdapter + * @package Misantron\Silex\Provider\Adapter + */ class JsonConfigAdapter implements ConfigAdapterInterface { /** @@ -20,9 +24,7 @@ public function load(\SplFileInfo $file): array $config = json_decode(file_get_contents($file->getRealPath()), true); if (json_last_error() !== JSON_ERROR_NONE) { - throw new \RuntimeException( - sprintf('Unable to parse JSON file: %s', json_last_error_msg()) - ); + throw new \RuntimeException('Unable to parse JSON file: ' . json_last_error_msg()); } return $config; diff --git a/src/Adapter/PhpConfigAdapter.php b/src/Adapter/PhpConfigAdapter.php index e22e7a0..30e8095 100644 --- a/src/Adapter/PhpConfigAdapter.php +++ b/src/Adapter/PhpConfigAdapter.php @@ -11,12 +11,12 @@ class PhpConfigAdapter implements ConfigAdapterInterface */ public function load(\SplFileInfo $file): array { - if ($file->getExtension() !== 'php') { - throw new \RuntimeException('Invalid config file type provided'); - } if (!$file->isReadable()) { throw new \RuntimeException('Config file is not readable'); } + if ($file->getExtension() !== 'php') { + throw new \RuntimeException('Invalid config file type provided'); + } $config = require $file->getRealPath(); if (!is_array($config)) { diff --git a/src/Adapter/XmlConfigAdapter.php b/src/Adapter/XmlConfigAdapter.php index 973680d..27eff4c 100644 --- a/src/Adapter/XmlConfigAdapter.php +++ b/src/Adapter/XmlConfigAdapter.php @@ -3,6 +3,10 @@ namespace Misantron\Silex\Provider\Adapter; +/** + * Class XmlConfigAdapter + * @package Misantron\Silex\Provider\Adapter + */ class XmlConfigAdapter implements ConfigAdapterInterface { /** diff --git a/src/Adapter/YamlConfigAdapter.php b/src/Adapter/YamlConfigAdapter.php index 58dadf8..8ac3327 100644 --- a/src/Adapter/YamlConfigAdapter.php +++ b/src/Adapter/YamlConfigAdapter.php @@ -6,6 +6,10 @@ use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Parser; +/** + * Class YamlConfigAdapter + * @package Misantron\Silex\Provider\Adapter + */ class YamlConfigAdapter implements ConfigAdapterInterface { /** diff --git a/src/ConfigServiceProvider.php b/src/ConfigServiceProvider.php index 0979498..4cae3fd 100644 --- a/src/ConfigServiceProvider.php +++ b/src/ConfigServiceProvider.php @@ -43,7 +43,7 @@ public function __construct( $files = array_filter($paths, function ($file) { return file_exists($file); }); - $config = array_reduce($files, function ($carry, $path) use ($adapter) { + $config = array_reduce($files, function (array $carry, string $path) use ($adapter) { $file = new \SplFileInfo($path); if ($file->isFile()) { $config = $adapter->load($file);