Completed
Push — master ( 499e80...f97bb0 )
by Jean-Christophe
01:49
created

DbExport   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A exports() 0 16 3
A addManyToMany() 0 5 2
1
<?php
2
namespace Ubiquity\db\export;
3
4
use Ubiquity\controllers\Startup;
5
use Ubiquity\cache\CacheManager;
6
use Ubiquity\orm\parser\ManyToManyParser;
7
8
class DbExport{
9
	protected $manyToManys=[];
10
11
	public function __construct(){
12
13
	}
14
15
	public function exports(){
16
		$result=[];
17
		$config=Startup::getConfig();
18
		$models=CacheManager::getModels($config,true);
19
		foreach ($models as $model){
20
			$tableExport=new TableExport($model);
21
			$result[]=$tableExport->exports($this);
22
		}
23
		foreach ($this->manyToManys as $target=>$ManyToManyParser){
24
			$ManyToManyParser->init();
25
			$sqlExport=new SqlExport();
26
			$fields=[$ManyToManyParser->getFkField(),$ManyToManyParser->getMyFkField()];
27
			$result[]=$sqlExport->exports($target,$fields);
28
		}
29
		return \implode("\n", $result);
30
	}
31
32
	public function addManyToMany($jointable,$memberTargetEntity){
33
		if(!isset($this->manyToManys[$jointable])){
34
			$this->manyToManys[$jointable]=new ManyToManyParser($memberTargetEntity["class"], $memberTargetEntity["member"]);
35
		}
36
	}
37
}
38