ViewPresenter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 30
ccs 15
cts 15
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A viewPath() 0 7 2
A viewParams() 0 7 1
A render() 0 6 1
1
<?php
2
3
namespace ThinkOne\NovaFlexibleContentFieldShortcode;
4
5
use Illuminate\Support\Facades\View;
6
use Illuminate\Support\Str;
7
8
abstract class ViewPresenter implements ShortcodePresenter
9
{
10
    protected string $viewPath = '';
11
12
    protected array $viewParams = [];
13
14 2
    public function render(string $key, array $attributes = [], array $options = []): string
15
    {
16 2
        return View::make(
17 2
            $this->viewPath($key, $attributes, $options),
18 2
            $this->viewParams($key, $attributes, $options),
19 2
        )->render();
20
    }
21
22 2
    public function viewPath(string $key, array $attributes = [], array $options = []): string
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    public function viewPath(/** @scrutinizer ignore-unused */ string $key, array $attributes = [], array $options = []): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $attributes is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    public function viewPath(string $key, /** @scrutinizer ignore-unused */ array $attributes = [], array $options = []): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    public function viewPath(string $key, array $attributes = [], /** @scrutinizer ignore-unused */ array $options = []): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24 2
        if (!$this->viewPath) {
25 1
            return 'shortcodes.' . Str::kebab(class_basename(get_called_class()));
26
        }
27
28 1
        return $this->viewPath;
29
    }
30
31 2
    public function viewParams(string $key, array $attributes = [], array $options = []): array
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

31
    public function viewParams(/** @scrutinizer ignore-unused */ string $key, array $attributes = [], array $options = []): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33 2
        return [
34 2
            'shortcodeData' => array_merge(
35 2
                $this->viewParams,
36 2
                $options,
37 2
                $attributes,
38 2
            ),
39 2
        ];
40
    }
41
}
42