CacheStamp   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
c 0
b 0
f 0
dl 0
loc 23
rs 10
ccs 6
cts 7
cp 0.8571

1 Method

Rating   Name   Duplication   Size   Complexity  
A cacheStamp() 0 13 3
1
<?php
2
3
namespace mQueue\View\Helper;
4
5
use Zend_View_Helper_Abstract;
6
7
class CacheStamp extends Zend_View_Helper_Abstract
8
{
9
    /**
10
     * Inject the last modified time of file.
11
     * This avoid browser cache and force reloading when the file changed.
12
     *
13
     * @param string $fileName
14
     *
15
     * @return string
16
     */
17 13
    public function cacheStamp($fileName)
18
    {
19
        // In development, use non minified version
20 13
        if (APPLICATION_ENV == 'development') {
21
            $fileName = str_replace('/js/min/', '/js/', $fileName);
22
        }
23
24 13
        $fullPath = APPLICATION_PATH . '/../public/' . $fileName;
25 13
        if (is_file($fullPath)) {
26 13
            $fileName = $this->view->serverUrl() . $this->view->baseUrl($fileName) . '?' . filemtime($fullPath);
27
        }
28
29 13
        return $fileName;
30
    }
31
}
32