11<?php
2- namespace CodeClimate \Bundle \TestReporterBundle \Command ;
32
4- use CodeClimate \Bundle \TestReporterBundle \CoverageCollector ;
5- use CodeClimate \Bundle \TestReporterBundle \ApiClient ;
3+ namespace CodeClimate \PhpTestReporter \ConsoleCommands ;
4+
5+ use CodeClimate \PhpTestReporter \TestReporter \ApiClient ;
6+ use CodeClimate \PhpTestReporter \TestReporter \CoverageCollector ;
67use Symfony \Component \Console \Command \Command ;
78use Symfony \Component \Console \Input \InputInterface ;
89use Symfony \Component \Console \Input \InputOption ;
@@ -15,51 +16,48 @@ class TestReporterCommand extends Command
1516{
1617 /**
1718 * Path to project root directory.
18- *
1919 * @var string
2020 */
2121 protected $ rootDir ;
2222
2323 /**
2424 * {@inheritdoc}
25- *
2625 * @see \Symfony\Component\Console\Command\Command::configure()
2726 */
2827 protected function configure ()
2928 {
3029 $ this
31- ->setName ('test-reporter ' )
32- ->setDescription ('Code Climate PHP Test Reporter ' )
33- ->addOption (
34- 'stdout ' ,
35- null ,
36- InputOption::VALUE_NONE ,
37- 'Do not upload, print JSON payload to stdout '
38- )
39- ->addOption (
40- 'coverage-report ' ,
41- null ,
42- InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY ,
43- 'Location of clover style CodeCoverage report, as produced by PHPUnit \'s --coverage-clover option. ' ,
44- array ( 'build/logs/clover.xml ' )
45- );
30+ ->setName ('test-reporter ' )
31+ ->setDescription ('Code Climate PHP Test Reporter ' )
32+ ->addOption (
33+ 'stdout ' ,
34+ null ,
35+ InputOption::VALUE_NONE ,
36+ 'Do not upload, print JSON payload to stdout '
37+ )
38+ ->addOption (
39+ 'coverage-report ' ,
40+ null ,
41+ InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY ,
42+ 'Location of clover style CodeCoverage report, as produced by PHPUnit \'s --coverage-clover option. ' ,
43+ [ 'build/logs/clover.xml ' ]
44+ );
4645 }
4746
4847 /**
4948 * {@inheritdoc}
50- *
5149 * @see \Symfony\Component\Console\Command\Command::execute()
5250 */
5351 protected function execute (InputInterface $ input , OutputInterface $ output )
5452 {
55- $ ret = 0 ;
53+ $ ret = 0 ;
5654 $ collector = new CoverageCollector ($ input ->getOption ('coverage-report ' ));
57- $ json = $ collector ->collectAsJson ();
55+ $ json = $ collector ->collectAsJson ();
5856
5957 if ($ input ->getOption ('stdout ' )) {
6058 $ output ->writeln ((string )$ json );
6159 } else {
62- $ client = new ApiClient ();
60+ $ client = new ApiClient ();
6361 $ response = $ client ->send ($ json );
6462 switch ($ response ->code ) {
6563 case 200 :
@@ -72,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7270 break ;
7371
7472 default :
75- $ output ->writeln ("Unexpected response: " . $ response ->code . " " . $ response ->message );
73+ $ output ->writeln ("Unexpected response: " . $ response ->code . " " . $ response ->message );
7674 $ output ->writeln ($ response ->body );
7775 $ ret = 1 ;
7876 break ;
0 commit comments