Overview

Namespaces

  • Charcoal
    • Config

Classes

  • AbstractConfig
  • AbstractEntity
  • GenericConfig

Interfaces

  • ConfigInterface
  • ConfigurableInterface
  • DelegatesAwareInterface
  • EntityInterface
  • FileAwareInterface
  • SeparatorAwareInterface

Traits

  • ConfigurableTrait
  • DelegatesAwareTrait
  • FileAwareTrait
  • SeparatorAwareTrait
  • Overview
  • Namespace
  • Class

Class AbstractEntity

Default data model.

Notes on \ArrayAccess:

  • Keys SHOULD be formatted as "snake_case" (e.g., "first_name") or "camelCase" (e.g., "firstName"). and WILL be converted to the latter PSR-1 to access or assign values.
  • Values are accessed and assigned via methods and properties which MUST be formatted as "camelCase", e.g.: $firstName, firstName(), setFirstName().
  • A key-value pair is internally passed to a (non-private / non-static) setter method (if present) or assigned to a (non-private / non-static) property (declared or not) and tracks affected keys.
Charcoal\Config\AbstractEntity implements Charcoal\Config\EntityInterface

Direct known subclasses

Charcoal\Config\AbstractConfig

Indirect known subclasses

Charcoal\Config\GenericConfig
Abstract
Namespace: Charcoal\Config
Located at Charcoal/Config/AbstractEntity.php
Methods summary
public array
# keys( )

Gets the data keys on this entity.

Gets the data keys on this entity.

Returns

array

Implementation of

Charcoal\Config\EntityInterface::keys()
public array
# data( array $keys = null )

Gets all data, or a subset, from this entity.

Gets all data, or a subset, from this entity.

Parameters

$keys
Optional. Extracts only the requested data.

Returns

array
Key-value array of data, excluding pairs with NULL values.

Uses

Charcoal\Config\AbstractEntity::offsetExists()
Charcoal\Config\AbstractEntity::offsetGet()

Implementation of

Charcoal\Config\EntityInterface::data()
public Charcoal\Config\AbstractEntity
# setData( array $data )

Sets data on this entity.

Sets data on this entity.

Parameters

$data
Key-value array of data to append.

Returns

Charcoal\Config\AbstractEntity

Uses

Charcoal\Config\AbstractEntity::offsetSet()

Implementation of

Charcoal\Config\EntityInterface::setData()
public boolean
# has( string $key )

Determines if this entity contains the specified key and if its value is not NULL.

Determines if this entity contains the specified key and if its value is not NULL.

Parameters

$key
The data key to check.

Returns

boolean
TRUE if $key exists and has a value other than NULL, FALSE otherwise.

Uses

Charcoal\Config\AbstractEntity::offsetExists()

Implementation of

Charcoal\Config\EntityInterface::has()
public mixed
# get( string $key )

Find an entry of the configuration by its key and retrieve it.

Find an entry of the configuration by its key and retrieve it.

Parameters

$key
The data key to retrieve.

Returns

mixed
Value of the requested $key on success, NULL if the $key is not set.

Uses

Charcoal\Config\AbstractEntity::offsetGet()

Implementation of

Charcoal\Config\EntityInterface::get()
public Charcoal\Config\AbstractEntity
# set( string $key, mixed $value )

Assign a value to the specified key on this entity.

Assign a value to the specified key on this entity.

Parameters

$key
The data key to assign $value to.
$value
The data value to assign to $key.

Returns

Charcoal\Config\AbstractEntity
Chainable

Uses

Charcoal\Config\AbstractEntity::offsetSet()

Implementation of

Charcoal\Config\EntityInterface::set()
public boolean
# offsetExists( string $key )

Determines if this entity contains the specified key and if its value is not NULL.

Determines if this entity contains the specified key and if its value is not NULL.

Routine: - If the entity has a getter method (e.g., "foo_bar" → fooBar()), its called and its value is checked; - If the entity has a property (e.g., $fooBar), its value is checked; - If the entity has neither, FALSE is returned.

Parameters

$key
The data key to check.

Returns

boolean
TRUE if $key exists and has a value other than NULL, FALSE otherwise.

Throws

InvalidArgumentException
If the $key is not a string or is a numeric value.

See

\ArrayAccess

Used by

Charcoal\Config\AbstractEntity::data()
Charcoal\Config\AbstractEntity::has()
public mixed
# offsetGet( string $key )

Returns the value from the specified key on this entity.

Returns the value from the specified key on this entity.

Routine: - If the entity has a getter method (e.g., "foo_bar" → fooBar()), its called and returns its value; - If the entity has a property (e.g., $fooBar), its value is returned; - If the entity has neither, NULL is returned.

Parameters

$key
The data key to retrieve.

Returns

mixed
Value of the requested $key on success, NULL if the $key is not set.

Throws

InvalidArgumentException
If the $key is not a string or is a numeric value.

See

\ArrayAccess

Used by

Charcoal\Config\AbstractEntity::data()
Charcoal\Config\AbstractEntity::get()
public
# offsetSet( string $key, mixed $value )

Assigns the value to the specified key on this entity.

Assigns the value to the specified key on this entity.

Routine: - The data key is added to the entity's key pool. - If the entity has a setter method (e.g., "foo_bar" → setFooBar()), its called and passed the value; - If the entity has NO setter method, the value is assigned to a property (e.g., $fooBar).

Parameters

$key
The data key to assign $value to.
$value
The data value to assign to $key.

Throws

InvalidArgumentException
If the $key is not a string or is a numeric value.

See

\ArrayAccess

Used by

Charcoal\Config\AbstractEntity::setData()
Charcoal\Config\AbstractEntity::set()
Charcoal\Config\AbstractEntity::offsetUnset()
public
# offsetUnset( string $key )

Removes the value from the specified key on this entity.

Removes the value from the specified key on this entity.

Routine: - The data key is removed from the entity's key pool. - NULL is assigned to the entity.

Parameters

$key
The data key to remove.

Throws

InvalidArgumentException
If the $key is not a string or is a numeric value.

See

\ArrayAccess

Uses

Charcoal\Config\AbstractEntity::offsetSet()
public array
# jsonSerialize( )

Gets the data that can be serialized with json_encode().

Gets the data that can be serialized with json_encode().

Returns

array
Key-value array of data.

See

\JsonSerializable
public string
# serialize( )

Serializes the data on this entity.

Serializes the data on this entity.

Returns

string
Returns a string containing a byte-stream representation of the object.

See

\Serializable
public
# unserialize( string $data )

Applies the serialized data to this entity.

Applies the serialized data to this entity.

Parameters

$data
The serialized data to extract.

See

\Serializable
final protected string
# camelize( string $str )

Transform a string from "snake_case" to "camelCase".

Transform a string from "snake_case" to "camelCase".

Parameters

$str
The string to camelize.

Returns

string
The camelized string.
Properties summary
protected array $keys

Holds a list of all data keys.

Holds a list of all data keys.

# []
API documentation generated by ApiGen