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

FileCollection::exclude()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 5
nc 1
nop 1
crap 3
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 15
        return $this->reject(function ($file) use ($patterns) {
28 15
            foreach ($patterns as $pattern) {
29 15
                if (Str::is($pattern, $file['name'])) return true;
30 5
            }
31
32 15
            return false;
33 15
        });
34
    }
35
}
36