AutoloadTrait::mergeAutoload()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php namespace Arcanedev\Composer\Entities\PackageTraits;
2
3
use Arcanedev\Composer\Utilities\Util;
4
use Composer\Package\RootPackageInterface;
5
6
/**
7
 * Trait     AutoloadTrait
8
 *
9
 * @package  Arcanedev\Composer\Entities\PackageTraits
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
trait AutoloadTrait
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Traits
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    use PackageTrait;
19
20
    /* ------------------------------------------------------------------------------------------------
21
     |  Main Functions
22
     | ------------------------------------------------------------------------------------------------
23
     */
24
    /**
25
     * Merge autoload into a RootPackage.
26
     *
27
     * @param  \Composer\Package\RootPackageInterface  $root
28
     */
29 99
    private function mergeAutoload(RootPackageInterface $root)
30
    {
31 99
        if ( ! empty($autoload = $this->getPackage()->getAutoload())) {
32 9
            static::unwrapIfNeeded($root, 'setAutoload')
33 9
                ->setAutoload(array_merge_recursive(
34 9
                    $root->getAutoload(), Util::fixRelativePaths($this->getPath(), $autoload)
35
                ));
36
        }
37 99
    }
38
}
39