Passed
Push — develop ( aa2ce5...bab8ed )
by Richard
03:43 queued 14s
created

PageMakeCommand::getStub()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Riclep\Storyblok\Console;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Illuminate\Support\Str;
7
8
class PageMakeCommand extends GeneratorCommand
9
{
10
	protected $name  = 'ls:page';
11
12
	protected $description = 'Create a new page class';
13
14
	protected $type = 'Page';
15
16
	protected function getStub(): string
17
	{
18
		return file_exists(resource_path('stubs/storyblok/page.stub')) ? resource_path('stubs/storyblok/page.stub') : __DIR__ . '/stubs/page.stub';
19
	}
20
21
	protected function getDefaultNamespace($rootNamespace): string
22
	{
23
		return $rootNamespace . '\Storyblok\Page';
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