GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

InfoCommand   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 7

Test Coverage

Coverage 82.35%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 13
lcom 2
cbo 7
dl 0
loc 68
ccs 28
cts 34
cp 0.8235
rs 10
c 1
b 1
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A checkInChronos() 0 6 1
D process() 0 37 10
A checkInMarathon() 0 6 1
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2015-07-30
7
 *
8
 */
9
10
namespace Chapi\Commands;
11
12
use Chapi\Service\JobRepository\JobRepositoryInterface;
13
use Symfony\Component\Console\Helper\Table;
14
use Symfony\Component\Console\Input\InputArgument;
15
16
class InfoCommand extends AbstractCommand
17
{
18
    /**
19
     * Configures the current command.
20
     */
21 1
    protected function configure()
22
    {
23 1
        $this->setName('info')
24 1
            ->setDescription('Display your job information from chronos')
25 1
            ->addArgument('jobName', InputArgument::REQUIRED, 'selected job')
26
        ;
27 1
    }
28
29
    /**
30
     * @return int
31
     */
32 1
    protected function process()
33
    {
34 1
        $jobName = $this->input->getArgument('jobName');
35
36 1
        $chronosJobEntity = $this->checkInChronos($jobName);
37 1
        $jobEntity = $chronosJobEntity == null ? $this->checkInMarathon($jobName) : $chronosJobEntity;
38
39 1
        if (!$jobEntity) {
40
            $this->output->writeln(sprintf('<fg=red>%s</>', 'Could not find the job.'));
41
            return 1;
42
        }
43
44 1
        $this->output->writeln(sprintf("\n<comment>info '%s'</comment>\n", $jobEntity->getKey()));
45
46 1
        $table = new Table($this->output);
47 1
        $table->setHeaders(array('Property', 'Value'));
48
49 1
        foreach ($jobEntity as $key => $value) {
50 1
            if (is_array($value) || is_object($value)) {
51 1
                $emptyString = (is_object($value)) ? '{ }' : '[ ]';
52
53 1
                $value = (!empty($value))
54
                    ? json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
55 1
                    : $emptyString;
56 1
            } elseif (is_bool($value)) {
57 1
                $value = (true === $value)
58 1
                    ? 'true'
59 1
                    : 'false';
60
            }
61
62 1
            $table->addRow(array($key, $value));
63
        }
64
65 1
        $table->render();
66
67 1
        return 0;
68
    }
69
70 1
    private function checkInChronos($jobName)
71
    {
72
        /** @var JobRepositoryInterface  $jobRepositoryChronos */
73 1
        $jobRepositoryChronos = $this->getContainer()->get(JobRepositoryInterface::DIC_NAME_CHRONOS);
74 1
        return $jobRepositoryChronos->getJob($jobName);
75
    }
76
77
    private function checkInMarathon($jobName)
78
    {
79
        /** @var JobRepositoryInterface  $jobRepositoryMarathon */
80
        $jobRepositoryMarathon = $this->getContainer()->get(JobRepositoryInterface::DIC_NAME_MARATHON);
81
        return $jobRepositoryMarathon->getJob($jobName);
82
    }
83
}
84