Completed
Pull Request — master (#8)
by ARCANEDEV
06:34
created

SuggestsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A mergeSuggests() 0 8 2
1
<?php namespace Arcanedev\Composer\Entities\PackageTraits;
2
3
use Composer\Package\RootPackageInterface;
4
5
/**
6
 * Trait     SuggestsTrait
7
 *
8
 * @package  Arcanedev\Composer\Entities\PackageTraits
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
trait SuggestsTrait
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Main Functions
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Merge suggested packages into a RootPackage.
19
     *
20
     * @param  \Composer\Package\RootPackageInterface  $root
21
     */
22
    protected function mergeSuggests(RootPackageInterface $root)
23
    {
24
        if ( ! empty($suggests = $this->package->getSuggests())) {
0 ignored issues
show
Bug introduced by
The property package does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
25
            /** @var \Composer\Package\RootPackageInterface $unwrapped */
26
            $unwrapped = static::unwrapIfNeeded($root, 'setSuggests');
27
            $unwrapped->setSuggests(array_merge($root->getSuggests(), $suggests));
28
        }
29
    }
30
}
31