Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
fix : fixed naming of the config files
Browse files Browse the repository at this point in the history
  • Loading branch information
prisis committed Feb 4, 2020
1 parent 81f39d7 commit 9873f63
Show file tree
Hide file tree
Showing 27 changed files with 104 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
extensions: mbstring, xml, ctype, iconv, zip, dom, fileinfo
tools: composer, composer-prefetcher, cs2pr

- name: "Install Narrowspark coding standard and Annotate a Github Pull Request"
- name: "Install Narrowspark coding standard"
run: composer global require narrowspark/coding-standard:3.4.0 --no-interaction --no-progress --profile --no-suggest --optimize-autoloader

- name: "lint php code"
Expand Down
8 changes: 0 additions & 8 deletions .mergify.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/Viserio/Component/Config/.changelog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ return [
'narrowspark',
'framework',
'v' . \Viserio\Component\Foundation\AbstractKernel::VERSION,
['Component: Options Resolver']
['Component: Config']
)
];
16 changes: 8 additions & 8 deletions src/Viserio/Component/Config/Command/ConfigDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,26 +154,26 @@ public function __construct(ConfigDumpCommand $command)
}

/**
* Read the mandatory options and ask for the value.
* Read the mandatory config and ask for the value.
*
* @param string $className
* @param array $dimensions
* @param array $mandatoryOptions
* @param array $mandatoryConfig
*
* @return array
*/
protected function readMandatoryOption(string $className, array $dimensions, array $mandatoryOptions): array
protected function readMandatoryOption(string $className, array $dimensions, array $mandatoryConfig): array
{
$options = [];
$config = [];

foreach ($mandatoryOptions as $key => $mandatoryOption) {
foreach ($mandatoryConfig as $key => $mandatoryOption) {
if (! \is_scalar($mandatoryOption)) {
$options[$key] = $this->readMandatoryOption($className, $dimensions, $mandatoryOptions[$key]);
$config[$key] = $this->readMandatoryOption($className, $dimensions, $mandatoryConfig[$key]);

continue;
}

$options[$mandatoryOption] = $this->command->ask(
$config[$mandatoryOption] = $this->command->ask(
\sprintf(
'%s: Please enter the following mandatory value for [%s]',
$className,
Expand All @@ -182,7 +182,7 @@ protected function readMandatoryOption(string $className, array $dimensions, arr
);
}

return $options;
return $config;
}
};
}
Expand Down
24 changes: 12 additions & 12 deletions src/Viserio/Component/Config/Command/ConfigReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function readConfig(ReflectionClass $reflectionClass): array

if (isset($interfaces[RequiresConfigContract::class])) {
$dimensions = [];
$defaultOptions = [];
$defaultConfig = [];
$key = null;
$class = $reflectionClass->getName();

Expand All @@ -42,16 +42,16 @@ public function readConfig(ReflectionClass $reflectionClass): array
}

if (isset($interfaces[ProvidesDefaultConfigContract::class])) {
$defaultOptions = $class::getDefaultConfig();
$defaultConfig = $class::getDefaultConfig();
}

if (isset($interfaces[RequiresMandatoryConfigContract::class])) {
$config = \array_merge_recursive(
$defaultOptions,
$defaultConfig,
$this->readMandatoryOption($class, $dimensions, $class::getMandatoryConfig())
);
} else {
$config = $defaultOptions;
$config = $defaultConfig;
}

if (\count($dimensions) !== 0) {
Expand All @@ -69,29 +69,29 @@ public function readConfig(ReflectionClass $reflectionClass): array
}

/**
* Read the mandatory options.
* Read the mandatory config.
*
* @param string $className
* @param array $dimensions
* @param array $mandatoryOptions
* @param array $mandatoryConfig
*
* @return array
*/
protected function readMandatoryOption(string $className, array $dimensions, array $mandatoryOptions): array
protected function readMandatoryOption(string $className, array $dimensions, array $mandatoryConfig): array
{
$options = [];
$config = [];

foreach ($mandatoryOptions as $key => $mandatoryOption) {
foreach ($mandatoryConfig as $key => $mandatoryOption) {
if (! \is_scalar($mandatoryOption)) {
$options[$key] = $this->readMandatoryOption($className, $dimensions, $mandatoryOptions[$key]);
$config[$key] = $this->readMandatoryOption($className, $dimensions, $mandatoryConfig[$key]);

continue;
}

$options[$mandatoryOption] = null;
$config[$mandatoryOption] = null;
}

return $options;
return $config;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ConfigReaderCommand extends AbstractCommand
/**
* {@inheritdoc}
*/
protected $description = 'Reads the provided configuration file and displays options for the provided class name.';
protected $description = 'Reads the provided configuration file and displays config for the provided class name.';

/**
* {@inheritdoc}
Expand Down
2 changes: 1 addition & 1 deletion src/Viserio/Component/Config/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center">Viserio Options Resolver Component</h1>
<h1 align="center">Viserio Config Component</h1>
<p align="center">
<a href="https://github.com/narrowspark/framework/releases"><img src="https://img.shields.io/packagist/v/narrowspark/framework.svg?style=flat-square"></a>
<a href="https://php.net/"><img src="https://img.shields.io/badge/php-%5E7.4.0-8892BF.svg?style=flat-square"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

namespace Viserio\Component\Config\Tests\Fixture;

use Viserio\Contract\Config\DeprecatedConfig as DeprecatedOptionsContract;
use Viserio\Contract\Config\DeprecatedConfig as DeprecatedConfigContract;
use Viserio\Contract\Config\ProvidesDefaultConfig as ProvidesDefaultConfigContract;
use Viserio\Contract\Config\RequiresComponentConfigId as RequiresComponentConfigIdContract;
use Viserio\Contract\Config\RequiresMandatoryConfig as RequiresMandatoryConfigContract;

class ConnectionComponentDefaultConfigMandatoryContainedIdWithDeprecationKeyConfiguration implements DeprecatedOptionsContract, ProvidesDefaultConfigContract, RequiresComponentConfigIdContract, RequiresMandatoryConfigContract
class ConnectionComponentDefaultConfigMandatoryContainedIdWithDeprecationKeyConfiguration implements DeprecatedConfigContract, ProvidesDefaultConfigContract, RequiresComponentConfigIdContract, RequiresMandatoryConfigContract
{
/**
* {@inheritdoc}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace Viserio\Component\Config\Tests\Fixture;

use Viserio\Contract\Config\DeprecatedConfig as DeprecatedOptionsContract;
use Viserio\Contract\Config\DeprecatedConfig as DeprecatedConfigContract;
use Viserio\Contract\Config\ProvidesDefaultConfig as ProvidesDefaultConfigContract;
use Viserio\Contract\Config\RequiresComponentConfig as RequiresComponentConfigContract;

class ConnectionComponentDefaultConfigWithDeprecationKeyAndEmptyMessageConfiguration implements DeprecatedOptionsContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
class ConnectionComponentDefaultConfigWithDeprecationKeyAndEmptyMessageConfiguration implements DeprecatedConfigContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
{
/**
* {@inheritdoc}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace Viserio\Component\Config\Tests\Fixture;

use Viserio\Contract\Config\DeprecatedConfig as DeprecatedOptionsContract;
use Viserio\Contract\Config\DeprecatedConfig as DeprecatedConfigContract;
use Viserio\Contract\Config\ProvidesDefaultConfig as ProvidesDefaultConfigContract;
use Viserio\Contract\Config\RequiresComponentConfig as RequiresComponentConfigContract;

class ConnectionComponentDefaultConfigWithDeprecationKeyAndInvalidMessageConfiguration implements DeprecatedOptionsContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
class ConnectionComponentDefaultConfigWithDeprecationKeyAndInvalidMessageConfiguration implements DeprecatedConfigContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
{
/**
* {@inheritdoc}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace Viserio\Component\Config\Tests\Fixture;

use Viserio\Contract\Config\DeprecatedConfig as DeprecatedOptionsContract;
use Viserio\Contract\Config\DeprecatedConfig as DeprecatedConfigContract;
use Viserio\Contract\Config\ProvidesDefaultConfig as ProvidesDefaultConfigContract;
use Viserio\Contract\Config\RequiresComponentConfig as RequiresComponentConfigContract;

class ConnectionComponentDefaultConfigWithDeprecationKeyAndMessageConfiguration implements DeprecatedOptionsContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
class ConnectionComponentDefaultConfigWithDeprecationKeyAndMessageConfiguration implements DeprecatedConfigContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
{
/**
* {@inheritdoc}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace Viserio\Component\Config\Tests\Fixture;

use Viserio\Contract\Config\DeprecatedConfig as DeprecatedOptionsContract;
use Viserio\Contract\Config\DeprecatedConfig as DeprecatedConfigContract;
use Viserio\Contract\Config\ProvidesDefaultConfig as ProvidesDefaultConfigContract;
use Viserio\Contract\Config\RequiresComponentConfig as RequiresComponentConfigContract;

class ConnectionComponentDefaultConfigWithDeprecationKeyConfiguration implements DeprecatedOptionsContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
class ConnectionComponentDefaultConfigWithDeprecationKeyConfiguration implements DeprecatedConfigContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
{
/**
* {@inheritdoc}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Viserio\Contract\Config\RequiresMandatoryConfig as RequiresMandatoryConfigContract;
use Viserio\Contract\Config\RequiresValidatedConfig as RequiresValidatedConfigContract;

class ConnectionComponentDefaultOptionsWithMandatoryConfigurationAndStringValidator implements ProvidesDefaultConfigContract,
class ConnectionComponentDefaultConfigWithMandatoryConfigurationAndStringValidator implements ProvidesDefaultConfigContract,
RequiresComponentConfigContract,
RequiresMandatoryConfigContract,
RequiresValidatedConfigContract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace Viserio\Component\Config\Tests\Fixture;

use Viserio\Contract\Config\DeprecatedConfig as DeprecatedOptionsContract;
use Viserio\Contract\Config\DeprecatedConfig as DeprecatedConfigContract;
use Viserio\Contract\Config\ProvidesDefaultConfig as ProvidesDefaultConfigContract;
use Viserio\Contract\Config\RequiresComponentConfig as RequiresComponentConfigContract;

class ConnectionComponentDefaultConfigWithMultiDimensionalDeprecationKeyConfiguration implements DeprecatedOptionsContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
class ConnectionComponentDefaultConfigWithMultiDimensionalDeprecationKeyConfiguration implements DeprecatedConfigContract, ProvidesDefaultConfigContract, RequiresComponentConfigContract
{
/**
* {@inheritdoc}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

namespace Viserio\Component\Config\Tests\Fixture;

use Viserio\Contract\Config\DeprecatedConfig as DeprecatedOptionsContract;
use Viserio\Contract\Config\DeprecatedConfig as DeprecatedConfigContract;
use Viserio\Contract\Config\RequiresComponentConfig as RequiresComponentConfigContract;

class ConnectionComponentWithNotFoundDeprecationKeyConfiguration implements DeprecatedOptionsContract, RequiresComponentConfigContract
class ConnectionComponentWithNotFoundDeprecationKeyConfiguration implements DeprecatedConfigContract, RequiresComponentConfigContract
{
/**
* {@inheritdoc}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Viserio\Contract\Config\RequiresMandatoryConfig as RequiresMandatoryConfigContract;
use Viserio\Contract\Config\RequiresValidatedConfig as RequiresValidatedConfigContract;

class ConnectionDefaultOptionsWithMandatoryConfigurationAndStringValidator implements ProvidesDefaultConfigContract,
class ConnectionDefaultConfigWithMandatoryConfigurationAndStringValidator implements ProvidesDefaultConfigContract,
RequiresConfigContract,
RequiresMandatoryConfigContract,
RequiresValidatedConfigContract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Viserio\Contract\Config\RequiresMandatoryConfig as RequiresMandatoryConfigContract;
use Viserio\Contract\Config\RequiresValidatedConfig as RequiresValidatedConfigContract;

class ConnectionDefaultOptionsWithMandatoryConfigurationAndTwoLevelArrayAndTwoValidator implements ProvidesDefaultConfigContract,
class ConnectionDefaultConfigWithMandatoryConfigurationAndTwoLevelArrayAndTwoValidator implements ProvidesDefaultConfigContract,
RequiresConfigContract,
RequiresMandatoryConfigContract,
RequiresValidatedConfigContract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Viserio\Contract\Config\RequiresMandatoryConfig as RequiresMandatoryConfigContract;
use Viserio\Contract\Config\RequiresValidatedConfig as RequiresValidatedConfigContract;

class ConnectionDefaultOptionsWithMandatoryConfigurationAndTwoLevelArrayValidator implements ProvidesDefaultConfigContract,
class ConnectionDefaultConfigWithMandatoryConfigurationAndTwoLevelArrayValidator implements ProvidesDefaultConfigContract,
RequiresConfigContract,
RequiresMandatoryConfigContract,
RequiresValidatedConfigContract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Viserio\Contract\Config\RequiresMandatoryConfig as RequiresMandatoryConfigContract;
use Viserio\Contract\Config\RequiresValidatedConfig as RequiresValidatedConfigContract;

class ConnectionDefaultOptionsWithMandatoryConfigurationAndTwoValidator implements ProvidesDefaultConfigContract,
class ConnectionDefaultConfigWithMandatoryConfigurationAndTwoValidator implements ProvidesDefaultConfigContract,
RequiresConfigContract,
RequiresMandatoryConfigContract,
RequiresValidatedConfigContract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Viserio\Contract\Config\RequiresMandatoryConfig as RequiresMandatoryConfigContract;
use Viserio\Contract\Config\RequiresValidatedConfig as RequiresValidatedConfigContract;

class ConnectionDefaultOptionsWithMandatoryConfigurationAndValidator implements ProvidesDefaultConfigContract,
class ConnectionDefaultConfigWithMandatoryConfigurationAndValidator implements ProvidesDefaultConfigContract,
RequiresConfigContract,
RequiresMandatoryConfigContract,
RequiresValidatedConfigContract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Viserio\Contract\Config\RequiresMandatoryConfig as RequiresMandatoryConfigContract;
use Viserio\Contract\Config\RequiresValidatedConfig as RequiresValidatedConfigContract;

class ConnectionDefaultOptionsWithMandatoryNullValueConfigurationAndStringValidator implements RequiresConfigContract,
class ConnectionDefaultConfigWithMandatoryNullValueConfigurationAndStringValidator implements RequiresConfigContract,
RequiresMandatoryConfigContract,
RequiresValidatedConfigContract
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class UniversalContainerIdComponentConfiguration implements ProvidesDefaultConfi
];

/** @var array */
private static $getMandatoryOptions = [
private static $getMandatoryConfig = [
'params' => ['user', 'dbname'],
'driverClass',
];

/** @var array */
private static $getDefaultOptions = [
private static $getDefaultConfig = [
'params' => [
'host' => 'awesomehost',
'port' => '4444',
Expand All @@ -46,12 +46,12 @@ public static function getDimensions(): iterable

public static function getMandatoryConfig(): iterable
{
return self::getData('getMandatoryOptions');
return self::getData('getMandatoryConfig');
}

public static function getDefaultConfig(): iterable
{
return self::getData('getDefaultOptions');
return self::getData('getDefaultConfig');
}

private static function getData($name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Viserio\Component\Config\Tests\Fixture\ConnectionComponentDefaultConfigConfiguration;
use Viserio\Component\Config\Tests\Fixture\ConnectionComponentDefaultConfigMandatoryContainedIdConfiguration;
use Viserio\Component\Config\Tests\Fixture\ConnectionDefaultConfigConfiguration;
use Viserio\Component\Config\Tests\Fixture\ConnectionDefaultOptionsWithMandatoryConfigurationAndTwoLevelArrayValidator;
use Viserio\Component\Config\Tests\Fixture\ConnectionDefaultConfigWithMandatoryConfigurationAndTwoLevelArrayValidator;
use Viserio\Component\Console\Tester\CommandTestCase;

/**
Expand Down Expand Up @@ -101,7 +101,7 @@ public static function provideReadCases(): iterable
[],
],
[
ConnectionDefaultOptionsWithMandatoryConfigurationAndTwoLevelArrayValidator::class,
ConnectionDefaultConfigWithMandatoryConfigurationAndTwoLevelArrayValidator::class,
[
'params' => [
'host' => 'awesomehost',
Expand Down
Loading

0 comments on commit 9873f63

Please sign in to comment.