Completed
Push — master ( 209aaf...f9b28a )
by ARCANEDEV
9s
created

ExcludePattern::directories()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
ccs 0
cts 12
cp 0
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
crap 12
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
     * @param  array  $patterns
19
     *
20
     * @return array
21
     */
22
    public static function directories(array $patterns)
23
    {
24
        $patterns = array_map(function ($pattern) {
25
            return trim($pattern, '/');
26
        }, $patterns);
27
28
        foreach ($patterns as $pattern) {
29
            $patterns[] = Str::endsWith($pattern, '/*')
30
                ? Str::replaceLast('/*', '', $pattern)
31
                : $pattern.'/*';
32
        }
33
34
        return array_unique($patterns);
35
    }
36
}
37