Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
meritoo committed Jun 4, 2019
1 parent bb09236 commit ae39426
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/DependencyInjection/Base/BaseExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,26 @@ protected function getKeysToStopLoadingParametersOn(): array
*/
private function loadServices(ContainerBuilder $container): BaseExtension
{
$services = $this->getServicesFileName();
$servicesWithExtension = $this->verifyServicesFileExtension($services);
$name = $this->getServicesFileName();
$nameWithExtension = $this->getConfigurationFileWithExtension($name);

return $this->loadConfigurationFile($container, $servicesWithExtension);
return $this->loadConfigurationFile($container, $nameWithExtension);
}

/**
* Verifies if given services' configuration file has extension. If not, the default extension of configuration
* files will be used (".yaml" extension).
* Returns name of given configuration file with extension.
* If the file name does not contain extension, default extension will be used (the ".yaml" extension).
*
* @param string $fileName Name of configuration file
* @param string $fileName Name of configuration file (with or without extension)
* @return string
*/
private function verifyServicesFileExtension(string $fileName): string
private function getConfigurationFileWithExtension(string $fileName): string
{
$fileExtension = Miscellaneous::getFileExtension($fileName);

// Use the default extension, if extension of configuration file is unknown
if (empty($fileExtension)) {
$fileName = Miscellaneous::includeFileExtension($fileName, static::CONFIGURATION_DEFAULT_EXTENSION);
return Miscellaneous::includeFileExtension($fileName, static::CONFIGURATION_DEFAULT_EXTENSION);
}

return $fileName;
Expand Down
2 changes: 1 addition & 1 deletion tests/DependencyInjection/Base/BaseExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @copyright Meritoo <http://www.meritoo.pl>
*
* @internal
* @covers \Meritoo\CommonBundle\DependencyInjection\Base\BaseExtension
* @covers \Meritoo\CommonBundle\DependencyInjection\Base\BaseExtension
*/
class BaseExtensionTest extends BaseTestCase
{
Expand Down

0 comments on commit ae39426

Please sign in to comment.