@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | protected function configure() |
32 | 32 | { |
33 | 33 | $this |
34 | - ->setName('create') |
|
35 | - ->setDescription('Create a project based on the given template') |
|
36 | - ->addArgument('template', InputArgument::REQUIRED) |
|
37 | - ->addOption( |
|
34 | + ->setName ('create') |
|
35 | + ->setDescription ('Create a project based on the given template') |
|
36 | + ->addArgument ('template', InputArgument::REQUIRED) |
|
37 | + ->addOption ( |
|
38 | 38 | 'dir', |
39 | 39 | null, |
40 | 40 | InputOption::VALUE_OPTIONAL, |
41 | 41 | 'Which name must the directory to create have?' |
42 | 42 | ) |
43 | - ->addOption( |
|
43 | + ->addOption ( |
|
44 | 44 | 'name', |
45 | 45 | null, |
46 | 46 | InputOption::VALUE_OPTIONAL, |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | protected function execute(InputInterface $input, OutputInterface $output): void |
60 | 60 | { |
61 | 61 | try { |
62 | - $this->executeCommand($input, $output); |
|
62 | + $this->executeCommand ($input, $output); |
|
63 | 63 | } catch (BoilerException $exception) { |
64 | - $output->write('<error>' . $exception->getMessage() . '</error>'); |
|
64 | + $output->write ('<error>' . $exception->getMessage () . '</error>'); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | '{#PROJECT_NAME#}' => $this->variables['template_name'], |
79 | 79 | ]; |
80 | 80 | |
81 | - return str_replace(array_keys($variables), array_values($variables), $contents); |
|
81 | + return str_replace (array_keys ($variables), array_values ($variables), $contents); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | protected function executeScripts(OutputInterface $output, array $template): void |
91 | 91 | { |
92 | 92 | foreach ($template['steps'] as $step) { |
93 | - $output->writeln('<info>Executing ' . $template[$step]['name'] . '</info>'); |
|
94 | - $scripts = is_array($template[$step]['script']) ? $template[$step]['script'] : [$template[$step]['script']]; |
|
93 | + $output->writeln ('<info>Executing ' . $template[$step]['name'] . '</info>'); |
|
94 | + $scripts = is_array ($template[$step]['script']) ? $template[$step]['script'] : [$template[$step]['script']]; |
|
95 | 95 | foreach ($scripts as $script) { |
96 | - exec($this->replaceVariables($script)); |
|
96 | + exec ($this->replaceVariables ($script)); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -108,38 +108,38 @@ discard block |
||
108 | 108 | */ |
109 | 109 | private function executeCommand(InputInterface $input, OutputInterface $output): void |
110 | 110 | { |
111 | - $this->paths = $this->configuration->getPaths(); |
|
111 | + $this->paths = $this->configuration->getPaths (); |
|
112 | 112 | |
113 | 113 | if (empty($this->paths)) { |
114 | - throw new BoilerException('No paths configured'); |
|
114 | + throw new BoilerException ('No paths configured'); |
|
115 | 115 | } |
116 | 116 | |
117 | - $templateFileName = $input->getArgument('template'); |
|
117 | + $templateFileName = $input->getArgument ('template'); |
|
118 | 118 | |
119 | 119 | if (empty($templateFileName)) { |
120 | - throw new BoilerException('No template given.'); |
|
121 | - } elseif (is_array($templateFileName)) { |
|
122 | - throw new BoilerException('Only one template is allowed.'); |
|
120 | + throw new BoilerException ('No template given.'); |
|
121 | + } elseif (is_array ($templateFileName)) { |
|
122 | + throw new BoilerException ('Only one template is allowed.'); |
|
123 | 123 | } |
124 | 124 | |
125 | - $template = Template::getInstance()->searchTemplateByFilenameInGivenPaths($templateFileName, $this->paths); |
|
125 | + $template = Template::getInstance ()->searchTemplateByFilenameInGivenPaths ($templateFileName, $this->paths); |
|
126 | 126 | |
127 | - $templateName = $input->getOption('name') ? $input->getOption('name') : $template['name']; |
|
128 | - $directoryName = $input->getOption('dir') ?: $templateFileName; |
|
127 | + $templateName = $input->getOption ('name') ? $input->getOption ('name') : $template['name']; |
|
128 | + $directoryName = $input->getOption ('dir') ?: $templateFileName; |
|
129 | 129 | |
130 | - if (file_exists($directoryName)) { |
|
131 | - throw new BoilerException('Folder already exists'); |
|
130 | + if (file_exists ($directoryName)) { |
|
131 | + throw new BoilerException ('Folder already exists'); |
|
132 | 132 | } |
133 | 133 | |
134 | - $output->writeln('<info>Installing ' . $templateName . '</info>'); |
|
134 | + $output->writeln ('<info>Installing ' . $templateName . '</info>'); |
|
135 | 135 | $this->variables['template_name'] = $templateName; |
136 | 136 | |
137 | - mkdir($directoryName); |
|
138 | - chdir($directoryName); |
|
137 | + mkdir ($directoryName); |
|
138 | + chdir ($directoryName); |
|
139 | 139 | |
140 | - $this->prepareTemplateFolder($templateFileName); |
|
140 | + $this->prepareTemplateFolder ($templateFileName); |
|
141 | 141 | |
142 | - $this->executeScripts($output, $template); |
|
142 | + $this->executeScripts ($output, $template); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -149,27 +149,27 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function prepareTemplateFolder(string $name): void |
151 | 151 | { |
152 | - $finder = new Finder(); |
|
152 | + $finder = new Finder (); |
|
153 | 153 | foreach ($this->paths as $directory) { |
154 | 154 | $templateDir = $directory . '/' . $name; |
155 | - if (!is_dir($templateDir)) { |
|
155 | + if (!is_dir ($templateDir)) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | 158 | |
159 | - $finder->in($templateDir) |
|
160 | - ->notName($name . '.yml') |
|
161 | - ->sortByType() |
|
162 | - ->ignoreDotFiles(false); |
|
159 | + $finder->in ($templateDir) |
|
160 | + ->notName ($name . '.yml') |
|
161 | + ->sortByType () |
|
162 | + ->ignoreDotFiles (false); |
|
163 | 163 | |
164 | 164 | foreach ($finder as $file) { |
165 | - if ($file->isDir()) { |
|
166 | - mkdir($file->getFilename(), 0777, true); |
|
165 | + if ($file->isDir ()) { |
|
166 | + mkdir ($file->getFilename (), 0777, true); |
|
167 | 167 | continue; |
168 | 168 | } |
169 | 169 | |
170 | - if ($file->isFile()) { |
|
171 | - copy($file->getPathname(), $file->getRelativePathname()); |
|
172 | - file_put_contents($file->getRelativePathname(), $this->replaceVariables($file->getContents())); |
|
170 | + if ($file->isFile ()) { |
|
171 | + copy ($file->getPathname (), $file->getRelativePathname ()); |
|
172 | + file_put_contents ($file->getRelativePathname (), $this->replaceVariables ($file->getContents ())); |
|
173 | 173 | continue; |
174 | 174 | } |
175 | 175 | } |
@@ -21,13 +21,13 @@ |
||
21 | 21 | */ |
22 | 22 | public function __construct(string $name = null) |
23 | 23 | { |
24 | - $this->configuration = $this->getConfiguration(); |
|
24 | + $this->configuration = $this->getConfiguration (); |
|
25 | 25 | |
26 | - parent::__construct($name); |
|
26 | + parent::__construct ($name); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | final private function getConfiguration(): Configuration |
30 | 30 | { |
31 | - return Configuration::getInstance(); |
|
31 | + return Configuration::getInstance (); |
|
32 | 32 | } |
33 | 33 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | protected function configure() |
17 | 17 | { |
18 | 18 | $this |
19 | - ->setName('paths') |
|
20 | - ->setDescription('List all paths to search for templates'); |
|
19 | + ->setName ('paths') |
|
20 | + ->setDescription ('List all paths to search for templates'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function execute(InputInterface $input, OutputInterface $output) |
34 | 34 | { |
35 | - $paths = $this->configuration->getPaths(); |
|
35 | + $paths = $this->configuration->getPaths (); |
|
36 | 36 | |
37 | 37 | if (empty($paths)) { |
38 | - $output->writeln('<info>No paths set...</info>'); |
|
38 | + $output->writeln ('<info>No paths set...</info>'); |
|
39 | 39 | |
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $table = new Table($output); |
|
43 | + $table = new Table ($output); |
|
44 | 44 | $table |
45 | - ->setHeaders(['Path']) |
|
46 | - ->setRows(array_map(function ($path) { |
|
45 | + ->setHeaders (['Path']) |
|
46 | + ->setRows (array_map (function($path) { |
|
47 | 47 | return [$path]; |
48 | 48 | }, $paths)); |
49 | - $table->render(); |
|
49 | + $table->render (); |
|
50 | 50 | } |
51 | 51 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $this->configLocation = $_SERVER['HOME'] . $this->configLocation; |
50 | 50 | $this->configFileLocation = $this->configLocation . '/' . $this->configFile; |
51 | - $this->setupConfiguration(); |
|
51 | + $this->setupConfiguration (); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public static function getInstance() |
60 | 60 | { |
61 | 61 | if (self::$instance === null) { |
62 | - self::$instance = new Configuration(); |
|
62 | + self::$instance = new Configuration (); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return self::$instance; |
@@ -67,31 +67,31 @@ discard block |
||
67 | 67 | |
68 | 68 | private function setupConfiguration() |
69 | 69 | { |
70 | - if (!is_dir($this->configLocation)) { |
|
71 | - mkdir($this->configLocation, 0777, true); |
|
70 | + if (!is_dir ($this->configLocation)) { |
|
71 | + mkdir ($this->configLocation, 0777, true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if (!file_exists($this->configFileLocation)) { |
|
74 | + if (!file_exists ($this->configFileLocation)) { |
|
75 | 75 | $this->config = [ |
76 | 76 | 'paths' => [], |
77 | 77 | ]; |
78 | - $this->saveConfigurationFile(); |
|
78 | + $this->saveConfigurationFile (); |
|
79 | 79 | } |
80 | 80 | |
81 | - $this->loadConfiguration(); |
|
81 | + $this->loadConfiguration (); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | public function loadConfiguration() |
85 | 85 | { |
86 | - $json = file_get_contents($this->configFileLocation); |
|
86 | + $json = file_get_contents ($this->configFileLocation); |
|
87 | 87 | $this->config = $json ? json_decode($json, true) : []; |
88 | 88 | } |
89 | 89 | |
90 | 90 | private function saveConfigurationFile() |
91 | 91 | { |
92 | - file_put_contents( |
|
92 | + file_put_contents ( |
|
93 | 93 | $this->configFileLocation, |
94 | - json_encode($this->config, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT) |
|
94 | + json_encode ($this->config, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT) |
|
95 | 95 | ); |
96 | 96 | } |
97 | 97 | |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function addPath(string $path): bool |
106 | 106 | { |
107 | - if (!is_array($this->config['paths']) || !in_array($path, $this->config['paths'])) { |
|
107 | + if (!is_array ($this->config['paths']) || !in_array ($path, $this->config['paths'])) { |
|
108 | 108 | $this->config['paths'][] = $path; |
109 | - $this->saveConfigurationFile(); |
|
109 | + $this->saveConfigurationFile (); |
|
110 | 110 | |
111 | 111 | return true; |
112 | 112 | } |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function removePath(string $path): bool |
125 | 125 | { |
126 | - $arrayKey = array_search($path, $this->config['paths']); |
|
127 | - if (is_array($this->config['paths']) && $arrayKey !== false) { |
|
126 | + $arrayKey = array_search ($path, $this->config['paths']); |
|
127 | + if (is_array ($this->config['paths']) && $arrayKey !== false) { |
|
128 | 128 | unset($this->config['paths'][$arrayKey]); |
129 | - $this->saveConfigurationFile(); |
|
129 | + $this->saveConfigurationFile (); |
|
130 | 130 | |
131 | 131 | return true; |
132 | 132 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function getPaths(): array |
143 | 143 | { |
144 | - if (array_key_exists('paths', $this->config) && is_array($this->config['paths'])) { |
|
144 | + if (array_key_exists ('paths', $this->config) && is_array ($this->config['paths'])) { |
|
145 | 145 | return $this->config['paths']; |
146 | 146 | } |
147 | 147 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public static function getInstance() |
41 | 41 | { |
42 | 42 | if (self::$instance === null) { |
43 | - self::$instance = new Template(); |
|
43 | + self::$instance = new Template (); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return self::$instance; |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | public function searchTemplateByFilenameInGivenPaths(string $fileName, array $paths): array |
60 | 60 | { |
61 | 61 | $this->paths = $paths; |
62 | - $template = $this->findAndParseTemplate($fileName); |
|
63 | - $extraTemplates = $this->getIncludedTemplates($template); |
|
64 | - $template = $this->mergeExtraTemplates($template, $extraTemplates); |
|
62 | + $template = $this->findAndParseTemplate ($fileName); |
|
63 | + $extraTemplates = $this->getIncludedTemplates ($template); |
|
64 | + $template = $this->mergeExtraTemplates ($template, $extraTemplates); |
|
65 | 65 | |
66 | - $this->validateTemplate($template); |
|
66 | + $this->validateTemplate ($template); |
|
67 | 67 | |
68 | 68 | return $template; |
69 | 69 | } |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | */ |
80 | 80 | protected function findAndParseTemplate(string $templateFileName): array |
81 | 81 | { |
82 | - $templateFile = $this->getTemplate($templateFileName); |
|
82 | + $templateFile = $this->getTemplate ($templateFileName); |
|
83 | 83 | |
84 | - if (is_null($templateFile)) { |
|
85 | - throw new BoilerException('No template found with name ' . $templateFileName); |
|
84 | + if (is_null ($templateFile)) { |
|
85 | + throw new BoilerException ('No template found with name ' . $templateFileName); |
|
86 | 86 | } |
87 | 87 | |
88 | - $pathName = $templateFile->getPathname(); |
|
89 | - $template = $this->parseTemplateFile($pathName); |
|
88 | + $pathName = $templateFile->getPathname (); |
|
89 | + $template = $this->parseTemplateFile ($pathName); |
|
90 | 90 | |
91 | - if (!is_array($template)) { |
|
92 | - throw new BoilerException('Template could not be parsed as a yaml file'); |
|
91 | + if (!is_array ($template)) { |
|
92 | + throw new BoilerException ('Template could not be parsed as a yaml file'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $template; |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | protected function getTemplate(string $name): ?SplFileInfo |
106 | 106 | { |
107 | 107 | foreach ($this->paths as $directory) { |
108 | - $fileInDirectory = $this->findYamlFileInDirectory($name, $directory . '/' . $name); |
|
108 | + $fileInDirectory = $this->findYamlFileInDirectory ($name, $directory . '/' . $name); |
|
109 | 109 | |
110 | - if (!is_null($fileInDirectory)) { |
|
110 | + if (!is_null ($fileInDirectory)) { |
|
111 | 111 | return $fileInDirectory; |
112 | 112 | } |
113 | 113 | |
114 | - $file = $this->findYamlFileInDirectory($name, $directory); |
|
114 | + $file = $this->findYamlFileInDirectory ($name, $directory); |
|
115 | 115 | |
116 | - if (!is_null($file)) { |
|
116 | + if (!is_null ($file)) { |
|
117 | 117 | return $file; |
118 | 118 | } |
119 | 119 | } |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | protected function parseTemplateFile(string $path) |
134 | 134 | { |
135 | 135 | try { |
136 | - return Yaml::parseFile($path); |
|
136 | + return Yaml::parseFile ($path); |
|
137 | 137 | } catch (ParseException $exception) { |
138 | - throw new BoilerException( |
|
138 | + throw new BoilerException ( |
|
139 | 139 | 'Template file located at `' . $path . '` could not be parsed', |
140 | - $exception->getCode(), |
|
140 | + $exception->getCode (), |
|
141 | 141 | $exception |
142 | 142 | ); |
143 | 143 | } |
@@ -153,16 +153,16 @@ discard block |
||
153 | 153 | */ |
154 | 154 | protected function findYamlFileInDirectory(string $name, string $directory) |
155 | 155 | { |
156 | - if (!is_dir($directory)) { |
|
156 | + if (!is_dir ($directory)) { |
|
157 | 157 | return null; |
158 | 158 | } |
159 | 159 | |
160 | 160 | $name .= '.yml'; |
161 | - $finder = new Finder(); |
|
162 | - $finder->files()->name($name)->depth('== 0')->in($directory); |
|
161 | + $finder = new Finder (); |
|
162 | + $finder->files ()->name ($name)->depth ('== 0')->in ($directory); |
|
163 | 163 | |
164 | 164 | foreach ($finder as $file) { |
165 | - if ($file->getFilename() === $name) { |
|
165 | + if ($file->getFilename () === $name) { |
|
166 | 166 | return $file; |
167 | 167 | } |
168 | 168 | } |
@@ -180,23 +180,23 @@ discard block |
||
180 | 180 | */ |
181 | 181 | protected function getIncludedTemplates(array $template): array |
182 | 182 | { |
183 | - if (!array_key_exists('include', $template)) { |
|
183 | + if (!array_key_exists ('include', $template)) { |
|
184 | 184 | return []; |
185 | 185 | } |
186 | 186 | |
187 | - if (!is_array($template['include'])) { |
|
188 | - throw new BoilerException('Include function must be an array.'); |
|
187 | + if (!is_array ($template['include'])) { |
|
188 | + throw new BoilerException ('Include function must be an array.'); |
|
189 | 189 | } |
190 | 190 | |
191 | - return array_map(function ($fileName) { |
|
192 | - $templateFile = $this->getTemplate($fileName); |
|
191 | + return array_map (function($fileName) { |
|
192 | + $templateFile = $this->getTemplate ($fileName); |
|
193 | 193 | if ($templateFile === null) { |
194 | - throw new BoilerException('Included file `' . $fileName . '` does not exists'); |
|
194 | + throw new BoilerException ('Included file `' . $fileName . '` does not exists'); |
|
195 | 195 | } |
196 | - $template = $this->parseTemplateFile($templateFile->getPathname()); |
|
196 | + $template = $this->parseTemplateFile ($templateFile->getPathname ()); |
|
197 | 197 | |
198 | 198 | if (!$template) { |
199 | - throw new BoilerException('Included file `' . $fileName . '` cannot be parsed'); |
|
199 | + throw new BoilerException ('Included file `' . $fileName . '` cannot be parsed'); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $template; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | protected function mergeExtraTemplates(array $template, array $extraTemplates): array |
215 | 215 | { |
216 | 216 | foreach ($extraTemplates as $extraTemplate) { |
217 | - $template = array_merge($template, $extraTemplate); |
|
217 | + $template = array_merge ($template, $extraTemplate); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | return $template; |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | */ |
230 | 230 | protected function validateTemplate(array $template): void |
231 | 231 | { |
232 | - if (!array_key_exists('name', $template) || empty($template['name'])) { |
|
233 | - throw new BoilerException('There\'s no name defined in the template'); |
|
232 | + if (!array_key_exists ('name', $template) || empty($template['name'])) { |
|
233 | + throw new BoilerException ('There\'s no name defined in the template'); |
|
234 | 234 | } |
235 | 235 | |
236 | - if (!array_key_exists('steps', $template) || !is_array($template['steps']) || empty($template['steps'])) { |
|
237 | - throw new BoilerException('There are no steps defined in the template'); |
|
236 | + if (!array_key_exists ('steps', $template) || !is_array ($template['steps']) || empty($template['steps'])) { |
|
237 | + throw new BoilerException ('There are no steps defined in the template'); |
|
238 | 238 | } |
239 | 239 | |
240 | - $this->validateSteps($template); |
|
240 | + $this->validateSteps ($template); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -251,16 +251,16 @@ discard block |
||
251 | 251 | { |
252 | 252 | $steps = $template['steps']; |
253 | 253 | foreach ($steps as $step) { |
254 | - if (!array_key_exists($step, $template)) { |
|
255 | - throw new BoilerException('The step `' . $step . '` does not exists.'); |
|
254 | + if (!array_key_exists ($step, $template)) { |
|
255 | + throw new BoilerException ('The step `' . $step . '` does not exists.'); |
|
256 | 256 | } |
257 | 257 | |
258 | - if (!array_key_exists('name', $template[$step])) { |
|
259 | - throw new BoilerException('No `name` set for the step `' . $step . '`'); |
|
258 | + if (!array_key_exists ('name', $template[$step])) { |
|
259 | + throw new BoilerException ('No `name` set for the step `' . $step . '`'); |
|
260 | 260 | } |
261 | 261 | |
262 | - if (!array_key_exists('script', $template[$step])) { |
|
263 | - throw new BoilerException('No `script` set for the step `' . $step . '`'); |
|
262 | + if (!array_key_exists ('script', $template[$step])) { |
|
263 | + throw new BoilerException ('No `script` set for the step `' . $step . '`'); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | protected function configure() |
17 | 17 | { |
18 | 18 | $this |
19 | - ->setName('remove') |
|
20 | - ->setDescription('Remove the directory as a place to search for boiler-templates.') |
|
21 | - ->addArgument('directory', InputArgument::OPTIONAL); |
|
19 | + ->setName ('remove') |
|
20 | + ->setDescription ('Remove the directory as a place to search for boiler-templates.') |
|
21 | + ->addArgument ('directory', InputArgument::OPTIONAL); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -32,31 +32,31 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function execute(InputInterface $input, OutputInterface $output) |
34 | 34 | { |
35 | - $directory = $input->getArgument('directory'); |
|
35 | + $directory = $input->getArgument ('directory'); |
|
36 | 36 | |
37 | - if (is_array($directory)) { |
|
38 | - throw new BoilerException('Only one directory is allowed.'); |
|
37 | + if (is_array ($directory)) { |
|
38 | + throw new BoilerException ('Only one directory is allowed.'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | if (empty($directory)) { |
42 | - $directory = getcwd(); |
|
42 | + $directory = getcwd (); |
|
43 | 43 | |
44 | 44 | if ($directory === false) { |
45 | - throw new BoilerException('Current directory cannot be removed.'); |
|
45 | + throw new BoilerException ('Current directory cannot be removed.'); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - $path = realpath($directory); |
|
49 | + $path = realpath ($directory); |
|
50 | 50 | |
51 | - if ($path === false || !file_exists($path)) { |
|
52 | - throw new BoilerException('Directory does not exists'); |
|
51 | + if ($path === false || !file_exists ($path)) { |
|
52 | + throw new BoilerException ('Directory does not exists'); |
|
53 | 53 | } |
54 | 54 | |
55 | - $paths = $this->configuration->getPaths(); |
|
56 | - if (!in_array($path, $paths)) { |
|
57 | - throw new BoilerException('Folder not in paths.'); |
|
55 | + $paths = $this->configuration->getPaths (); |
|
56 | + if (!in_array ($path, $paths)) { |
|
57 | + throw new BoilerException ('Folder not in paths.'); |
|
58 | 58 | } |
59 | - $result = $this->configuration->removePath($path); |
|
59 | + $result = $this->configuration->removePath ($path); |
|
60 | 60 | |
61 | 61 | $resultMessage = '<comment>Directory successfully removed</comment>'; |
62 | 62 | |
@@ -64,6 +64,6 @@ discard block |
||
64 | 64 | $resultMessage = '<error>Directory could not be removed</error>'; |
65 | 65 | } |
66 | 66 | |
67 | - $output->writeln($resultMessage); |
|
67 | + $output->writeln ($resultMessage); |
|
68 | 68 | } |
69 | 69 | } |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | protected function configure() |
17 | 17 | { |
18 | 18 | $this |
19 | - ->setName('setup') |
|
20 | - ->setDescription('Set the directory as a place to search for boiler-templates.') |
|
21 | - ->addArgument('directory', InputArgument::OPTIONAL); |
|
19 | + ->setName ('setup') |
|
20 | + ->setDescription ('Set the directory as a place to search for boiler-templates.') |
|
21 | + ->addArgument ('directory', InputArgument::OPTIONAL); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -32,31 +32,31 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function execute(InputInterface $input, OutputInterface $output) |
34 | 34 | { |
35 | - $directory = $input->getArgument('directory'); |
|
35 | + $directory = $input->getArgument ('directory'); |
|
36 | 36 | |
37 | - if (is_array($directory)) { |
|
38 | - throw new BoilerException('Only one directory is allowed.'); |
|
37 | + if (is_array ($directory)) { |
|
38 | + throw new BoilerException ('Only one directory is allowed.'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | if (empty($directory)) { |
42 | - $directory = getcwd(); |
|
42 | + $directory = getcwd (); |
|
43 | 43 | |
44 | 44 | if ($directory === false) { |
45 | - throw new BoilerException('Current directory cannot be added.'); |
|
45 | + throw new BoilerException ('Current directory cannot be added.'); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - $path = realpath($directory); |
|
49 | + $path = realpath ($directory); |
|
50 | 50 | |
51 | - if ($path === false || !file_exists($path)) { |
|
52 | - throw new BoilerException('Directory does not exists'); |
|
51 | + if ($path === false || !file_exists ($path)) { |
|
52 | + throw new BoilerException ('Directory does not exists'); |
|
53 | 53 | } |
54 | 54 | |
55 | - $paths = $this->configuration->getPaths(); |
|
56 | - if (in_array($path, $paths)) { |
|
57 | - throw new BoilerException('Folder already added.'); |
|
55 | + $paths = $this->configuration->getPaths (); |
|
56 | + if (in_array ($path, $paths)) { |
|
57 | + throw new BoilerException ('Folder already added.'); |
|
58 | 58 | } |
59 | - $result = $this->configuration->addPath($path); |
|
59 | + $result = $this->configuration->addPath ($path); |
|
60 | 60 | |
61 | 61 | $resultMessage = '<comment>Directory successfully added</comment>'; |
62 | 62 | |
@@ -64,6 +64,6 @@ discard block |
||
64 | 64 | $resultMessage = '<error>Directory could not be added.</error>'; |
65 | 65 | } |
66 | 66 | |
67 | - $output->writeln($resultMessage); |
|
67 | + $output->writeln ($resultMessage); |
|
68 | 68 | } |
69 | 69 | } |