Passed
Branch dev_2x (3e8772)
by Adrian
01:42
created

ManyToOne   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
c 0
b 0
f 0
dl 0
loc 13
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Orm\Blueprint\Relation;
5
6
use Sirius\Orm\Blueprint\Relation;
7
use Sirius\Orm\Helpers\Inflector;
8
use Sirius\Orm\Relation\RelationConfig;
9
10
class ManyToOne extends Relation
11
{
12
    protected $type = RelationConfig::TYPE_MANY_TO_ONE;
13
14
    protected $foreignKey = 'id';
15
16
    public function setForeignMapper($foreignMapper): Relation
17
    {
18
        if ($foreignMapper && ! $this->nativeKey) {
19
            $this->nativeKey = Inflector::singularize($foreignMapper) . '_id';
20
        }
21
22
        return parent::setForeignMapper($foreignMapper);
23
    }
24
}
25