Test Failed
Pull Request — master (#59)
by
unknown
12:59 queued 01:57
created

YumlModelsCreator::fieldIsEmail()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 5
c 1
b 1
f 0
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
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 1
	protected function init($config){
14 1
		parent::init($config);
15 1
	}
16
17 1
	public function initYuml($yumlString) {
18 1
		$this->yumlParser=new YumlParser($yumlString);
19 1
	}
20
21
22 1
	protected function getTablesName(){
23 1
		return $this->yumlParser->getTableNames();
24
	}
25
26 1
	protected function getFieldsInfos($tableName) {
27 1
		$fieldsInfos=array();
28 1
		$fields = $this->yumlParser->getFields($tableName);
29 1
		foreach ($fields as $field) {
30 1
			$fieldsInfos[$field['name']] = ["Type"=>$field['type'],"Nullable"=>(isset($field["null"]) && $field["null"]),"Email" => $this->fieldIsEmail($field['Field'])];
31
		}
32 1
		return $fieldsInfos;
33
	}
34
35 1
    protected function fieldIsEmail($field)
36 1
    {
37
        $possibleColumnNames = array("email", "mail", "courrierelectronique", "ecourrier", "mailaddresse", "mailaddresse", "mailadress", "mailadresse");
38
        $res = false;
39 1
40 1
        if (in_array($field, $possibleColumnNames)) {
41
            $res = true;
42
        }
43
        return $res;
44
    }
45
46
	protected function getPrimaryKeys($tableName){
47
		return $this->yumlParser->getPrimaryKeys($tableName);
48
	}
49
50
	protected function getForeignKeys($tableName,$pkName){
51
		return $this->yumlParser->getForeignKeys($tableName);
52
	}
53
}
54