Skip to content

Commit

Permalink
Decoration
Browse files Browse the repository at this point in the history
  • Loading branch information
misantron committed Jan 16, 2018
1 parent 631fdf4 commit 991aee5
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: php
php:
- 7.0
- 7.1
- nightly
- 7.2

sudo: false

Expand Down
4 changes: 4 additions & 0 deletions src/Adapter/ConfigAdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace Misantron\Silex\Provider\Adapter;


/**
* Interface ConfigAdapterInterface
* @package Misantron\Silex\Provider\Adapter
*/
interface ConfigAdapterInterface
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Adapter/IniConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace Misantron\Silex\Provider\Adapter;


/**
* Class IniConfigAdapter
* @package Misantron\Silex\Provider\Adapter
*/
class IniConfigAdapter implements ConfigAdapterInterface
{
/**
Expand Down
8 changes: 5 additions & 3 deletions src/Adapter/JsonConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace Misantron\Silex\Provider\Adapter;


/**
* Class JsonConfigAdapter
* @package Misantron\Silex\Provider\Adapter
*/
class JsonConfigAdapter implements ConfigAdapterInterface
{
/**
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/PhpConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions src/Adapter/XmlConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace Misantron\Silex\Provider\Adapter;


/**
* Class XmlConfigAdapter
* @package Misantron\Silex\Provider\Adapter
*/
class XmlConfigAdapter implements ConfigAdapterInterface
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Adapter/YamlConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 991aee5

Please sign in to comment.