55use App \CommandInterface ;
66use App \OutputInterface ;
77
8- class Command implements CommandInterface
8+ class ViewFilesCommand implements CommandInterface
99{
1010 protected $ output ;
11- protected $ docopt ;
12- protected $ cliData ;
1311 private const MAX_FILE_SIZE = 4096 ;
1412
15- public function __construct (OutputInterface $ output, string $ doc )
13+ public function __construct (OutputInterface $ output )
1614 {
1715 $ this ->output = $ output ;
18- $ this ->docopt = $ doc ;
19- $ this ->cliData = $ this ->output ->parseCommandData ($ this ->docopt );
2016 }
2117
2218 private function parseFile (string $ filename ): array
@@ -36,22 +32,20 @@ private function parseFile(string $filename): array
3632 return $ keys ;
3733 }
3834
39- public function execute ()
35+ public function execute (object $ cliData )
4036 {
41- if (isset ($ this -> cliData ['FILE1 ' ]) & isset ($ this -> cliData ['FILE2 ' ])) {
42- if (file_exists ($ this -> cliData ['FILE1 ' ]) & file_exists ($ this -> cliData ['FILE2 ' ])) {
43- $ file1Content = $ this ->parseFile ($ this -> cliData ['FILE1 ' ]);
44- $ file2Content = $ this ->parseFile ($ this -> cliData ['FILE2 ' ]);
37+ if (isset ($ cliData ['FILE1 ' ]) && isset ($ cliData ['FILE2 ' ])) {
38+ if (file_exists ($ cliData ['FILE1 ' ]) && file_exists ($ cliData ['FILE2 ' ])) {
39+ $ file1Content = $ this ->parseFile ($ cliData ['FILE1 ' ]);
40+ $ file2Content = $ this ->parseFile ($ cliData ['FILE2 ' ]);
4541
4642 print_r ("File1 content: \n" );
4743 print_r ($ file1Content );
4844 print_r ("File2 content: \n" );
4945 print_r ($ file2Content );
5046 } else {
51- print_r ("File {$ this -> cliData ['FILE2 ' ]} not exists \n" );
47+ print_r ("File {$ cliData [ ' FILE1 ' ]} or { $ cliData ['FILE2 ' ]} not exists \n" );
5248 }
53- } else {
54- print_r ("File {$ this ->cliData ['FILE1 ' ]} not exists \n" );
5549 }
5650 }
5751}
0 commit comments