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.

PullCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2015-08-02
7
 *
8
 */
9
10
11
namespace Chapi\Commands;
12
13
use Chapi\BusinessCase\JobManagement\StoreJobBusinessCaseFactoryInterface;
14
use Chapi\BusinessCase\JobManagement\StoreJobBusinessCaseInterface;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputOption;
17
18
class PullCommand extends AbstractCommand
19
{
20
    /**
21
     * Configures the current command.
22
     */
23
    protected function configure()
24
    {
25
        $this->setName('pull')
26
            ->setDescription('Pull jobs from chronos and add them to local repository')
27
            ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force to overwrite local jobs')
28
            ->addArgument('jobnames', InputArgument::IS_ARRAY, 'Jobnames to pull')
29
        ;
30
    }
31
32
    /**
33
     * @return int
34
     */
35
    protected function process()
36
    {
37
        $force = (bool) $this->input->getOption('force');
38
        $jobNames = $this->input->getArgument('jobnames');
39
40
        /** @var StoreJobBusinessCaseFactoryInterface $storeJobBusinessCaseFactory */
41
        $storeJobBusinessCaseFactory = $this->getContainer()->get(StoreJobBusinessCaseFactoryInterface::DIC_NAME);
42
43
        if (count($jobNames) == 0) {
44
            $storeJobBusinessCases = $storeJobBusinessCaseFactory->getAllStoreJobBusinessCase();
45
            /** @var StoreJobBusinessCaseInterface $storeJobBusinessCase */
46
            foreach ($storeJobBusinessCases as $storeJobBusinessCase) {
47
                $storeJobBusinessCase->storeJobsToLocalRepository($jobNames, $force);
48
            }
49
            return 0;
50
        }
51
52
53
        foreach ($jobNames as $jobName) {
54
            // since the job can be of any underlying system
55
            // we get teh businesscase for the system
56
            // and the update it there.
57
58
            /** @var StoreJobBusinessCaseInterface  $_oStoreJobBusinessCase */
59
            $storeJobBusinessCase = $storeJobBusinessCaseFactory->getBusinessCaseWithJob($jobName);
60
            if (null == $storeJobBusinessCase) {
61
                // not found but process the rest of the jobs
62
                continue;
63
            }
64
65
            // TODO: add method for single job to LocalRepository update
66
            $storeJobBusinessCase->storeJobsToLocalRepository(array($jobName), $force);
67
        }
68
69
        return 0;
70
    }
71
}
72