Completed
Branch feature/pre-split (669609)
by Anton
03:30
created

MorphedTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configureMorphed() 0 4 1
A isMorphed() 0 4 1
localKey() 0 1 ?
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
namespace Spiral\ORM\Entities\Loaders\Traits;
8
9
use Spiral\Database\Builders\SelectQuery;
10
use Spiral\ORM\Entities\Loaders\AbstractLoader;
11
use Spiral\ORM\Record;
12
13
trait MorphedTrait
14
{
15
    protected function configureMorphed(SelectQuery $query, AbstractLoader $parent)
0 ignored issues
show
Unused Code introduced by
The parameter $query is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $parent is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
    {
17
        //Need role somewhere here
18
    }
19
20
    /**
21
     * Indication that relation is morphed.
22
     *
23
     * @return bool
24
     */
25
    protected function isMorphed(): bool
26
    {
27
        return !empty($this->localKey(Record::MORPH_KEY));
28
    }
29
30
    /**
31
     * Generate sql identifier using loader alias and value from relation definition. Key name to be
32
     * fetched from schema.
33
     *
34
     * Example:
35
     * $this->getKey(Record::OUTER_KEY);
36
     *
37
     * @param string $key
38
     *
39
     * @return string|null
40
     */
41
    abstract protected function localKey($key);
42
}