Files   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 64
ccs 12
cts 15
cp 0.8
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFiles() 0 10 2
A saveCacheBust() 0 19 2
A getCacheBust() 0 10 2
1
<?php
2
3
namespace makehappen\autominifier;
4
5
class Files
6
{
7
    /**
8
     * Get files to minify and concatenate
9
     *
10
     * @var $strFilesFolder
11
     * @return array
12
     */
13 3
    public function getFiles($strFilesFolder = '')
14
    {
15
        // abort if folder not found
16 3
        if (!is_dir($strFilesFolder)) {
17
            return [];
18
        }
19
20
        // get all files
21 3
        return scandir($strFilesFolder);
22
    }
23
24
    /**
25
     * Save Cache Bust
26
     *
27
     * @var string $strApplicationFileContents
28
     * @var string $strCacheBustFile
29
     * @return null
30
     */
31 3
    public function saveCacheBust($strApplicationFileContents = '', $strCacheBustFile = '')
32
    {
33
        // get contents signature
34 3
        $strNewCacheBust = md5($strApplicationFileContents);
35
36
        // get prior cache bust
37 3
        $strPriorCacheBust = $this->getCacheBust($strCacheBustFile);
38
39
        // if unchanged, stop here
40 3
        if ($strPriorCacheBust == $strNewCacheBust) {
41
            return $strPriorCacheBust;
42
        }
43
44
        // set new cache bust
45 3
        file_put_contents($strCacheBustFile, $strNewCacheBust);
46
47
        // return new cache bust
48 3
        return $strNewCacheBust;
49
    }
50
51
52
    /**
53
     * Get Cache Bust
54
     *
55
     * @var string $strCacheBustFile
56
     * @return bool|string
57
     */
58 3
    public function getCacheBust($strCacheBustFile = '')
59
    {
60
        // abort if file not found
61 3
        if (!file_exists($strCacheBustFile)) {
62 3
            return '';
63
        }
64
65
        // get cache bust file contents
66
        return file_get_contents($strCacheBustFile);
67
    }
68
}
69