Completed
Branch master (06cb84)
by Tomáš
06:00
created

SourceFinder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
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 28
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\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