PathLibrary   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalizerPath() 0 13 4
1
<?php
2
// +----------------------------------------------------------------------
3
// | date: 2016-11-13
4
// +----------------------------------------------------------------------
5
// | UtilityLibrary.php: 工具库
6
// +----------------------------------------------------------------------
7
// | Author: yangyifan <[email protected]>
8
// +----------------------------------------------------------------------
9
namespace tinymeng\uploads\Helper;
10
class PathLibrary
11
{
12
    /*
13
     * 内部方法, 规整文件路径
14
     * @param  string  $path      文件路径
15
     * @param  string  $isfolder  是否为文件夹
16
     */
17
    public static function normalizerPath($path, $isfolder = False)
18
    {
19
        if (preg_match('/^\//', $path) == 0) {
20
            $path = '/' . $path;
21
        }
22
        if ($isfolder == True) {
23
            if (preg_match('/\/$/', $path) == 0) {
24
                $path = $path . '/';
25
            }
26
        }
27
        // Remove unnecessary slashes.
28
        $path = preg_replace('#/+#', '/', $path);
29
        return $path;
30
    }
31
}