ExcludePattern::directories()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 16
ccs 3
cts 3
cp 1
rs 9.4285
cc 3
eloc 10
nc 3
nop 1
crap 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