CMSMainTest_ClassA   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A onBeforeWrite() 0 6 2
1
<?php
2
3
namespace SilverStripe\CMS\Tests\Controllers;
4
5
use SilverStripe\CMS\Model\SiteTree;
6
use SilverStripe\Dev\TestOnly;
7
use SilverStripe\ORM\ValidationException;
8
9
class CMSMainTest_ClassA extends SiteTree implements TestOnly
10
{
11
    private static $table_name = 'CMSMainTest_ClassA';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
12
13
    private static $allowed_children = [CMSMainTest_ClassB::class];
0 ignored issues
show
introduced by
The private property $allowed_children is not used, and could be removed.
Loading history...
14
15
    protected function onBeforeWrite()
16
    {
17
        parent::onBeforeWrite();
18
19
        if ($this->ClassName !== self::class) {
20
            throw new ValidationException("Class saved with incorrect ClassName");
21
        }
22
    }
23
}
24