BetterRequirementsVersioning_Backend   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A path_for_file() 0 16 3
1
<?php
2
class BetterRequirementsVersioning_Backend extends Requirements_Backend
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
3
{
4
5
    /**
6
     * Finds the path for specified file.
7
     *
8
     * @param string $fileOrUrl
9
     * @return string|boolean
10
     */
11
    protected function path_for_file($fileOrUrl)
12
    {
13
        if (preg_match('{^//|http[s]?}', $fileOrUrl)) {
14
            return $fileOrUrl;
15
        } elseif (Director::fileExists($fileOrUrl)) {
16
            $path = pathinfo($fileOrUrl);
17
            $absoluteFile = Director::getAbsFile(preg_replace('/([^\?]*)?.*/', '$1', $fileOrUrl));
18
            $v = '.'.filemtime($absoluteFile).'.';
19
20
            $prefix = Director::baseURL();
21
            $fileOrUrl = $path['dirname'].'/'.str_replace('.', $v, $path['basename']);
22
            return "{$prefix}{$fileOrUrl}";
23
        } else {
24
            return false;
25
        }
26
    }
27
}
28