EnsureRootDirectoryExists   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 27
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 2
1
<?php namespace Arcanedev\Assets\Pipes\Init;
2
3
use Arcanedev\Assets\Exceptions\DirectoryExistsException;
4
use Closure;
5
use Illuminate\Support\Facades\File;
6
7
/**
8
 * Class     EnsureRootDirectoryExists
9
 *
10
 * @package  Arcanedev\Assets\Pipes\Init
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class EnsureRootDirectoryExists extends AbstractPipe
14
{
15
    /* -----------------------------------------------------------------
16
     |  Main Method
17
     | -----------------------------------------------------------------
18
     */
19
20
    /**
21
     * @param  array     $passable
22
     * @param  \Closure  $next
23
     *
24
     * @return mixed
25
     *
26
     * @throws \Exception
27
     */
28
    public function handle(array $passable, Closure $next)
29
    {
30
        $path = $passable['root-directory'].'/'.$passable['name'];
31
32
        if (File::isDirectory($path))
33
            DirectoryExistsException::throw($path);
34
35
        File::makeDirectory($path, 0755, true);
36
37
        return $next($passable + compact('path'));
38
    }
39
}
40