Passed
Push — master ( 147f66...7138a8 )
by Richard
17:47 queued 12:18
created

FolderMakeCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Riclep\Storyblok\Console;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Illuminate\Support\Str;
7
8
class FolderMakeCommand extends GeneratorCommand
9
{
10
	protected $name  = 'ls:folder';
11
12
	protected $description = 'Create a new folder class';
13
14
	protected $type = 'Folder';
15
16
	protected function getStub(): string
17
	{
18
		return file_exists(resource_path('stubs/storyblok/folder.stub')) ? resource_path('stubs/storyblok/folder.stub') : __DIR__ . '/stubs/folder.stub';
19
	}
20
21
	protected function getDefaultNamespace($rootNamespace): string
22
	{
23
		return $rootNamespace . '\Storyblok\Folders';
24
	}
25
26
	public function handle(): void
27
	{
28
		parent::handle();
29
30
		$this->doOtherOperations();
31
	}
32
33
	protected function doOtherOperations(): void
34
	{
35
		$class = $this->qualifyClass($this->getNameInput());
36
		$path = $this->getPath($class);
37
		$content = file_get_contents($path);
38
39
		$content = str_replace('DummySlug', Str::kebab($this->getNameInput()), $content);
40
41
		file_put_contents($path, $content);
42
	}
43
}
44