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
|
1 |
|
public function __construct($displayProperties = true, $displayAssociations = true, $displayMethods = false, $displayMethodsParams = false, $displayPropertiesTypes = false) { |
18
|
1 |
|
$this->displayProperties = $displayProperties; |
19
|
1 |
|
$this->displayAssociations = $displayAssociations; |
20
|
1 |
|
$this->displayMethods = $displayMethods; |
21
|
1 |
|
$this->displayMethodsParams = $displayMethodsParams; |
22
|
1 |
|
$this->displayPropertiesTypes = $displayPropertiesTypes; |
23
|
1 |
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* |
27
|
|
|
* @return ClassToYuml[]|string[] |
28
|
|
|
*/ |
29
|
1 |
|
public function parse() { |
30
|
1 |
|
$yumlResult = [ ]; |
31
|
1 |
|
$config = Startup::getConfig (); |
32
|
1 |
|
$files = CacheManager::getModelsFiles ( $config, true ); |
33
|
1 |
|
if (\sizeof ( $files ) !== 0) { |
34
|
1 |
|
foreach ( $files as $file ) { |
35
|
1 |
|
$completeName = ClassUtils::getClassFullNameFromFile ( $file ); |
36
|
1 |
|
$yumlR = new ClassToYuml ( $completeName, $this->displayProperties, false, $this->displayMethods, $this->displayMethodsParams, $this->displayPropertiesTypes, false ); |
37
|
1 |
|
$yumlResult [] = $yumlR; |
38
|
|
|
} |
39
|
1 |
|
if ($this->displayAssociations) { |
40
|
1 |
|
$count = \sizeof ( $files ); |
41
|
1 |
|
for($i = 0; $i < $count; $i ++) { |
42
|
1 |
|
$result = $yumlResult [$i]->oneToManyTostring (); |
43
|
1 |
|
if (UString::isNotNull ( $result )) |
44
|
1 |
|
$yumlResult [] = $result; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
} |
48
|
1 |
|
return $yumlResult; |
49
|
|
|
} |
50
|
|
|
|
51
|
1 |
|
public function __toString() { |
52
|
1 |
|
return \implode ( Yuml::$groupeSeparator, $this->parse () ); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|