Total Complexity | 7 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | class OneToOne extends Relation |
||
12 | { |
||
13 | protected $type = RelationConfig::TYPE_ONE_TO_ONE; |
||
14 | |||
15 | protected $cascade; |
||
16 | |||
17 | /** |
||
18 | * @return bool |
||
19 | */ |
||
20 | public function getCascade() |
||
21 | { |
||
22 | return $this->cascade; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param bool $cascade |
||
27 | * |
||
28 | * @return Relation |
||
29 | */ |
||
30 | public function setCascade(bool $cascade) |
||
31 | { |
||
32 | $this->cascade = $cascade; |
||
33 | |||
34 | return $this; |
||
35 | } |
||
36 | |||
37 | public function setMapper(Mapper $mapper): Relation |
||
38 | { |
||
39 | if ($mapper && ! $this->foreignKey) { |
||
40 | $this->foreignKey = Inflector::singularize($mapper->getName()) . '_id'; |
||
41 | } |
||
42 | |||
43 | if ($mapper && ! $this->nativeKey) { |
||
44 | $this->nativeKey = $mapper->getPrimaryKey(); |
||
45 | } |
||
46 | |||
47 | return parent::setMapper($mapper); |
||
48 | } |
||
50 |