MorphMany::populateEagerQueryFromFkList()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Records\Relations;
4
5
use Nip\Database\Query\AbstractQuery;
6
use Nip\Records\AbstractModels\Record;
7
8
/**
9
 * Class MorphMany
10
 * @package Nip\Records\Relations
11
 */
12
class MorphMany extends MorphOneOrMany
13
{
14
15
    /**
16
     * @param AbstractQuery $query
17
     */
18 1
    public function populateQuerySpecific(AbstractQuery $query)
19
    {
20 1
        $query->where($this->getMorphTypeField() . ' = ?', $this->getMorphValue());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getMorphTypeField() targeting Nip\Records\Relations\Mo...ny::getMorphTypeField() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
$this->getMorphValue() of type string is incompatible with the type array expected by parameter $values of Nip\Database\Query\AbstractQuery::where(). ( Ignorable by Annotation )

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

20
        $query->where($this->getMorphTypeField() . ' = ?', /** @scrutinizer ignore-type */ $this->getMorphValue());
Loading history...
21 1
        $query->where('`' . $this->getFK() . '` = ?', $this->getItemRelationPrimaryKey());
22 1
    }
23
24
    /** @noinspection PhpMissingParentCallCommonInspection
25
     * @inheritdoc
26
     */
27 1
    public function populateEagerQueryFromFkList($query, $fkList)
28
    {
29 1
        $value = $this->hasManager() ? $this->getMorphValue() : '';
30 1
        $query->where($this->getMorphTypeField() . ' = ?', $value);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getMorphTypeField() targeting Nip\Records\Relations\Mo...ny::getMorphTypeField() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
31 1
        return parent::populateEagerQueryFromFkList($query, $fkList);
32
    }
33
34
    /**
35
     * @param Record $item
36
     */
37 1
    public function saveResult(Record $item)
38
    {
39 1
        $value = $this->hasManager() ? $this->getMorphValue() : '';
40 1
        $item->{$this->getMorphTypeField()} = $value;
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getMorphTypeField() targeting Nip\Records\Relations\Mo...ny::getMorphTypeField() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
41 1
        return parent::saveResult($item);
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::saveResult($item) targeting Nip\Records\Relations\HasOneOrMany::saveResult() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
42
    }
43
}
44