Passed
Pull Request — 4 (#930)
by Steve
03:44
created

TestContentElement   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 2
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