Skip to content

Commit

Permalink
Fix bugs found by scrutinizer-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Westin Shafer committed May 17, 2017
1 parent 2370d07 commit e06ed57
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 73 deletions.
36 changes: 1 addition & 35 deletions src/Config/AdaptorConfig.php
Expand Up @@ -3,40 +3,6 @@

namespace WShafer\PSR11FlySystem\Config;

use WShafer\PSR11FlySystem\Exception\MissingConfigException;

class AdaptorConfig
class AdaptorConfig extends ConfigurationAbstract
{
protected $config = [];

public function __construct(array $config)
{
$this->validateConfig($config);
$this->config = $config;
}

protected function validateConfig($config)
{
if (empty($config)) {
throw new MissingConfigException(
'No config found'
);
}

if (empty($config['type'])) {
throw new MissingConfigException(
'No config key of "type" found in adaptor config array.'
);
}
}

public function getType()
{
return $this->config['type'];
}

public function getOptions()
{
return $this->config['options'] ?? [];
}
}
36 changes: 1 addition & 35 deletions src/Config/CacheConfig.php
Expand Up @@ -3,40 +3,6 @@

namespace WShafer\PSR11FlySystem\Config;

use WShafer\PSR11FlySystem\Exception\MissingConfigException;

class CacheConfig
class CacheConfig extends ConfigurationAbstract
{
protected $config = [];

public function __construct(array $config)
{
$this->validateConfig($config);
$this->config = $config;
}

protected function validateConfig($config)
{
if (empty($config)) {
throw new MissingConfigException(
'No config found'
);
}

if (empty($config['type'])) {
throw new MissingConfigException(
'No config key of "type" found in cache config array.'
);
}
}

public function getType()
{
return $this->config['type'];
}

public function getOptions()
{
return $this->config['options'] ?? [];
}
}
42 changes: 42 additions & 0 deletions src/Config/ConfigurationAbstract.php
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);

namespace WShafer\PSR11FlySystem\Config;

use WShafer\PSR11FlySystem\Exception\MissingConfigException;

abstract class ConfigurationAbstract
{
protected $config = [];

public function __construct(array $config)
{
$this->validateConfig($config);
$this->config = $config;
}

protected function validateConfig($config)
{
if (empty($config)) {
throw new MissingConfigException(
'No config found'
);
}

if (empty($config['type'])) {
throw new MissingConfigException(
'No config key of "type" found in adaptor config array.'
);
}
}

public function getType()
{
return $this->config['type'];
}

public function getOptions()
{
return $this->config['options'] ?? [];
}
}
4 changes: 2 additions & 2 deletions src/Config/FileSystemConfig.php
Expand Up @@ -51,7 +51,7 @@ public function validateConfig($config)
/**
* Get the adaptor
*
* @return AdaptorConfig
* @return string
*/
public function getAdaptor()
{
Expand All @@ -61,7 +61,7 @@ public function getAdaptor()
/**
* Get the cache
*
* @return CacheConfig|string
* @return string
*/
public function getCache()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Service/CacheManager.php
Expand Up @@ -11,7 +11,8 @@

class CacheManager implements ContainerInterface
{
protected $config = [];
/** @var MainConfig */
protected $config;

/** @var MapperInterface */
protected $cacheMapper;
Expand Down

0 comments on commit e06ed57

Please sign in to comment.