Passed
Pull Request — 4 (#930)
by Steve
04:26 queued 43s
created

TestContentElement::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace DNADesign\Elemental\Tests\Src;
4
5
use DNADesign\Elemental\Models\ElementContent;
6
use SilverStripe\Dev\TestOnly;
7
8
class TestContentElement extends ElementContent implements TestOnly
9
{
10
    public const INVALID_TITLE = 'INVALID_TITLE';
11
12
    public const INVALID_TITLE_MESSAGE = 'INVALID_TITLE_MESSAGE';
13
14
    public function validate()
15
    {
16
        $validationResult = parent::validate();
17
        if ($this->Content === static::INVALID_TITLE) {
0 ignored issues
show
Bug Best Practice introduced by
The property Content does not exist on DNADesign\Elemental\Tests\Src\TestContentElement. Since you implemented __get, consider adding a @property annotation.
Loading history...
18
            $validationResult->addFieldError('Content', static::INVALID_TITLE_MESSAGE);
19
        }
20
        return $validationResult;
21
    }
22
}
23