Neuron-PHP

Field

Normalized representation of a single database column / model field.

A Field carries the logical type plus derivation helpers used by the model, DTO, repository, view and migration generators so that every generator agrees on naming, PHP types, validator types and HTML inputs.

Table of Contents

Properties

$autoIncrement  : bool
$default  : mixed
$isPrimary  : bool
$length  : int|null
$name  : string
$nullable  : bool
$type  : string

Methods

__construct()  : mixed
camelName()  : string
The camelCase form of the column name (e.g. author_id -> authorId).
dtoType()  : string
The Neuron DTO validator type.
fromArrayExpr()  : string
Expression that hydrates this field from a data array element.
getter()  : string
The getter method name.
htmlInputType()  : string
The HTML form input type for create/edit forms.
isDateTime()  : bool
Whether this field represents a date/time value.
isPhpNullable()  : bool
Whether the model property should be declared nullable.
isTextarea()  : bool
Whether the field should render as a textarea instead of an input.
isTimestamp()  : bool
Whether this field is one of the auto-managed timestamp columns.
label()  : string
Human friendly label (e.g. author_id -> Author Id).
phinxType()  : string
The Phinx migration column type.
phpBaseType()  : string
The scalar PHP type without nullability prefix.
phpDefaultLiteral()  : string
The default value literal for a model property declaration.
phpType()  : string
The PHP type hint for the model property/getter.
propertyName()  : string
The model property name (underscore-prefixed camelCase).
setter()  : string
The setter method name.
studlyName()  : string
The StudlyCase form of the column name (e.g. author_id -> AuthorId).
toArrayExpr()  : string
Expression that serializes this field for toArray().

Properties

$autoIncrement read-only

public bool $autoIncrement = false

$default read-only

public mixed $default = null

$isPrimary read-only

public bool $isPrimary = false

$length read-only

public int|null $length = null

$name read-only

public string $name

$nullable read-only

public bool $nullable = false

$type read-only

public string $type = 'string'

Methods

__construct()

public __construct(string $name[, string $type = 'string' ][, bool $nullable = false ][, int|null $length = null ][, mixed $default = null ][, bool $isPrimary = false ][, bool $autoIncrement = false ]) : mixed
Parameters
$name : string

Column name (snake_case)

$type : string = 'string'

Logical type (string, text, integer, biginteger, float, decimal, boolean, date, datetime, time, json, email, uuid)

$nullable : bool = false

Whether the column accepts null

$length : int|null = null

Maximum length for string types

$default : mixed = null

Column default value

$isPrimary : bool = false

Whether this is the primary key

$autoIncrement : bool = false

Whether the primary key auto-increments

camelName()

The camelCase form of the column name (e.g. author_id -> authorId).

public camelName() : string
Return values
string

dtoType()

The Neuron DTO validator type.

public dtoType() : string
Return values
string

fromArrayExpr()

Expression that hydrates this field from a data array element.

public fromArrayExpr(string $element) : string
Parameters
$element : string

PHP expression for the source value (e.g. "$data['name']")

Return values
string

getter()

The getter method name.

public getter() : string
Return values
string

htmlInputType()

The HTML form input type for create/edit forms.

public htmlInputType() : string
Return values
string

isDateTime()

Whether this field represents a date/time value.

public isDateTime() : bool
Return values
bool

isPhpNullable()

Whether the model property should be declared nullable.

public isPhpNullable() : bool

Date/time properties are always nullable (no scalar default exists) as is the auto-increment primary key.

Return values
bool

isTextarea()

Whether the field should render as a textarea instead of an input.

public isTextarea() : bool
Return values
bool

isTimestamp()

Whether this field is one of the auto-managed timestamp columns.

public isTimestamp() : bool
Return values
bool

label()

Human friendly label (e.g. author_id -> Author Id).

public label() : string
Return values
string

phinxType()

The Phinx migration column type.

public phinxType() : string
Return values
string

phpBaseType()

The scalar PHP type without nullability prefix.

public phpBaseType() : string
Return values
string

phpDefaultLiteral()

The default value literal for a model property declaration.

public phpDefaultLiteral() : string
Return values
string

phpType()

The PHP type hint for the model property/getter.

public phpType() : string
Return values
string

propertyName()

The model property name (underscore-prefixed camelCase).

public propertyName() : string
Return values
string

setter()

The setter method name.

public setter() : string
Return values
string

studlyName()

The StudlyCase form of the column name (e.g. author_id -> AuthorId).

public studlyName() : string
Return values
string

toArrayExpr()

Expression that serializes this field for toArray().

public toArrayExpr() : string
Return values
string
On this page

Search results