CollectDependenciesCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 6
dl 0
loc 34
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B execute() 0 31 6
1
<?php
2
/**
3
 * Asset Packagist.
4
 *
5
 * @link      https://github.com/hiqdev/asset-packagist
6
 * @package   asset-packagist
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\assetpackagist\commands;
12
13
use hiqdev\assetpackagist\models\AssetPackage;
14
use Yii;
15
use yii\helpers\Console;
16
17
/**
18
 * Class CollectDependenciesCommand collects dependencies for a certain package
19
 * and publishes tasks to update them.
20
 */
21
class CollectDependenciesCommand extends AbstractPackageCommand
22
{
23
    public function execute($queue)
24
    {
25
        $this->beforeRun();
26
27
        $package = $this->package;
28
        $requires = [];
29
30
        foreach ($package->getReleases() as $release) {
31
            if (!isset($release['require'])) {
32
                continue;
33
            }
34
35
            foreach ($release['require'] as $name => $version) {
36
                $requires[$name] = true;
37
            }
38
        }
39
40
        foreach (array_keys($requires) as $name) {
41
            $assetPackage = AssetPackage::fromFullName($name);
42
43
            if ($this->packageRepository->exists($assetPackage)) {
44
                Yii::trace(Console::renderColoredString('Package %N' . $assetPackage->getFullName() . "%n already exists. Skipping.\n"), __CLASS__);
0 ignored issues
show
Deprecated Code introduced by
The method yii\BaseYii::trace() has been deprecated with message: since 2.0.14. Use [[debug()]] instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
45
                continue;
46
            }
47
48
            $queue->push(Yii::createObject(PackageUpdateCommand::class, [$assetPackage]));
49
            Yii::trace(Console::renderColoredString('Created update command for %Y' . $assetPackage->getFullName() . "%n package\n"), __CLASS__);
0 ignored issues
show
Deprecated Code introduced by
The method yii\BaseYii::trace() has been deprecated with message: since 2.0.14. Use [[debug()]] instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
50
        }
51
52
        $this->afterRun();
53
    }
54
}
55