Passed
Push — master ( 964b09...302996 )
by Daniel
59:27 queued 48:09
created

PolyItem::Objects()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 4
nc 3
nop 0
dl 0
loc 6
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\ORM\Tests\ManyManyThroughListTest;
4
5
use Generator;
6
use SilverStripe\Dev\TestOnly;
7
use SilverStripe\ORM\DataObject;
8
9
class PolyItem extends DataObject implements TestOnly
10
{
11
    private static $table_name = 'ManyManyThroughListTest_PolyItem';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
12
13
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
14
        'Title' => 'Varchar'
15
    ];
16
17
    private static $has_many = [
0 ignored issues
show
introduced by
The private property $has_many is not used, and could be removed.
Loading history...
18
        'JoinObject' => PolyJoinObject::class . '.Items',
19
    ];
20
21
    /**
22
     * Placeholder for missing belongs_many_many for polymorphic relation
23
     *
24
     * @todo Make this work for belongs_many_many
25
     * @return Generator|DataObject[]
26
     */
27
    public function Objects()
28
    {
29
        foreach ($this->JoinObject() as $object) {
0 ignored issues
show
Bug introduced by
The method JoinObject() does not exist on SilverStripe\ORM\Tests\M...hroughListTest\PolyItem. 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
        foreach ($this->/** @scrutinizer ignore-call */ JoinObject() as $object) {
Loading history...
30
            $objectParent = $object->Parent();
31
            if ($objectParent && $objectParent->exists()) {
32
                yield $objectParent;
33
            }
34
        }
35
    }
36
}
37