Completed
Pull Request — master (#6)
by Beñat
01:52
created

DownloadRoutesLoaderBuilder::sanitize()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\FileBundle\DependencyInjection\Compiler\Routing;
14
15
/**
16
 * Download routes loader builder.
17
 *
18
 * @author Beñat Espiña <[email protected]>
19
 */
20
class DownloadRoutesLoaderBuilder extends RoutesLoaderBuilder
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function sanitize(array $configuration)
26
    {
27
        foreach ($configuration as $key => $config) {
28
            if (null === $config['download_base_url']) {
29
                $configuration[$key]['download_base_url'] = $this->defaultUploadDir($key);
30
            }
31
        }
32
33
        return $configuration;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    protected function definitionName()
40
    {
41
        return 'bengor.file_bundle.routing.download_routes_loader';
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function defaultUploadDir($file)
48
    {
49
        return sprintf('/%ss', $file);
50
    }
51
}
52