Completed
Pull Request — master (#9)
by ARCANEDEV
10:00
created

ExcludePattern::directories()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

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