PHP 클래스 Mongolid\DataMapper\SchemaMapper

When instantiating a SchemaMapper you should provide a Schema. When calling 'map' the Schema provided will be used to format the data to the correct format. This class is meant to do the opposite of the EntityAssembler
파일 보기 프로젝트 열기: leroy-merlin-br/mongolid 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$schema Mongolid\Schema\Schema The actual schema to maps the data.

보호된 프로퍼티들

프로퍼티 타입 설명
$castableTypes string[] Types that can be casted.

공개 메소드들

메소드 설명
__construct ( Schema $schema )
map ( array | object $data ) : array Maps the input $data to the schema specified in the $schema property.
parseField ( mixed $value, string $fieldType ) : mixed Parse a value based on a field yype of the schema.

보호된 메소드들

메소드 설명
cast ( mixed $value, string $type ) : mixed Uses PHP's settype to cast a value to a type.
clearDynamic ( array &$data ) : void If the schema is not dynamic, remove all non specified fields.
mapToSchema ( mixed $value, string $schemaClass ) : mixed Instantiate another SchemaMapper with the given $schemaClass and maps the given $value.
parseToArray ( mixed $object ) : array Parses an object to an array before sending it to the SchemaMapper.

메소드 상세

__construct() 공개 메소드

public __construct ( Schema $schema )
$schema Mongolid\Schema\Schema Schema that will be used to map each field.

cast() 보호된 메소드

Uses PHP's settype to cast a value to a type.
또한 보기: http://php.net/manual/pt_BR/function.settype.php
protected cast ( mixed $value, string $type ) : mixed
$value mixed Value to be casted.
$type string Type to which the $value should be casted to.
리턴 mixed

clearDynamic() 보호된 메소드

If the schema is not dynamic, remove all non specified fields.
protected clearDynamic ( array &$data ) : void
$data array Reference of the fields. The passed array will be modified.
리턴 void

map() 공개 메소드

Maps the input $data to the schema specified in the $schema property.
public map ( array | object $data ) : array
$data array | object Array or object with the fields that should be mapped to $this->schema specifications.
리턴 array

mapToSchema() 보호된 메소드

Instantiate another SchemaMapper with the given $schemaClass and maps the given $value.
protected mapToSchema ( mixed $value, string $schemaClass ) : mixed
$value mixed Value that will be mapped.
$schemaClass string Class that will be passed to the new SchemaMapper constructor.
리턴 mixed

parseField() 공개 메소드

Parse a value based on a field yype of the schema.
public parseField ( mixed $value, string $fieldType ) : mixed
$value mixed Value to be parsed.
$fieldType string Description of how the field should be treated.
리턴 mixed $value Value parsed to match $type

parseToArray() 보호된 메소드

Parses an object to an array before sending it to the SchemaMapper.
protected parseToArray ( mixed $object ) : array
$object mixed The object that will be transformed into an array.
리턴 array

프로퍼티 상세

$castableTypes 보호되어 있는 프로퍼티

Types that can be casted.
또한 보기: http://php.net/manual/en/language.types.type-juggling.php
protected string[] $castableTypes
리턴 string[]

$schema 공개적으로 프로퍼티

The actual schema to maps the data.
public Schema,Mongolid\Schema $schema
리턴 Mongolid\Schema\Schema