@@ -41,6 +41,10 @@ |
||
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | + /** |
|
| 45 | + * @param string $keyProject |
|
| 46 | + * @param string $path |
|
| 47 | + */ |
|
| 44 | 48 | public function addProject($keyProject, $path) |
| 45 | 49 | { |
| 46 | 50 | $this->generateDatabase(); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | $db = file_get_contents(getenv("HOME").'/'.self::DIRECTORY.'/'.self::DB); |
| 18 | - $jsonDb = json_decode($db,true); |
|
| 18 | + $jsonDb = json_decode($db, true); |
|
| 19 | 19 | if (!is_array($jsonDb)) { |
| 20 | 20 | throw new \RuntimeException('$jsonDb must be an array.'); |
| 21 | 21 | } |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | $this->generateDatabase(); |
| 29 | 29 | $jsonDb = $this->getProjects(); |
| 30 | 30 | |
| 31 | - if (isset($jsonDb[$keyProject])){ |
|
| 31 | + if (isset($jsonDb[$keyProject])) { |
|
| 32 | 32 | unset($jsonDb[$keyProject]); |
| 33 | 33 | try { |
| 34 | 34 | file_put_contents(getenv("HOME").'/'.self::DIRECTORY.'/'.self::DB, json_encode($jsonDb)); |
| 35 | - } catch (\Exception $e){ |
|
| 35 | + } catch (\Exception $e) { |
|
| 36 | 36 | return false; |
| 37 | 37 | } |
| 38 | 38 | return true; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | try { |
| 51 | 51 | file_put_contents(getenv("HOME").'/'.self::DIRECTORY.'/'.self::DB, json_encode($jsonDb)); |
| 52 | - } catch (\Exception $e){ |
|
| 52 | + } catch (\Exception $e) { |
|
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -48,14 +48,14 @@ |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $jsonDb = $this->databaseService->getProjects(); |
| 51 | - if (array_key_exists($nameOfProject,$jsonDb)) { |
|
| 51 | + if (array_key_exists($nameOfProject, $jsonDb)) { |
|
| 52 | 52 | $question = new ConfirmationQuestion('<error>This project exist. Do you want override it?</error> <info>Y/n</info> ', false); |
| 53 | 53 | if (!$helper->ask($input, $output, $question)) { |
| 54 | 54 | return; |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ($this->databaseService->addProject($nameOfProject, getcwd())){ |
|
| 58 | + if ($this->databaseService->addProject($nameOfProject, getcwd())) { |
|
| 59 | 59 | $output->writeln('<info>OK. Project added.</info>'); |
| 60 | 60 | } else { |
| 61 | 61 | $output->writeln('<error>KO. Error</error>'); |