CreateMissingBlockSolution   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 16
c 3
b 0
f 0
dl 0
loc 53
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getRunParameters() 0 4 1
A __construct() 0 3 1
A getRunButtonText() 0 3 1
A getDocumentationLinks() 0 4 1
A getSolutionActionDescription() 0 3 1
A run() 0 3 1
A getSolutionTitle() 0 7 2
A getSolutionDescription() 0 7 2
1
<?php
2
3
namespace Riclep\Storyblok\Solutions;
4
5
use Spatie\Ignition\Contracts\RunnableSolution;
6
use Illuminate\Support\Facades\Artisan;
7
use Illuminate\Support\Str;
8
9
class CreateMissingBlockSolution implements RunnableSolution
10
{
11
	protected $data;
12
13
	public function __construct($data = null)
14
	{
15
		$this->data = $data;
16
	}
17
18
	public function getSolutionTitle(): string
19
	{
20
		if (get_class($this->data) === 'App\Storyblok\Block') {
21
			return 'Create a view or custom Block class';
22
		}
23
24
		return 'Create a view or implement view logic';
25
	}
26
27
	public function getSolutionDescription(): string
28
	{
29
		if (get_class($this->data) === 'App\Storyblok\Block') {
30
			return 'Create one of the following views: `[' . implode(', ', $this->data->views()) . ']` or a create Block class called `App\Storyblok\Blocks\\' . Str::studly($this->data->meta()['component']) . '` and override the `views()` method implementing your own view finding logic. You can also scaffold all your views using `artisan ls:stub-views`.';
31
		}
32
33
		return 'Create one of the following views: `[' . implode(', ', $this->data->views()) . ']` or override the `views()` method in `App\Storyblok\Blocks\\' . Str::studly($this->data->meta()['component']) . '` and implement your own view finding logic. You can also scaffold all your views using `artisan ls:stub-views`.';
34
	}
35
36
	public function getDocumentationLinks(): array
37
	{
38
		return [
39
			'Laravel Storyblok docs' => 'https://ls.sirric.co.uk/docs/',
40
		];
41
	}
42
43
	public function getSolutionActionDescription(): string
44
	{
45
		return 'We can try to solve this exception by running a little code';
46
	}
47
48
	public function getRunButtonText(): string
49
	{
50
		return 'Create ' . Str::studly($this->data->meta()['component']) . ' Block class';
51
	}
52
53
	public function run(array $parameters = []): void
54
	{
55
		Artisan::call('ls:block', $parameters);
56
	}
57
58
	public function getRunParameters(): array
59
	{
60
		return [
61
			'name' => Str::studly($this->data->meta()['component']),
62
		];
63
	}
64
}