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   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 5
dl 0
loc 54
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
B process() 0 36 5
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