ManifestRunner::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 12
cts 12
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of Transfer.
5
 *
6
 * For the full copyright and license information, please view the LICENSE file located
7
 * in the root directory.
8
 */
9
10
namespace Transfer\Manifest;
11
12
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
13
use Transfer\Procedure\ProcedureBuilder;
14
15
/**
16
 * Manifest runner.
17
 */
18
class ManifestRunner
19
{
20
    /**
21
     * @var EventDispatcherInterface
22
     */
23
    protected $dispatcher;
24
25
    /**
26
     * Propagates the event dispatcher onto processor.
27
     *
28
     * @param EventDispatcherInterface $dispatcher
29
     */
30 1
    public function setEventDispatcher(EventDispatcherInterface $dispatcher)
31
    {
32 1
        $this->dispatcher = $dispatcher;
33 1
    }
34
35
    /**
36
     * Configures and runs a manifest.
37
     *
38
     * @param ManifestInterface $manifest Manifest to be run
39
     */
40 2
    public function run(ManifestInterface $manifest)
41
    {
42 2
        $builder = new ProcedureBuilder();
43 2
        $processor = $manifest->getProcessor();
44
45 2
        if ($this->dispatcher) {
46 1
            $processor->setEventDispatcher($this->dispatcher);
47 1
        }
48
49 2
        $manifest->configureProcedureBuilder($builder);
50 2
        $manifest->configureProcessor($manifest->getProcessor());
51
52 2
        $procedure = $builder->getProcedure();
53
54
        $processor
55 2
            ->addProcedure($procedure)
56 2
            ->process();
57 2
    }
58
}
59