FileFinder::findPHPFilesByPath()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
nc 2
nop 1
dl 0
loc 15
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the php-formatter package
5
 *
6
 * Copyright (c) 2014-2016 Marc Morera
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Marc Morera <[email protected]>
14
 */
15
16
namespace Mmoreram\PHPFormatter\Finder;
17
18
use Symfony\Component\Finder\Finder;
19
20
/**
21
 * Class FileFinder.
22
 */
23
class FileFinder
24
{
25
    /**
26
     * Find all php files by path.
27
     *
28
     * @param string $path Path
29
     *
30
     * @return Finder Finder iterable object with all PHP found files in path
31
     */
32
    public function findPHPFilesByPath($path)
33
    {
34
        $finder = new Finder();
35
36
        if (file_exists($path) && !is_dir($path)) {
37
            $finder->append([0 => $path]);
38
        } else {
39
            $finder
40
                ->files()
41
                ->in($path)
42
                ->name('*.php');
43
        }
44
45
        return $finder;
46
    }
47
}
48