Passed
Push — master ( 5a27b6...d7396e )
by Jean-Christophe
02:39
created

ClassesToYuml::parse()   A

Complexity

Conditions 6
Paths 3

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 15
nc 3
nop 0
dl 0
loc 20
rs 9.2222
c 0
b 0
f 0
1
<?php
2
3
namespace Ubiquity\utils\yuml;
4
5
use Ubiquity\cache\CacheManager;
6
use Ubiquity\controllers\Startup;
7
use Ubiquity\cache\ClassUtils;
8
use Ubiquity\utils\base\UString;
9
10
class ClassesToYuml {
11
	private $displayProperties;
12
	private $displayAssociations;
13
	private $displayMethods;
14
	private $displayMethodsParams;
15
	private $displayPropertiesTypes;
16
17
	public function __construct($displayProperties = true, $displayAssociations = true, $displayMethods = false, $displayMethodsParams = false, $displayPropertiesTypes = false) {
18
		$this->displayProperties = $displayProperties;
19
		$this->displayAssociations = $displayAssociations;
20
		$this->displayMethods = $displayMethods;
21
		$this->displayMethodsParams = $displayMethodsParams;
22
		$this->displayPropertiesTypes = $displayPropertiesTypes;
23
	}
24
25
	/**
26
	 *
27
	 * @return ClassToYuml[]|string[]
28
	 */
29
	public function parse() {
30
		$yumlResult = [ ];
31
		$config = Startup::getConfig ();
32
		$files = CacheManager::getModelsFiles ( $config, true );
33
		if (\sizeof ( $files ) !== 0) {
34
			foreach ( $files as $file ) {
35
				$completeName = ClassUtils::getClassFullNameFromFile ( $file );
36
				$yumlR = new ClassToYuml ( $completeName, $this->displayProperties, false, $this->displayMethods, $this->displayMethodsParams, $this->displayPropertiesTypes, false );
37
				$yumlResult [] = $yumlR;
38
			}
39
			if ($this->displayAssociations) {
40
				$count = \sizeof ( $files );
41
				for($i = 0; $i < $count; $i ++) {
42
					$result = $yumlResult [$i]->oneToManyTostring ();
43
					if (UString::isNotNull ( $result ))
44
						$yumlResult [] = $result;
45
				}
46
			}
47
		}
48
		return $yumlResult;
49
	}
50
51
	public function __toString() {
52
		return \implode ( Yuml::$groupeSeparator, $this->parse () );
53
	}
54
}
55