PublicDirectory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 5
b 0
f 0
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getPublicDir() 0 13 3
1
<?php
2
3
/*
4
 * This file is part of the SF Forward Bundle.
5
 *
6
 * (c) DAOUDI Soufian <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace SfForward\Util;
13
14
class PublicDirectory
15
{
16
    const WEB_FOLDER_NAME = 'web';
17
    const PUBLIC_FOLDER_NAME = 'public';
18
19
    /**
20
     * @param string $projectDir
21
     *
22
     * @return string
23
     */
24
    public static function getPublicDir($projectDir)
25
    {
26
        $projectDir = rtrim($projectDir, '/');
27
28
        if (file_exists($webDir = "$projectDir/".self::WEB_FOLDER_NAME.'/')) {
29
            return $webDir;
30
        }
31
32
        if (file_exists($publicDir = "$projectDir/".self::PUBLIC_FOLDER_NAME.'/')) {
33
            return $publicDir;
34
        }
35
36
        return $projectDir.'/';
37
    }
38
}
39