1 | <?php declare(strict_types = 1); |
||
18 | abstract class GenericAnalyzer |
||
19 | { |
||
20 | /** @var DatabaseInterface */ |
||
21 | protected $database; |
||
22 | |||
23 | /** @var string Metadata class */ |
||
24 | protected $metadataClass = GenericMetadata::class; |
||
25 | |||
26 | /** |
||
27 | * Generator constructor. |
||
28 | * |
||
29 | * @param DatabaseInterface $database Database instance |
||
30 | */ |
||
31 | public function __construct(DatabaseInterface $database) |
||
35 | |||
36 | /** |
||
37 | * Analyze and create metadata collection. |
||
38 | * |
||
39 | * @return GenericMetadata[] Metadata collection |
||
40 | */ |
||
41 | abstract public function analyze() : array; |
||
42 | |||
43 | /** |
||
44 | * Get correct field name. |
||
45 | * |
||
46 | * @param string $fieldName Original field name |
||
47 | * |
||
48 | * @return string Correct PHP-supported field name |
||
49 | */ |
||
50 | protected function fieldName(string $fieldName) : string |
||
54 | |||
55 | /** |
||
56 | * Transliterate string to english. |
||
57 | * |
||
58 | * @param string $string Source string |
||
59 | * |
||
60 | * @return string Transliterated string |
||
61 | */ |
||
62 | protected function transliterated(string $string) : string |
||
119 | |||
120 | /** |
||
121 | * Get correct full entity name with name space. |
||
122 | * |
||
123 | * @param string $navigationName Original navigation entity name |
||
124 | * @param string $namespace Namespace |
||
125 | * |
||
126 | * @return string Correct PHP-supported entity name |
||
127 | */ |
||
128 | protected function fullEntityName(string $navigationName, string $namespace = null) : string |
||
132 | |||
133 | /** |
||
134 | * Get correct entity name. |
||
135 | * |
||
136 | * @param string $navigationName Original navigation entity name |
||
137 | * |
||
138 | * @return string Correct PHP-supported entity name |
||
139 | */ |
||
140 | protected function entityName(string $navigationName) : string |
||
144 | |||
145 | /** |
||
146 | * Remove all wrong characters from entity name |
||
147 | * |
||
148 | * @param string $navigationName Original navigation entity name |
||
149 | * |
||
150 | * @return string Correct PHP-supported entity name |
||
151 | */ |
||
152 | protected function getValidName(string $navigationName) : string |
||
156 | |||
157 | /** |
||
158 | * Get class constant name by its value. |
||
159 | * |
||
160 | * @param string $value Constant value |
||
161 | * @param string $className Class name |
||
162 | * |
||
163 | * @return string Full constant name |
||
164 | */ |
||
165 | protected function constantNameByValue(string $value, string $className) : string |
||
178 | } |
||
179 | //[PHPCOMPRESSOR(remove,end)] |
||
180 |