Completed
Push — master ( 442c30...3b833c )
by
unknown
12s
created

Resource   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A onAfterWrite() 0 5 2
1
<?php
2
3
namespace SilverStripe\CKANRegistry\Model;
4
5
use SilverStripe\ORM\DataObject;
6
7
/**
8
 * A CKAN Resource that belongs to a DataSet/Package, as to be accessed via the CKAN API.
9
 */
10
class Resource extends DataObject
11
{
12
    private static $table_name = 'CKANResource';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
13
14
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
15
        'Name' => 'Varchar',
16
        'Endpoint' => 'Varchar',
17
        'DataSet' => 'Varchar',
18
        'Identifier' => 'Varchar',
19
    ];
20
21
    private static $has_many = [
0 ignored issues
show
introduced by
The private property $has_many is not used, and could be removed.
Loading history...
22
        'Fields' => ResourceField::class,
23
        'Filters' => ResourceFilter::class,
24
    ];
25
26
    public function onAfterWrite()
27
    {
28
        if ($this->changed('Identifier')) {
0 ignored issues
show
Bug introduced by
The method changed() does not exist on SilverStripe\CKANRegistry\Model\Resource. 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

28
        if ($this->/** @scrutinizer ignore-call */ changed('Identifier')) {
Loading history...
29
            $this->Fields()->removeAll();
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on SilverStripe\CKANRegistry\Model\Resource. 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

29
            $this->/** @scrutinizer ignore-call */ 
30
                   Fields()->removeAll();
Loading history...
30
            $this->Filters()->removeAll();
0 ignored issues
show
Bug introduced by
The method Filters() does not exist on SilverStripe\CKANRegistry\Model\Resource. 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

30
            $this->/** @scrutinizer ignore-call */ 
31
                   Filters()->removeAll();
Loading history...
31
        }
32
    }
33
}
34