Passed
Push — master ( 3317fd...38d44b )
by Nicolaas
03:15
created

ObjectsUpdated::getClassNameTitle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Sunnysideup\SimpleTemplateCaching\Model;
4
5
use SilverStripe\ORM\DataObject;
6
7
use SilverStripe\Core\Injector\Injector;
8
9
/**
10
 * A blog category for generalising blog posts.
11
 *
12
*
13
 * @method Blog Blog()
14
 *
15
 * @property string $Title
16
 * @property string $URLSegment
17
 * @property int $BlogID
18
 */
19
class ObjectsUpdated extends DataObject
20
{
21
22
    /**
23
     * {@inheritDoc}
24
     * @var string
25
     */
26
    private static $table_name = 'ObjectsUpdated';
27
28
    /**
29
     * @var array
30
     */
31
    private static $db = [
32
        'ClassNameLastEdited'      => 'Varchar(255)',
33
    ];
34
35
    private static $default_sort = [
36
        'ID' => 'DESC',
37
    ];
38
39
    /**
40
     * @var array
41
     */
42
    private static $summary_fields = [
43
        'Created'      => 'Updated',
44
        'ClassNameLastEdited'      => 'ClassName',
45
        'ClassNameTitle'      => 'Human readable name',
46
    ];
47
48
    /**
49
     * @var array
50
     */
51
    private static $field_labels = [
52
        'Created'      => 'Updated',
53
        'ClassNameLastEdited'      => 'Code name',
54
        'ClassNameTitle'      => 'Human readable name',
55
    ];
56
    /**
57
     * @var array
58
     */
59
    private static $casting = [
60
        'ClassNameTitle'      => 'Varchar',
61
    ];
62
63
    public function getClassNameTitle() : string
64
    {
65
        if(class_exists($this->getOwner()->ClassNameLastEdited)) {
0 ignored issues
show
Bug introduced by
The method getOwner() does not exist on Sunnysideup\SimpleTempla...ng\Model\ObjectsUpdated. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
        if(class_exists($this->/** @scrutinizer ignore-call */ getOwner()->ClassNameLastEdited)) {
Loading history...
66
            return Injector::inst()->get($this->getOwner()->ClassNameLastEdited)->i18n_singular_name();
67
        }
68
        return 'class not found';
69
    }
70
}
71