Completed
Push — master ( f7eb77...bdcf7d )
by Tomáš
03:24
created

SourceFinder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 33
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B find() 0 26 4
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 4
    public function find(array $source) : array
20
    {
21 4
        $files = [];
22
23 4
        foreach ($source as $singleSource) {
24 4
            if (is_file($singleSource)) {
25 2
                $fileInfo = new SplFileInfo($singleSource);
26 2
                if ($fileInfo->getExtension() !== 'php') {
27 1
                    continue;
28
                }
29
30 1
                $files[$singleSource] = $fileInfo;
31
            } else {
32 2
                $finder = (new Finder())->files()
33 2
                    ->name('*.php')
34 2
                    ->in($singleSource);
35
36 2
                $files = array_merge(
37
                    $files,
38 3
                    iterator_to_array($finder->getIterator())
39
                );
40
            }
41
        }
42
43 4
        return $files;
44
    }
45
}
46