Passed
Pull Request — master (#53)
by
unknown
02:35
created

TestDataObject::getLinkedFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Bummzack\SortableFile\Tests\Model;
4
5
use Bummzack\SortableFile\Forms\SortableUploadField;
6
use SilverStripe\Assets\File;
7
use SilverStripe\Dev\TestOnly;
8
use SilverStripe\Forms\FieldList;
9
use SilverStripe\ORM\DataObject;
10
11
class TestDataObject extends DataObject implements TestOnly
12
{
13
14
    private static $has_many = [
0 ignored issues
show
introduced by
The private property $has_many is not used, and could be removed.
Loading history...
15
        'LinkedFilesFile' => FileLinkDataObject::class
16
    ];
17
18
    private static $many_many = [
0 ignored issues
show
introduced by
The private property $many_many is not used, and could be removed.
Loading history...
19
        'Files' => File::class,
20
        'OtherFiles' => File::class,
21
        'LinkedFiles' => [
22
            'through' 			=> FileLinkDataObject::class,
23
            'from' 				=> 'Owner',
24
            'to' 				=> 'File',
25
        ]
26
    ];
27
28
    private static $many_many_extraFields = [
0 ignored issues
show
introduced by
The private property $many_many_extraFields is not used, and could be removed.
Loading history...
29
        'Files' => [ 'SortOrder' => 'Int' ],
30
        'OtherFiles' => [ 'Sort' => 'Int' ]
31
    ];
32
33
    private static $owns = [
0 ignored issues
show
introduced by
The private property $owns is not used, and could be removed.
Loading history...
34
        'FileLinks'
35
    ];
36
37
    public function getCMSFields()
38
    {
39
        return FieldList::create(
40
            SortableUploadField::create('Files'),
41
            SortableUploadField::create('OtherFiles')->setSortColumn('Sort')
42
        );
43
    }
44
45
    public function getLinkedFiles()
46
    {
47
        return $this->LinkedFiles()->sort('Sort');
0 ignored issues
show
Bug introduced by
The method LinkedFiles() does not exist on Bummzack\SortableFile\Tests\Model\TestDataObject. 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

47
        return $this->/** @scrutinizer ignore-call */ LinkedFiles()->sort('Sort');
Loading history...
48
    }
49
}
50