Completed
Pull Request — master (#7)
by ARCANEDEV
04:58
created

ExcludePattern   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 26
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
ccs 9
cts 9
cp 1
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 24
        $patterns = array_map(function ($pattern) {
25 6
            return trim($pattern, '/');
26 24
        }, $patterns);
27
28 24
        foreach ($patterns as $pattern) {
29 6
            $patterns[] = Str::endsWith($pattern, '/*')
30 2
                ? Str::replaceLast('/*', '', $pattern)
31 6
                : $pattern.'/*';
32 8
        }
33
34 24
        return array_unique($patterns);
35
    }
36
}
37