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.

AddCommand::getChangedJobs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2015-07-31
7
 *
8
 */
9
10
namespace Chapi\Commands;
11
12
use Chapi\BusinessCase\Comparison\JobComparisonInterface;
13
use Chapi\Component\Command\JobUtils;
14
use Chapi\Service\JobIndex\JobIndexServiceInterface;
15
16
class AddCommand extends AbstractCommand
17
{
18
    /**
19
     * Configures the current command.
20
     */
21 2
    protected function configure()
22
    {
23 2
        $this->setName('add')
24 2
            ->setDescription('Add job contents to the index')
25
        ;
26
27 2
        JobUtils::configureJobNamesArgument($this, 'Jobs to add to the index');
28 2
    }
29
30
    /**
31
     * @return int
32
     */
33 2
    protected function process()
34
    {
35 2
        $jobNames = JobUtils::getJobNames($this->input, $this);
36 2
        $jobsToAdd = (JobUtils::isWildcard($jobNames))
37 1
            ? $this->getChangedJobs()
38 2
            : $jobNames
39
        ;
40
41 2
        $this->addJobs($jobsToAdd);
42
43 2
        return 0;
44
    }
45
46
    /**
47
     * @return array
48
     */
49 1
    private function getChangedJobs()
50
    {
51
        // job data
52
        /** @var JobComparisonInterface  $jobComparisonBusinessCase */
53 1
        $jobComparisonBusinessCase = $this->getContainer()->get(JobComparisonInterface::DIC_NAME);
54
55 1
        $newJobs = $jobComparisonBusinessCase->getRemoteMissingJobs();
56 1
        $missingJobs = $jobComparisonBusinessCase->getLocalMissingJobs();
57 1
        $localJobUpdates = $jobComparisonBusinessCase->getLocalJobUpdates();
58
59 1
        return array_merge($newJobs, $missingJobs, $localJobUpdates);
60
    }
61
62
    /**
63
     * @param string[] $jobsToAdd
64
     */
65 2
    private function addJobs($jobsToAdd)
66
    {
67
        /** @var JobIndexServiceInterface  $jobIndexService */
68 2
        $jobIndexService = $this->getContainer()->get(JobIndexServiceInterface::DIC_NAME);
69 2
        $jobIndexService->addJobs($jobsToAdd);
70 2
    }
71
}
72