Completed
Push — 1.0 ( 657f08...d94044 )
by Rob
09:07
created

FileSystemInsecureLocator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateAbsolutePath() 0 8 3
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Binary\Locator;
13
14
class FileSystemInsecureLocator extends FileSystemLocator
15
{
16
    /**
17
     * @param string $root
18
     * @param string $path
19
     *
20
     * @return string|false
21
     */
22
    protected function generateAbsolutePath($root, $path)
23
    {
24
        if (false !== strpos($path, '..'.DIRECTORY_SEPARATOR)) {
25
            return false;
26
        }
27
28
        return file_exists($absolute = $root.DIRECTORY_SEPARATOR.$path) ? $absolute : false;
29
    }
30
}
31