PostForm::getFormName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Blog\Post;
6
7
use Yiisoft\Form\FormModel;
8
use Yiisoft\Validator\Rule\Required;
9
10
final class PostForm extends FormModel
11
{
12
    private ?string $title = null;
13
    private ?string $content = null;
14
    private array $tags = [];
15
16
    public function getTitle(): string
17
    {
18
        return $this->title;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->title could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
19
    }
20
21
    public function getContent(): ?string
22
    {
23
        return $this->content;
24
    }
25
26
    public function getFormName(): string
27
    {
28
        return '';
29
    }
30
31
    public function getTags(): array
32
    {
33
        return $this->tags;
34
    }
35
36
    public function getRules(): array
37
    {
38
        return [
39
            'title' => [
40
                new Required(),
41
            ],
42
            'content' => [
43
                new Required(),
44
            ],
45
        ];
46
    }
47
}
48