Completed
Push — 15.x ( 53b7d0...60340d )
by Tim
04:40
created

getFileResolverConfiguration()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
ccs 0
cts 8
cp 0
rs 9.7998
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * TechDivision\Import\Subjects\FileResolver\MoveFilesFileResolver
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Subjects\FileResolver;
22
23
use TechDivision\Import\ApplicationInterface;
24
use TechDivision\Import\ConfigurationInterface;
25
use TechDivision\Import\Services\RegistryProcessorInterface;
26
27
/**
28
 * A custom file resolver implementation for the move files subject
29
 * that try's to load the prefix from the configuration.
30
 *
31
 * @author    Tim Wagner <[email protected]>
32
 * @copyright 2016 TechDivision GmbH <[email protected]>
33
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
34
 * @link      https://github.com/techdivision/import
35
 * @link      http://www.techdivision.com
36
 */
37
class MoveFilesFileResolver extends OkFileAwareFileResolver
38
{
39
40
    /**
41
     * The configuration instance.
42
     *
43
     * @var \TechDivision\Import\ConfigurationInterface
44
     */
45
    private $configuration;
46
47
    /**
48
     * Initializes the file resolver with the application and the registry instance.
49
     *
50
     * @param \TechDivision\Import\ApplicationInterface                $application       The application instance
51
     * @param \TechDivision\Import\Services\RegistryProcessorInterface $registryProcessor The registry instance
52
     * @param \TechDivision\Import\ConfigurationInterface              $configuration     The configuration instance
53
     */
54
    public function __construct(
55
        ApplicationInterface $application,
56
        RegistryProcessorInterface $registryProcessor,
57
        ConfigurationInterface $configuration
58
    ) {
59
60
        // pass the application + registry processor to the parent class
61
        parent::__construct($application, $registryProcessor);
62
63
        // set the configuration instance
64
        $this->configuration = $configuration;
65
    }
66
67
    /**
68
     * Return's the configuration instance.
69
     *
70
     * @return \TechDivision\Import\ConfigurationInterface The configuration instance
71
     */
72
    protected function getConfiguration()
73
    {
74
        return $this->configuration;
75
    }
76
77
    /**
78
     * Returns the file resolver configuration instance.
79
     *
80
     * @return \TechDivision\Import\Configuration\Subject\FileResolverConfigurationInterface The configuration instance
81
     */
82
    protected function getFileResolverConfiguration()
83
    {
84
85
        // load the file resolver configuration from the parent instance
86
        $fileResolverConfiguration = parent::getFileResolverConfiguration();
87
88
        // use the move files prefix from the configuration
89
        if ($moveFilesPrefix = $this->getConfiguration()->getMoveFilesPrefix()) {
90
            $fileResolverConfiguration->setPrefix($moveFilesPrefix);
0 ignored issues
show
Bug introduced by
The method setPrefix() does not seem to exist on object<TechDivision\Impo...ConfigurationInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
91
        }
92
93
        // return the customized file resolver configuration
94
        return $fileResolverConfiguration;
95
    }
96
}
97