Documentation

ModelFileParser
in package

Parses models source files.

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

extractModelInfoFromSource()  : array<string|int, mixed>|null
Returns the model namespace, class name and table name.
extractModelRelationsFromSource()  : array<string|int, mixed>|null
Extracts names and types of model relations.
extractClassName()  : mixed
extractNamespace()  : mixed
extractRelations()  : mixed
extractTableName()  : mixed
Returns the table name. This method would return null in case if the $table variable was found, but it value cannot be read. If the variable is not found, the method returns false, allowing the outer loop to go to the next token.

Methods

extractModelInfoFromSource()

Returns the model namespace, class name and table name.

public extractModelInfoFromSource(string $fileContents) : array<string|int, mixed>|null
Parameters
$fileContents : string

Specifies the file contents.

Return values
array<string|int, mixed>|null

Returns an array with keys 'namespace', 'class' and 'table' Returns null if the parsing fails.

extractModelRelationsFromSource()

Extracts names and types of model relations.

public extractModelRelationsFromSource(string $fileContents) : array<string|int, mixed>|null
Parameters
$fileContents : string

Specifies the file contents.

Return values
array<string|int, mixed>|null

Returns an array with keys matching the relation types and values containing relation names as array. Returns null if the parsing fails.

extractClassName()

protected extractClassName(mixed $stream) : mixed
Parameters
$stream : mixed
Return values
mixed

extractNamespace()

protected extractNamespace(mixed $stream) : mixed
Parameters
$stream : mixed
Return values
mixed

extractRelations()

protected extractRelations(mixed $stream) : mixed
Parameters
$stream : mixed
Return values
mixed

extractTableName()

Returns the table name. This method would return null in case if the $table variable was found, but it value cannot be read. If the variable is not found, the method returns false, allowing the outer loop to go to the next token.

protected extractTableName(mixed $stream) : mixed
Parameters
$stream : mixed
Return values
mixed

Search results