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

FolderMakeCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getStub() 0 3 2
A handle() 0 5 1
A getDefaultNamespace() 0 3 1
A doOtherOperations() 0 9 1
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