Data
+ Inheritance diagram for Data:

Description

A data object with support for annotated magic methods.

Protected Properties

readonly Api Api $api
 
array array self[] AbstractEntity[] $data = []
 
array bool[] $diff = []
 
const MAP = []
 

Public Methods

mixed __call (string $method, array $args)
 Magic method handler. More...
 
 __construct (Api|self $caller, array $data=[])
 
array __serialize ()
 
void __unserialize (array $data)
 
bool isDiff ()
 Whether the instance has changes. More...
 
array jsonSerialize ()
 
bool offsetExists (mixed $offset)
 
mixed offsetGet (mixed $offset)
 
void offsetSet (mixed $offset, mixed $value)
 
void offsetUnset (mixed $offset)
 
array toArray (bool $diff=false)
 Dehydrated data. More...
 

Protected Methods

mixed _get (string $field)
 Magic method: getField() More...
 
bool _has (string $field)
 Magic method: hasField() More...
 
_hydrate (string $class, $item)
 Sub-data factory that draws from the entity pool. More...
 
bool _is (string $field)
 Magic method: isField() More...
 
bool _of (string $resourceSubtype)
 Magic method: ofResourceSubtypeValue() More...
 
array _select (string|iterable $subject, callable $filter,... $args)
 Magic method: selectField(callable $filter) More...
 
$this _set (string $field, $value)
 Magic method: setField(mixed $value) More...
 
void _setData (array $data)
 Clears all diffs and sets all data, hydrating mapped fields. More...
 
void _setField (string $field, $value)
 Sets a value, hydrating if mapped, and clears the diff. More...
 

Constructor

◆ __construct()

__construct ( Api|self  $caller,
array  $data = [] 
)
Parameters
Api | self$caller
array$data

Methods

◆ __call()

mixed __call ( string  $method,
array  $args 
)
final

Magic method handler.

See also
_get()
_has()
_is()
_select()
_set()
Parameters
string$method
array$args
Returns
mixed

◆ __serialize()

array __serialize ( )
final
See also
jsonSerialize()
Returns
array

◆ __unserialize()

void __unserialize ( array  $data)
final
Parameters
array$data
Returns
void

◆ _get()

mixed _get ( string  $field)
protected

Magic method: getField()

See also
__call()
Parameters
string$field
Returns
mixed

Reimplemented in AbstractEntity.

◆ _has()

bool _has ( string  $field)
finalprotected

Magic method: hasField()

Whether a countable field has anything in it, or casts a scalar field to boolean.

See also
__call()
Parameters
string$field
Returns
bool

◆ _hydrate()

T _hydrate ( string  $class,
  $item 
)
finalprotected

Sub-data factory that draws from the entity pool.

@template T of self

Parameters
class-string<T>$class
null | string | array | self$item
Returns
T

◆ _is()

bool _is ( string  $field)
finalprotected

Magic method: isField()

Boolean casts a scalar field.

Do not use this for countable fields, use hasField() instead.

See also
__call()
Parameters
string$field
Returns
bool

◆ _of()

bool _of ( string  $resourceSubtype)
finalprotected

Magic method: ofResourceSubtypeValue()

Parameters
string$resourceSubtype
Returns
bool

◆ _select()

array _select ( string|iterable  $subject,
callable  $filter,
  $args 
)
finalprotected

Magic method: selectField(callable $filter)

This can also be used to select from an arbitrary iterable.

See also
__call()
Parameters
string | iterable$subjectIterable, or field name of iterable accessed via get<subject>()
callable$filterfn( Data|AbstractEntity $object ): bool
array$argsArguments for the getter, if $subject is a field name.
Returns
array

◆ _set()

$this _set ( string  $field,
  $value 
)
protected

Magic method: setField(mixed $value)

See also
__call()
Parameters
string$field
mixed$value
Returns
$this

Reimplemented in FieldEntry, and ExternalData.

◆ _setData()

void _setData ( array  $data)
protected

Clears all diffs and sets all data, hydrating mapped fields.

Parameters
array$data
Returns
void

Reimplemented in Task, Story, Project, FieldEntry, Event, Status, AbstractEntity, Section, Change, FieldSetting, and Like.

◆ _setField()

void _setField ( string  $field,
  $value 
)
protected

Sets a value, hydrating if mapped, and clears the diff.

Parameters
string$field
mixed$value
Returns
void

Reimplemented in FieldEntries.

◆ isDiff()

bool isDiff ( )
final

Whether the instance has changes.

Returns
bool

◆ jsonSerialize()

array jsonSerialize ( )
final
Returns
array

◆ offsetExists()

bool offsetExists ( mixed  $offset)
Parameters
mixed$offset
Returns
bool

◆ offsetGet()

mixed offsetGet ( mixed  $offset)
Parameters
mixed$offset
Returns
mixed

◆ offsetSet()

void offsetSet ( mixed  $offset,
mixed  $value 
)
Parameters
mixed$offset
mixed$value
Returns
void

◆ offsetUnset()

void offsetUnset ( mixed  $offset)
Parameters
mixed$offset
Returns
void

◆ toArray()

array toArray ( bool  $diff = false)

Dehydrated data.

Parameters
bool$diff
Returns
array

Reimplemented in FieldEntries.