Passed
Push — master ( 54cf3c...8581d1 )
by Richard
03:45 queued 11s
created

CreateMissingBlockSolution::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Riclep\Storyblok\Solutions;
4
5
use Facade\IgnitionContracts\RunnableSolution;
0 ignored issues
show
Bug introduced by
The type Facade\IgnitionContracts\RunnableSolution was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
		} else {
23
			return 'Create a view or implement view logic';
24
		}
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 implmenting your own view finding logic.';
31
		} else {
32
			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.';
33
		}
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 = [])
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
}