21 $this->originalString = $yumlString;
25 private function getFkName($table, $prefix =
"id") {
26 return $prefix . \ucfirst ( $table );
31 $this->parts = \preg_split (
'@\ *?,\ *?@', $str );
32 foreach ( $this->parts as $part ) {
40 \preg_match_all (
'@\[\w+[\|\]]@', $part, $matches );
41 if (\
sizeof ( $matches [0] ) > 0) {
42 foreach ( $matches [0] as $match ) {
43 $table = \substr ( $match, 1, \strlen ( $match ) - 2 );
44 $this->tables [$table] = [ ];
50 $tables = \array_keys ( $this->tables );
52 $matchProperties = [ ];
53 \preg_match (
'@\[' . $table .
'\|(.*?)\]@', $this->originalString, $matchProperties );
54 if (isset ( $matchProperties [1] )) {
55 $properties = $matchProperties [1];
68 $properties = \explode (
";", $propertiesString );
69 foreach ( $properties as $property ) {
71 if (! isset ( $this->tables [$table] [
"properties"] ))
72 $this->tables [$table] [
"properties"] = [ ];
73 $this->tables [$table] [
"properties"] [] = $result;
80 \preg_match_all (
'@«(.+?)»@', $property, $matches );
81 if (is_array ( $matches )) {
82 foreach ( $matches as $match ) {
83 if (isset ( $match [0] )) {
84 $property = \str_replace ( $match [0],
"", $property );
86 case $this->stereotypes [
"pk"] :
87 $result [
"pk"] =
true;
89 case $this->stereotypes [
"null"] :
90 $result [
"null"] =
true;
95 $parts = \explode (
":", $property );
96 \preg_match (
'@\ *?(\w+)@',
$parts [0], $match );
97 if (isset ( $match [1] ))
98 $result [
"name"] = $match [1];
99 if (isset (
$parts [1] )) {
100 $result [
"type"] =
$parts [1];
109 foreach ( $this->tables [$table] [
"properties"] as $property ) {
110 if (! isset ( $result ))
111 $result = $property [
"name"];
112 if (isset ( $property [
"pk"] ) && $property [
"pk"])
113 return $property [
"name"];
119 foreach ( $this->tables [$table] [
"properties"] as $property ) {
120 if ($property [
"name"] === $fieldName)
121 return $property [
"type"];
128 foreach ( $this->tables [$table] [
"properties"] as $property ) {
129 if (isset ( $property [
"pk"] ) && $property [
"pk"])
130 $result [] = $property [
"name"];
137 \preg_match_all (
'@\[' . $table .
'\][^,]*?1-.*?\[(\w+)\]@', $this->originalString, $matches );
139 \preg_match_all (
'@\[(\w+)\].*?-[^,]*?1\[' . $table .
'\]@', $this->originalString, $matches );
144 if (\
sizeof ( $matches ) > 1) {
147 foreach ( $matches [1] as $match ) {
150 $this->tables [$table] [
"relations"] [] = [
"TABLE_NAME" => $tableName,
"COLUMN_NAME" => $fk ];
158 \preg_match_all (
'@\[' . $table .
'\][^,]*?\*-.*?\*\[(\w+)\]@', $this->originalString, $matches );
164 $myFk = $this->
getFkName ( $table, $myPk );
166 if (\
sizeof ( $matches ) > 1) {
167 foreach ( $matches [1] as $match ) {
171 $fk = $this->
getFkName ( $tableName, $pk );
173 $newTable = $table .
"_" . $tableName;
174 $this->tables [$newTable] = [ ];
175 $this->tables [$newTable] [
"properties"] [] = [
"name" => $myFk,
"type" => $myFkType,
"pk" => true ];
176 $this->tables [$newTable] [
"properties"] [] = [
"name" => $fk,
"type" => $fkType,
"pk" => true ];
177 $this->tables [$tableName] [
"relations"] [] = [
"TABLE_NAME" => $newTable,
"COLUMN_NAME" => $fk ];
178 $this->tables [$table] [
"relations"] [] = [
"TABLE_NAME" => $newTable,
"COLUMN_NAME" => $myFk ];
193 return \array_keys ( $this->tables );
197 return $this->tables [$table] [
"properties"];
201 if (isset ( $this->tables [$table] [
"relations"] ))
202 return $this->tables [$table] [
"relations"];
_parseRelations($table, $matches)
getFieldType($table, $fieldName)
getFkName($table, $prefix="id")
parseProperties($propertiesString, $table)
parseManyRelations($table)
_parseManyRelations($table, $matches)