Completed
Push — develop ( 373768...b82813 )
by Mike
05:50
created

FlySystemCollector::getFiles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 4
dl 0
loc 14
ccs 7
cts 7
cp 1
crap 2
rs 9.7998
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Parser;
17
18
use phpDocumentor\Dsn;
19
20
final class FlySystemCollector implements FileCollector
21
{
22
    /**
23
     * @var SpecificationFactoryInterface
24
     */
25
    private $specificationFactory;
26
27
    /**
28
     * @var FlySystemFactory
29
     */
30
    private $flySystemFactory;
31
32
    /**
33
     * FlySystemCollector constructor.
34
     */
35 1
    public function __construct(SpecificationFactoryInterface $specificationFactory, FlySystemFactory $flySystemFactory)
36
    {
37 1
        $this->specificationFactory = $specificationFactory;
38 1
        $this->flySystemFactory = $flySystemFactory;
39 1
    }
40
41 1
    public function getFiles(Dsn $dsn, array $paths, array $ignore, array $extensions): array
42
    {
43 1
        $specs = $this->specificationFactory->create($paths, $ignore, $extensions);
44
45 1
        $fileSystem = $this->flySystemFactory->create($dsn);
46
47 1
        $files = [];
48
49 1
        foreach ($fileSystem->find($specs) as $file) {
50 1
            $files[] = new FlySystemFile($fileSystem, $file['path']);
51
        }
52
53 1
        return $files;
54
    }
55
}
56