FinderFileStorageProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 25
ccs 4
cts 10
cp 0.4
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getIterator() 0 10 2
1
<?php
2
3
namespace Mathielen\ImportEngine\Storage\Provider;
4
5
use Mathielen\ImportEngine\Storage\Factory\StorageFactoryInterface;
6
use Symfony\Component\Finder\Finder;
7
use Mathielen\ImportEngine\ValueObject\StorageSelection;
8
9
class FinderFileStorageProvider extends FileStorageProvider implements \IteratorAggregate
10
{
11
    /**
12
     * @var Finder
13
     */
14
    private $finder;
15
16 10
    public function __construct(Finder $finder, StorageFactoryInterface $storageFactory = null)
17
    {
18 10
        parent::__construct($storageFactory);
19
20 10
        $this->finder = $finder;
21 10
    }
22
23
    public function getIterator()
24
    {
25
        $files = array();
26
        foreach ($this->finder->files() as $file) {
27
            $item = new StorageSelection(new \SplFileInfo($file), $file->getFilename(), $file->getFilename());
28
            $files[] = $item;
29
        }
30
31
        return new \ArrayIterator($files);
32
    }
33
}
34