Completed
Push — 16.x ( 0056bb...bd3602 )
by Tim
02:11 queued 10s
created

FilesystemLoader::getFilesystemAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * TechDivision\Import\Loaders\FilesystemLoader
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 2020 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\Loaders;
22
23
use TechDivision\Import\Adapter\FilesystemAdapterInterface;
24
25
/**
26
 * Generic loader implementation that uses a glob compatible pattern
27
 * to load files from a given directory.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2020 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import
33
 * @link      http://www.techdivision.com
34
 * @link      https://www.php.net/glob
35
 */
36
class FilesystemLoader implements LoaderInterface
37
{
38
39
    /**
40
     * The filesystem adapter instance.
41
     *
42
     * @var \TechDivision\Import\Adapter\FilesystemAdapterInterface
43
     */
44
    protected $filesystemAdapter;
45
46
    /**
47
     * Construct that initializes the loader with the filesystem adapter instance.
48
     *
49
     * @param \TechDivision\Import\Adapter\FilesystemAdapterInterface $registryProcessor The filesystem adapter instance
0 ignored issues
show
Bug introduced by
There is no parameter named $registryProcessor. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
50
     */
51
    public function __construct(FilesystemAdapterInterface $filesystemAdapter)
52
    {
53
        $this->filesystemAdapter = $filesystemAdapter;
54
    }
55
56
    /**
57
     * Loads and returns the files by using the passed glob pattern.
58
     *
59
     * If no pattern will be passed to the `load()` method, the files of
60
     * the actual directory using `getcwd()` will be returned.
61
     *
62
     * @param string|null $pattern The pattern to load the files from the filesystem
63
     *
64
     * @return array The array with the data
65
     */
66
    public function load(string $pattern = null) : array
67
    {
68
        return $this->getFilesystemAdapter()->glob($pattern ? $pattern : getcwd() . DIRECTORY_SEPARATOR . '*');
69
    }
70
71
    /**
72
     * Return's the filesystem adapter instance.
73
     *
74
     * @return \TechDivision\Import\Adapter\FilesystemAdapterInterface The filesystem adapter instance
75
     */
76
    protected function getFilesystemAdapter() : FilesystemAdapterInterface
77
    {
78
        return $this->filesystemAdapter;
79
    }
80
}
81