PHP Class Spatie\Fractal\Fractal

Inheritance: implements JsonSerializabl\JsonSerializable
Mostra file Open project: spatie/laravel-fractal Class Usage Examples

Protected Properties

Property Type Description
$cursor League\Fractal\Pagination\CursorInterface
$data mixed
$dataType string
$excludes array
$includes array
$manager League\Fractal\Manager
$meta array
$paginator League\Fractal\Pagination\PaginatorInterface
$resourceName string
$serializer League\Fractal\Serializer\SerializerAbstract
$transformer League\Fractal\TransformerAbstract | callable

Public Methods

Method Description
__call ( string $name, array $arguments ) Support for magic methods to included data.
__construct ( League\Fractal\Manager $manager )
addMeta ( ) Set the meta data.
collection ( mixed $data, League\Fractal\TransformerAbstract | callable | null $transformer = null, string | null $resourceName = null ) Set the collection data that must be transformed.
createData ( ) : League\Fractal\Scope Create fractal data.
data ( string $dataType, mixed $data, League\Fractal\TransformerAbstract | callable | null $transformer = null ) Set the data that must be transformed.
getResource ( ) : League\Fractal\Resource\ResourceInterface Get the resource.
item ( mixed $data, League\Fractal\TransformerAbstract | callable | null $transformer = null, string | null $resourceName = null ) Set the item data that must be transformed.
jsonSerialize ( ) Convert the object into something JSON serializable.
paginateWith ( League\Fractal\Pagination\PaginatorInterface $paginator ) Set a Fractal paginator for the data.
parseExcludes ( array | string $excludes ) Specify the excludes.
parseIncludes ( array | string $includes ) Specify the includes.
serializeWith ( League\Fractal\Serializer\SerializerAbstract $serializer ) Set the serializer to be used.
toArray ( ) : array Perform the transformation to array.
toJson ( ) : string Perform the transformation to json.
transformWith ( League\Fractal\TransformerAbstract | callable $transformer ) Set the class or function that will perform the transform.
withCursor ( League\Fractal\Pagination\CursorInterface $cursor ) Set a Fractal cursor for the data.
withResourceName ( string $resourceName ) Set the resource name, to replace 'data' as the root of the collection or item.

Protected Methods

Method Description
normalizeIncludesOrExcludes ( array | string $includesOrExcludes = '' ) : array | string Normalize the includes an excludes.

Method Details

__call() public method

Support for magic methods to included data.
public __call ( string $name, array $arguments )
$name string
$arguments array

__construct() public method

public __construct ( League\Fractal\Manager $manager )
$manager League\Fractal\Manager

addMeta() public method

Set the meta data.
public addMeta ( )

collection() public method

Set the collection data that must be transformed.
public collection ( mixed $data, League\Fractal\TransformerAbstract | callable | null $transformer = null, string | null $resourceName = null )
$data mixed
$transformer League\Fractal\TransformerAbstract | callable | null
$resourceName string | null

createData() public method

Create fractal data.
public createData ( ) : League\Fractal\Scope
return League\Fractal\Scope

data() public method

Set the data that must be transformed.
public data ( string $dataType, mixed $data, League\Fractal\TransformerAbstract | callable | null $transformer = null )
$dataType string
$data mixed
$transformer League\Fractal\TransformerAbstract | callable | null

getResource() public method

Get the resource.
public getResource ( ) : League\Fractal\Resource\ResourceInterface
return League\Fractal\Resource\ResourceInterface

item() public method

Set the item data that must be transformed.
public item ( mixed $data, League\Fractal\TransformerAbstract | callable | null $transformer = null, string | null $resourceName = null )
$data mixed
$transformer League\Fractal\TransformerAbstract | callable | null
$resourceName string | null

jsonSerialize() public method

Convert the object into something JSON serializable.
public jsonSerialize ( )

normalizeIncludesOrExcludes() protected method

Normalize the includes an excludes.
protected normalizeIncludesOrExcludes ( array | string $includesOrExcludes = '' ) : array | string
$includesOrExcludes array | string
return array | string

paginateWith() public method

Set a Fractal paginator for the data.
public paginateWith ( League\Fractal\Pagination\PaginatorInterface $paginator )
$paginator League\Fractal\Pagination\PaginatorInterface

parseExcludes() public method

Specify the excludes.
public parseExcludes ( array | string $excludes )
$excludes array | string Array or string of resources to exclude.

parseIncludes() public method

Specify the includes.
public parseIncludes ( array | string $includes )
$includes array | string Array or string of resources to include.

serializeWith() public method

Set the serializer to be used.
public serializeWith ( League\Fractal\Serializer\SerializerAbstract $serializer )
$serializer League\Fractal\Serializer\SerializerAbstract

toArray() public method

Perform the transformation to array.
public toArray ( ) : array
return array

toJson() public method

Perform the transformation to json.
public toJson ( ) : string
return string

transformWith() public method

Set the class or function that will perform the transform.
public transformWith ( League\Fractal\TransformerAbstract | callable $transformer )
$transformer League\Fractal\TransformerAbstract | callable

withCursor() public method

Set a Fractal cursor for the data.
public withCursor ( League\Fractal\Pagination\CursorInterface $cursor )
$cursor League\Fractal\Pagination\CursorInterface

withResourceName() public method

Set the resource name, to replace 'data' as the root of the collection or item.
public withResourceName ( string $resourceName )
$resourceName string

Property Details

$cursor protected_oe property

protected CursorInterface,League\Fractal\Pagination $cursor
return League\Fractal\Pagination\CursorInterface

$data protected_oe property

protected mixed $data
return mixed

$dataType protected_oe property

protected string $dataType
return string

$excludes protected_oe property

protected array $excludes
return array

$includes protected_oe property

protected array $includes
return array

$manager protected_oe property

protected Manager,League\Fractal $manager
return League\Fractal\Manager

$meta protected_oe property

protected array $meta
return array

$paginator protected_oe property

protected PaginatorInterface,League\Fractal\Pagination $paginator
return League\Fractal\Pagination\PaginatorInterface

$resourceName protected_oe property

protected string $resourceName
return string

$serializer protected_oe property

protected SerializerAbstract,League\Fractal\Serializer $serializer
return League\Fractal\Serializer\SerializerAbstract

$transformer protected_oe property

protected TransformerAbstract,League\Fractal|callable $transformer
return League\Fractal\TransformerAbstract | callable