Completed
Pull Request — master (#1162)
by Dmitry
08:52
created

PathHelper::urlPathToFilePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the `liip/LiipImagineBundle` project.
7
 *
8
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
9
 *
10
 * For the full copyright and license information, please view the LICENSE.md
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Liip\ImagineBundle\Imagine\Cache\Helper;
15
16
/**
17
 * @author  Dmitrijs Balabka <[email protected]>
18
 */
19
class PathHelper
20
{
21
    public static function filePathToUrlPath(string $path): string
22
    {
23
        return implode('/', array_map('rawurlencode', explode('/', $path)));
24
    }
25
26
    public static function urlPathToFilePath(string $url): string
27
    {
28
        // used urldecode instead of rawurlencode for BC safety to support "+" in URL
29
        return urldecode($url);
30
    }
31
}
32