Completed
Pull Request — master (#42)
by James
01:14
created

getSolutionActionDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Facade\Ignition\Solutions;
4
5
use Illuminate\Support\Facades\Blade;
6
use Symfony\Component\Filesystem\Filesystem;
7
use Facade\IgnitionContracts\RunnableSolution;
8
use Illuminate\Support\Facades\View;
9
10
class CreateViewFileSolution implements RunnableSolution
11
{
12
    private $viewName;
13
14
    public function __construct($viewName = null)
15
    {
16
        $this->viewName = $viewName;
17
    }
18
19
    public function getSolutionTitle(): string
20
    {
21
        return $this->viewName . ' was not found.';
22
    }
23
24
    public function getDocumentationLinks(): array
25
    {
26
        return [];
27
    }
28
29
    public function getSolutionActionDescription(): string
30
    {
31
        return 'Are you sure the view exist and is a `.blade.php` file?';
32
    }
33
34
    public function getRunButtonText(): string
35
    {
36
        return 'Create file';
37
    }
38
39
    public function getSolutionDescription(): string
40
    {
41
        return '';
42
    }
43
44
    public function getRunParameters(): array
45
    {
46
        return [
47
            'viewName' => $this->viewName,
48
        ];
49
    }
50
51
    public function run(array $parameters = [])
52
    {
53
        $parts = explode('.', $parameters['viewName']);
54
        $file = array_pop($parts);
55
        $path = implode('/', $parts);
56
        $fileViewFinder = View::getFinder();
57
58
        $filesystem = new Filesystem();
59
        $filesystem->mkdir($fileViewFinder->getPaths()[0] . '/' . $path . '/');
60
        touch($fileViewFinder->getPaths()[0] . '/' . $path . '/' . $file . '.blade.php');
61
    }
62
}
63