Completed
Branch master (c5ceed)
by Tomáš
33:54 queued 13:17
created

SourceFinder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 27
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 0 21 3
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