Passed
Push — dev ( 392257...472d6e )
by Janko
10:08
created

getCodeDefinitions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 18
nc 2
nop 0
dl 0
loc 24
ccs 21
cts 21
cp 1
crap 2
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib;
6
7
use JBBCode\CodeDefinition;
8
use JBBCode\CodeDefinitionBuilder;
9
use JBBCode\CodeDefinitionSet;
10
use JBBCode\validators\CssColorValidator;
11
use Override;
0 ignored issues
show
Bug introduced by
The type Override 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...
12
13
final class StuBbCodeWithImageDefinitionSet implements CodeDefinitionSet
14
{
15
    /** @var CodeDefinition[]|null */
16
    private ?array $definitions = null;
17
18 1
    #[Override]
19
    public function getCodeDefinitions(): array
20
    {
21 1
        if ($this->definitions === null) {
22 1
            $this->definitions = [
23 1
                (new CodeDefinitionBuilder('b', '<strong>{param}</strong>'))->build(),
24 1
                (new CodeDefinitionBuilder('i', '<em>{param}</em>'))->build(),
25 1
                (new CodeDefinitionBuilder('u', '<u>{param}</u>'))->build(),
26 1
                (new CodeDefinitionBuilder(
27 1
                    'color',
28 1
                    '<span style="color: {option}">{param}</span>'
29 1
                ))
30 1
                    ->setUseOption(true)
31 1
                    ->setOptionValidator(new CssColorValidator())
32 1
                    ->build(),
33 1
                (new CodeDefinitionBuilder(
34 1
                    'img',
35 1
                    '<img src="{param}" style="max-height: 100%;max-width:100%;" />'
36 1
                ))
37 1
                    ->setBodyValidator(new StuBbCodeImageValidator())
38 1
                    ->build(),
39 1
            ];
40
        }
41 1
        return $this->definitions;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->definitions could return the type null which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
42
    }
43
}
44