AliasesBuilder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the LaravelYaml package.
5
 *
6
 * (c) Théo FIDRY <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Fidry\LaravelYaml\DependencyInjection\Builder;
13
14
use Fidry\LaravelYaml\DependencyInjection\Definition\Alias;
15
use Illuminate\Contracts\Foundation\Application;
16
17
/**
18
 * Is responsible for building Alias definitions.
19
 *
20
 * @author Théo FIDRY <[email protected]>
21
 */
22
final class AliasesBuilder implements BuilderInterface
23
{
24
    /**
25
     * @var Alias[]
26
     */
27
    private $aliases;
28
29
    /**
30
     * @param Alias[] $aliases
31
     */
32 4
    public function __construct(array $aliases)
33
    {
34 4
        $this->aliases = $aliases;
35 4
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 4
    public function build(Application $application)
41
    {
42 4
        foreach ($this->aliases as $alias) {
43 2
            $this->buildAlias($alias, $application);
44 2
        }
45 4
    }
46
47 2
    private function buildAlias(Alias $alias, Application $application)
48
    {
49 2
        $application->alias($alias->getAliased(), $alias->getAlias());
50 2
    }
51
}
52