PackageUpdateCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * This file is part of Packy.
5
 *
6
 * (c) Peter Nijssen
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AppBundle\Command;
13
14
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class PackageUpdateCommand extends ContainerAwareCommand
19
{
20
    /**
21
     * Configure the command.
22
     */
23
    protected function configure()
24
    {
25
        $this
26
            ->setName('packy:package:update')
27
            ->setDescription('Update the version of the package');
28
    }
29
30
    /**
31
     * Execute the command.
32
     *
33
     * @param InputInterface  $input
34
     * @param OutputInterface $output
35
     *
36
     * @throws \Exception
37
     */
38
    protected function execute(InputInterface $input, OutputInterface $output)
39
    {
40
        $packageRepository = $this->getContainer()->get('packy.repository.package');
41
        $packageManagers = $this->getContainer()->get('packy.package_managers');
42
        $packages = $packageRepository->findAll();
43
44
        foreach ($packages as $package) {
45
            $packageManager = $packageManagers->get($package->getManager());
46
            $package = $packageManager->analyzePackage($package);
47
            $packageRepository->update($package);
48
            $output->writeln('<info>Package ' . $package->getName() . ' updated!</info>');
49
        }
50
    }
51
}
52