Completed
Branch master (06cb84)
by Tomáš
06:00
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\File\Finder;
9
10
use SplFileInfo;
11
use Symfony\Component\Finder\Finder;
12
13
final class SourceFinder
14
{
15
    /**
16
     * @param array|string[]
17
     * @return SplFileInfo[]
18
     */
19
    public function find(array $source) : array
20
    {
21
        $files = [];
22
23
        foreach ($source as $singleSource) {
24
            if (is_file($singleSource)) {
25
                $files[$singleSource] = new SplFileInfo($singleSource);
26
            } else {
27
                $finder = (new Finder())->files()
28
                    ->name('*.php')
29
                    ->in($singleSource);
30
31
                $files = array_merge(
32
                    $files,
33
                    iterator_to_array($finder->getIterator())
34
                );
35
            }
36
        }
37
38
        return $files;
39
    }
40
}
41