CanResolveDocumentRoot   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDocumentRoot() 0 10 4
1
<?php
2
3
namespace Suitmedia\LighthouseAudit\Concerns;
4
5
use LogicException;
6
7
trait CanResolveDocumentRoot
8
{
9
    /**
10
     * Validate and return the real document root path.
11
     *
12
     * @param mixed $path
13
     *
14
     * @throws LogicException
15
     *
16
     * @return string
17
     */
18
    public function getDocumentRoot($path) :string
19
    {
20
        $path = is_string($path) ? realpath($path) : realpath('.');
21
22
        if ($path === false || !is_dir($path)) {
23
            throw new LogicException('The given path is not a directory or directory is not exists.');
24
        }
25
26
        return $path;
27
    }
28
}
29