Completed
Push — 3.0 ( fb09f5...9f4a0e )
by Daniel
02:19
created

EntryFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 52
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A make() 0 13 1
1
<?php
2
3
namespace MagentoHackathon\Composer\Magento\Factory;
4
5
use Composer\Package\PackageInterface;
6
use MagentoHackathon\Composer\Magento\Deploy\Manager\Entry;
7
use MagentoHackathon\Composer\Magento\Factory\ParserFactoryInterface;
8
use MagentoHackathon\Composer\Magento\ProjectConfig;
9
10
/**
11
 * Class EntryFactory
12
 * @package MagentoHackathon\Composer\Magento\Deploy\Manager
13
 * @author  Aydin Hassan <[email protected]>
14
 */
15
class EntryFactory
16
{
17
18
    /**
19
     * @var ProjectConfig
20
     */
21
    protected $config;
22
23
    /**
24
     * @var DeploystrategyFactory
25
     */
26
    protected $deploystrategyFactory;
27
28
    /**
29
     * @var ParserFactoryInterface
30
     */
31
    protected $parserFactory;
32
33
    /**
34
     * @param ProjectConfig $config
35
     * @param DeploystrategyFactory $deploystrategyFactory
36
     * @param ParserFactoryInterface $parserFactory
37
     */
38 7
    public function __construct(
39
        ProjectConfig $config,
40
        DeploystrategyFactory $deploystrategyFactory,
41
        ParserFactoryInterface $parserFactory
42
    ) {
43 7
        $this->config                   = $config;
44 7
        $this->deploystrategyFactory    = $deploystrategyFactory;
45 7
        $this->parserFactory            = $parserFactory;
46 7
    }
47
48
    /**
49
     * @param PackageInterface $package
50
     * @param string $packageSourceDirectory
51
     * @return Entry
52
     */
53 1
    public function make(PackageInterface $package, $packageSourceDirectory)
54
    {
55 1
        $entry = new Entry();
56 1
        $entry->setPackageName($package->getName());
57
58 1
        $strategy       = $this->deploystrategyFactory->make($package, $packageSourceDirectory);
59 1
        $mappingParser  = $this->parserFactory->make($package, $packageSourceDirectory);
60
61 1
        $strategy->setMappings($mappingParser->getMappings());
62 1
        $entry->setDeployStrategy($strategy);
63
64 1
        return $entry;
65
    }
66
}
67