CacheUtilsTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 28
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A streamSafeGlob() 0 17 4
1
<?php
2
3
namespace Ezcache\Cache;
4
5
/**
6
 * Trait CacheUtilsTrait.
7
 */
8
trait CacheUtilsTrait
9
{
10
    /**
11
     * Glob that is safe with streams (vfs for example).
12
     *
13
     * @param string $directory   the directory
14
     * @param string $filePattern the file pattern
15
     *
16
     * @return array containing match files
17
     */
18 1
    public function streamSafeGlob($directory, $filePattern) : array
19
    {
20 1
        $files = scandir($directory);
21 1
        $found = [];
22
23 1
        foreach ($files as $filename) {
24 1
            if (in_array($filename, ['.', '..'])) {
25 1
                continue;
26
            }
27
28 1
            if (fnmatch($filePattern, $filename)) {
29 1
                $found[] = "{$directory}/{$filename}";
30
            }
31
        }
32
33 1
        return $found;
34
    }
35
}
36