Passed
Push — master ( 363fd9...400deb )
by Alexander
10:38
created

PostForm   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getTags() 0 3 1
A formName() 0 3 1
A getContent() 0 3 1
A rules() 0 8 1
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 formName(): string
27
    {
28
        return '';
29
    }
30
31
    public function getTags(): array
32
    {
33
        return $this->tags;
34
    }
35
36
    protected function rules(): array
37
    {
38
        return [
39
            'title' => [
40
                new Required(),
41
            ],
42
            'content' => [
43
                new Required(),
44
            ]
45
        ];
46
    }
47
}
48