path_for_file()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 16
rs 9.4285
cc 3
eloc 12
nc 3
nop 1
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