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

YumlModelsCreator::getFieldsInfos()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 3
Ratio 37.5 %

Importance

Changes 0
Metric Value
dl 3
loc 8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
namespace Ubiquity\orm\creator\yuml;
3
4
use Ubiquity\orm\creator\ModelsCreator;
5
6
7
class YumlModelsCreator extends ModelsCreator{
8
	/**
9
	 * @var YumlParser
10
	 */
11
	private $yumlParser;
12
13
	protected function init($config){
14
		parent::init($config);
15
	}
16
17
	public function initYuml($yumlString) {
18
		$this->yumlParser=new YumlParser($yumlString);
19
	}
20
21
22
	protected function getTablesName(){
23
		return $this->yumlParser->getTableNames();
24
	}
25
26
	protected function getFieldsInfos($tableName) {
27
		$fieldsInfos=array();
28
		$fields = $this->yumlParser->getFields($tableName);
29 View Code Duplication
		foreach ($fields as $field) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
			$fieldsInfos[$field['name']] = ["Type"=>$field['type'],"Nullable"=>(isset($field["null"]) && $field["null"])];
31
		}
32
		return $fieldsInfos;
33
	}
34
35
	protected function getPrimaryKeys($tableName){
36
		return $this->yumlParser->getPrimaryKeys($tableName);
37
	}
38
39
	protected function getForeignKeys($tableName,$pkName){
0 ignored issues
show
Unused Code introduced by
The parameter $pkName 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...
40
		return $this->yumlParser->getForeignKeys($tableName);
41
	}
42
}
43