Completed
Push — master ( c7b947...966759 )
by Thomas
08:09
created

OneToOneRelationship::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
namespace keeko\tools\model;
3
4
use Propel\Generator\Model\ForeignKey;
5
use Propel\Generator\Model\Table;
6
7
class OneToOneRelationship extends Relationship {
8
	
9
	public function __construct(Table $model, Table $foreign, ForeignKey $fk) {
10
		$this->model = $model;
11
		$this->foreign = $foreign;
12
		$this->fk = $fk;
13
	}
14
	
15
	public function getType() {
16
		return self::ONE_TO_ONE;
17
	}
18
	
19
	public function getRelatedName() {
20
		$relatedName = $this->fk->getPhpName();
21
		if (empty($relatedName)) {
22
			$relatedName = $this->foreign->getPhpName();
23
		}
24
	
25
		return $relatedName;
26
	}
27
	
28
	public function getReverseRelatedName() {
29
		$reverseRelatedName = $this->fk->getRefPhpName();
30
		if (empty($reverseRelatedName)) {
31
			$reverseRelatedName = $this->model->getPhpName();
32
		}
33
	
34
		return $reverseRelatedName;
35
	}
36
}