Completed
Push — master ( b5c840...3d5461 )
by Marcus
04:46
created

MoveFilesFileResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 58
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1
ccs 0
cts 19
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getConfiguration() 0 4 1
A getFileResolverConfiguration() 0 14 2
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\Configuration\ConfigurationInterface;
24
use TechDivision\Import\Services\RegistryProcessorInterface;
25
use TechDivision\Import\Configuration\Subject\FileResolverConfigurationInterface;
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\Configuration\ConfigurationInterface
44
     */
45
    private $configuration;
46
47
    /**
48
     * Initializes the file resolver with the application and the registry instance.
49
     *
50
     * @param \TechDivision\Import\Configuration\ConfigurationInterface $configuration     The configuration instance
51
     * @param \TechDivision\Import\Services\RegistryProcessorInterface  $registryProcessor The registry instance
52
     */
53
    public function __construct(
54
        ConfigurationInterface $configuration,
55
        RegistryProcessorInterface $registryProcessor
56
    ) {
57
58
        // pass the application + registry processor to the parent class
59
        parent::__construct($registryProcessor);
60
61
        // set the configuration instance
62
        $this->configuration = $configuration;
63
    }
64
65
    /**
66
     * Return's the configuration instance.
67
     *
68
     * @return \TechDivision\Import\Configuration\ConfigurationInterface The configuration instance
69
     */
70
    protected function getConfiguration() : ConfigurationInterface
71
    {
72
        return $this->configuration;
73
    }
74
75
    /**
76
     * Returns the file resolver configuration instance.
77
     *
78
     * @return \TechDivision\Import\Configuration\Subject\FileResolverConfigurationInterface The configuration instance
79
     */
80
    protected function getFileResolverConfiguration() : FileResolverConfigurationInterface
81
    {
82
83
        // load the file resolver configuration from the parent instance
84
        $fileResolverConfiguration = parent::getFileResolverConfiguration();
85
86
        // use the move files prefix from the configuration
87
        if ($moveFilesPrefix = $this->getConfiguration()->getMoveFilesPrefix()) {
0 ignored issues
show
Bug introduced by
The method getMoveFilesPrefix() 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...
88
            $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...
89
        }
90
91
        // return the customized file resolver configuration
92
        return $fileResolverConfiguration;
93
    }
94
}
95