Completed
Push — master ( f657d9...210110 )
by ARCANEDEV
8s
created

DevTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 55
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A mergeDevInto() 0 6 1
mergeDevRequires() 0 1 ?
A mergeDevAutoload() 0 9 2
mergeReferences() 0 1 ?
1
<?php namespace Arcanedev\Composer\Entities\PackageTraits;
2
3
use Arcanedev\Composer\Entities\PluginState;
4
use Arcanedev\Composer\Utilities\Util;
5
use Composer\Package\RootPackageInterface;
6
7
/**
8
 * Trait     DevTrait
9
 *
10
 * @package  Arcanedev\Composer\Entities\PackageTraits
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
trait DevTrait
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Traits
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    use PackageTrait;
20
21
    /* ------------------------------------------------------------------------------------------------
22
     |  Main Functions
23
     | ------------------------------------------------------------------------------------------------
24
     */
25
    /**
26
     * Merge just the dev portion into a RootPackageInterface.
27
     *
28
     * @param  \Composer\Package\RootPackageInterface    $root
29
     * @param  \Arcanedev\Composer\Entities\PluginState  $state
30
     */
31
    public function mergeDevInto(RootPackageInterface $root, PluginState $state)
32
    {
33
        $this->mergeDevRequires($root, $state);
34
        $this->mergeDevAutoload($root);
35
        $this->mergeReferences($root);
36
    }
37
38
    /**
39
     * Merge require-dev into RootPackage.
40
     *
41
     * @param  \Composer\Package\RootPackageInterface    $root
42
     * @param  \Arcanedev\Composer\Entities\PluginState  $state
43
     */
44
    abstract protected function mergeDevRequires(RootPackageInterface $root, PluginState $state);
45
46
    /**
47
     * Merge autoload-dev into a RootPackage.
48
     *
49
     * @param  \Composer\Package\RootPackageInterface  $root
50
     */
51
    private function mergeDevAutoload(RootPackageInterface $root)
52
    {
53
        if ( ! empty($autoload = $this->getPackage()->getDevAutoload())) {
54
            static::unwrapIfNeeded($root, 'setDevAutoload')
55
                ->setDevAutoload(array_merge_recursive(
56
                    $root->getDevAutoload(), Util::fixRelativePaths($this->getPath(), $autoload)
57
                ));
58
        }
59
    }
60
61
    /**
62
     * Update the root packages reference information.
63
     *
64
     * @param  \Composer\Package\RootPackageInterface  $root
65
     */
66
    abstract protected function mergeReferences(RootPackageInterface $root);
67
}
68