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

FileCollection::exclude()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
ccs 0
cts 9
cp 0
rs 9.4285
cc 3
eloc 5
nc 1
nop 1
crap 12
1
<?php namespace Arcanesoft\Media\Entities;
2
3
use Illuminate\Support\Collection;
4
use Illuminate\Support\Str;
5
6
/**
7
 * Class     FileCollection
8
 *
9
 * @package  Arcanesoft\Media\Entities
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class FileCollection extends Collection
13
{
14
    /* -----------------------------------------------------------------
15
     |  Main Methods
16
     | -----------------------------------------------------------------
17
     */
18
    /**
19
     * ExcludePattern files with the given patterns.
20
     *
21
     * @param  array  $patterns
22
     *
23
     * @return self
24
     */
25
    public function exclude(array $patterns)
26
    {
27
        return $this->reject(function ($file) use ($patterns) {
28
            foreach ($patterns as $pattern) {
29
                if (Str::is($pattern, $file['name'])) return true;
30
            }
31
32
            return false;
33
        });
34
    }
35
}
36