From e3a302deffb9c158ff62077c52157b531bd9ad12 Mon Sep 17 00:00:00 2001 From: Nik Samokhvalov Date: Fri, 15 Dec 2017 19:05:08 +0300 Subject: [PATCH] Refactoring init command & update license years --- LICENSE.md | 2 +- src/Environment/Command/InitCommand.php | 30 +++++++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 101d9fe..cdd3148 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright © 2016 [Notamedia Ltd.](http://nota.media) +Copyright © 2016-2017 [Notamedia Ltd.](http://nota.media) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Environment/Command/InitCommand.php b/src/Environment/Command/InitCommand.php index 9cf9a75..ff61b4f 100644 --- a/src/Environment/Command/InitCommand.php +++ b/src/Environment/Command/InitCommand.php @@ -31,10 +31,6 @@ */ class InitCommand extends Command { - /** - * @var string Code of the environment - */ - protected $environmentCode; /** * @var string Path to the environment directory. */ @@ -51,6 +47,10 @@ class InitCommand extends Command * @var array Files that do not need to copy to the application when initializing the environment settings. */ protected $excludedFiles = ['config.php']; + /** + * @var string Type of the initialized environment. + */ + private $type; /** * {@inheritdoc} @@ -92,27 +92,27 @@ protected function initialize(InputInterface $input, OutputInterface $output) } if ($input->getArgument('type')) { - $code = $input->getArgument('type'); + $type = $input->getArgument('type'); - if (!isset($environments[$code])) { + if (!isset($environments[$type])) { throw new \Exception('Invalid environment code!'); } } else { - foreach ($environments as $code => $environment) { - $choices[$code] = $environment['name']; + foreach ($environments as $type => $environment) { + $choices[$type] = $environment['name']; } $questionHelper = $this->getHelper('question'); $question = new ChoiceQuestion('Which environment install?', $choices, false); - $code = $questionHelper->ask($input, $output, $question); + $type = $questionHelper->ask($input, $output, $question); } - if (!isset($environments[$code]['path'])) { + if (!isset($environments[$type]['path'])) { throw new \Exception('Environment path not found!'); } - $this->environmentCode = $code; - $this->dir = $dir . '/' . $environments[$code]['path']; + $this->type = $type; + $this->dir = $dir . '/' . $environments[$type]['path']; $this->config = include $this->dir . '/config.php'; } @@ -361,10 +361,12 @@ protected function configureOptions(InputInterface $input, OutputInterface $outp } /** + * Gets type of initialized environment. + * * @return string */ - public function getEnvironmentCode() + public function getType() { - return $this->environmentCode; + return $this->type; } }