Completed
Push — master ( 4cb7c1...45e0b0 )
by Alessandro
06:32 queued 41s
created

FileHelper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 2 Features 1
Metric Value
wmc 5
c 6
b 2
f 1
lcom 0
cbo 0
dl 0
loc 41
ccs 18
cts 18
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findFiles() 0 14 3
A adjustPath() 0 17 2
1
<?php
2
3
namespace Padosoft\LaravelComposerSecurity;
4
5
6
class FileHelper
7
{
8
    /**
9
     * @param $path
10
     * @param $fileName
11
     * @return array
12
     *
13
     */
14 20
    public function findFiles($path, $fileName)
15
    {
16 20
        if ($path=='') {
17 2
            $path = base_path();
18 2
        }
19
20 20
        if (is_dir($path)) {
21 20
            $path=str_finish($path, '/');
22
23 20
        }
24 20
        $path .= $fileName;
25
26 20
        return glob($path);
27
    }
28
29 20
    public static function adjustPath($path)
30
    {
31
32 20
        if ($path == '') {
33 4
            return array();
34
        }
35
36 20
        $p = explode(",", str_replace('\\', '/', $path));
37
38 20
        $pathList = array_map(function ($item) {
39 20
            return str_finish($item, '/');
40 20
        },
41
            $p
42 20
        );
43
44 20
        return $pathList;
45
    }
46
}
47