class StaticConventions implements Conventions

Conventions based on static definition.

Methods

__construct(string $primary = 'id', string $foreign = '%s_id', string $table = '%s')

Create static conventional structure.

string|array|null
getPrimary(string $table)

Returns primary key for table.

array|null
getHasManyReference(string $table, string $key)

Returns referenced table & referenced column.

array|null
getBelongsToReference(string $table, string $key)

Returns referenced table & referencing column.

string
getColumnFromTable(string $name)

No description

Details

at line 26
__construct(string $primary = 'id', string $foreign = '%s_id', string $table = '%s')

Create static conventional structure.

Parameters

string $primary

%s stands for table name

string $foreign

%1$s stands for key used after ->, %2$s for table name

string $table

%1$s stands for key used after ->, %2$s for table name

at line 34
string|array|null getPrimary(string $table)

Returns primary key for table.

Parameters

string $table

Return Value

string|array|null

at line 40
array|null getHasManyReference(string $table, string $key)

Returns referenced table & referenced column.

Example: (author, book) returns [book, author_id]

Parameters

string $table
string $key

Return Value

array|null

[referenced table, referenced column]

Exceptions

AmbiguousReferenceKeyException

at line 50
array|null getBelongsToReference(string $table, string $key)

Returns referenced table & referencing column.

Example (book, author) returns [author, author_id] (book, translator) returns [author, translator_id]

Parameters

string $table
string $key

Return Value

array|null

[referenced table, referencing column]

at line 60
protected string getColumnFromTable(string $name)

No description

Parameters

string $name

Return Value

string