Completed
Push — master ( 3b5f38...c5ceed )
by Tomáš
04:59
created

SourceFinder::find()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 18
cp 0
rs 9.3142
c 0
b 0
f 0
cc 3
eloc 13
nc 3
nop 1
crap 12
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\PHP7_CodeSniffer\Finder;
9
10
use SplFileInfo;
11
use Symfony\Component\Finder\Finder;
12
13
final class SourceFinder
14
{
15
    /**
16
     * @return SplFileInfo[]
17
     */
18
    public function find(array $source) : array
19
    {
20
        $files = [];
21
22
        foreach ($source as $singleSource) {
23
            if (is_file($singleSource)) {
24
                $files[$singleSource] = new SplFileInfo($singleSource);
25
            } else {
26
                $finder = (new Finder())->files()
27
                    ->name('*.php')
28
                    ->in($singleSource);
29
30
                $files = array_merge(
31
                    $files,
32
                    iterator_to_array($finder->getIterator())
33
                );
34
            }
35
        }
36
37
        return $files;
38
    }
39
}
40