MCPcopy Create free account
hub / github.com/VemtoOrg/vemto2 / getAlias

Method getAlias

src/php/common/ModelRepository.php:219–233  ·  view source on GitHub ↗
(string $classContent, $import)

Source from the content-addressed store, hash-verified

217 }
218
219 public function getAlias(string $classContent, $import) {
220 $useStatement = $import->name;
221 $alias = $import->getShortName();
222
223 // Regex to find the use statement for the specified class/interface/trait
224 $pattern = '/use\s+' . preg_quote($useStatement, '/') . '\s*(?:as\s+(.*?))?\s*;/';
225 preg_match($pattern, $classContent, $matches);
226
227 if (!empty($matches)) {
228 // If an alias is defined, use it; otherwise, use the last part of the use statement (class/interface/trait name)
229 $alias = isset($matches[1]) ? $matches[1] : basename(str_replace('\\', '/', $useStatement));
230 }
231
232 return $alias;
233 }
234
235 public function getAllImports($model)
236 {

Callers 1

getImportDataMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected