Completed
Pull Request — master (#10)
by ARCANEDEV
06:54
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 33
        $patterns = array_map(function ($pattern) {
25 33
            return trim($pattern, '/');
26 33
        }, $patterns);
27
28 33
        foreach ($patterns as $pattern) {
29 33
            $patterns[] = Str::endsWith($pattern, '/*')
30 11
                ? Str::replaceLast('/*', '', $pattern)
31 33
                : $pattern.'/*';
32 11
        }
33
34 33
        return array_unique($patterns);
35
    }
36
}
37