Passed
Push — master ( 800de6...ff9dd6 )
by Jean Paul
08:33
created

FileUtils   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A file_build_path() 0 3 1
A getUserHomePath() 0 12 5
1
<?php
2
3
namespace Coco\SourceWatcher\Utils;
4
5
/**
6
 * Class FileUtils
7
 *
8
 * @package Coco\SourceWatcher\Utils
9
 */
10
class FileUtils
11
{
12
    public static function file_build_path ( ...$segments ) : string
13
    {
14
        return join( DIRECTORY_SEPARATOR, $segments );
15
    }
16
17
    /**
18
     * // getenv("HOME") isn't set on windows and generates a Notice.
19
     *
20
     * @return string
21
     */
22
    public static function getUserHomePath () : string
23
    {
24
        $home = getenv( "HOME" );
25
26
        if ( empty( $home ) ) {
27
            if ( !empty( $_SERVER["HOMEDRIVE"] ) && !empty( $_SERVER["HOMEPATH"] ) ) {
28
                // home on windows
29
                $home = $_SERVER["HOMEDRIVE"] . $_SERVER["HOMEPATH"];
30
            }
31
        }
32
33
        return empty( $home ) ? "" : $home;
34
    }
35
}
36