ExcludePattern   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A directories() 0 16 3
1
<?php namespace Arcanesoft\Media\Helpers;
2
3
use Illuminate\Support\Str;
4
5
/**
6
 * Class     ExcludePattern
7
 *
8
 * @package  Arcanesoft\Media\Helpers
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class ExcludePattern
12
{
13
    /* -----------------------------------------------------------------
14
     |  Main Methods
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * @param  array  $patterns
20
     *
21
     * @return array
22
     */
23
    public static function directories(array $patterns)
24
    {
25 34
        $patterns = array_map(function ($pattern) {
26 34
            return trim($pattern, '/');
27 34
        }, $patterns);
28
29
        foreach ($patterns as $pattern) {
30
            $patterns[] = Str::endsWith($pattern, '/*')
31
                ? Str::replaceLast('/*', '', $pattern)
32
                : $pattern.'/*';
33
        }
34
35
        asort($patterns);
36
37
        return array_values(array_unique($patterns));
38
    }
39
}
40