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

ExcludePattern   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A directories() 0 14 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
     * @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