EnsureAssetsDirectoryExists::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php namespace Arcanedev\Assets\Pipes\Make;
2
3
use Arcanedev\Assets\Exceptions\DirectoryExistsException;
4
use Closure;
5
use Illuminate\Support\Facades\File;
6
7
/**
8
 * Class     EnsureAssetsDirectoryExists
9
 *
10
 * @package  Arcanedev\Assets\Pipes\Make
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class EnsureAssetsDirectoryExists 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
    public function handle(array $passable, Closure $next)
27
    {
28
        $path = $passable['root-directory'].'/'.$passable['name'];
29
30
        if (File::isDirectory($path))
31
            DirectoryExistsException::throw($path);
32
33
        File::makeDirectory($path, 0755, true);
34
35
        return $next($passable + compact('path'));
36
    }
37
}
38