Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Commit

Permalink
Reformat files (removed double line between methods etc.)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Stenvall committed Nov 27, 2017
1 parent 91528aa commit 5441ccb
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 45 deletions.
12 changes: 3 additions & 9 deletions src/Contracts/FractalBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

interface FractalBuilder
{

/**
* Sets the meta data to add to the serialized data.
*
Expand All @@ -32,7 +32,6 @@ public function setMeta(array $meta);
*/
public function setTransformer($transformer);


/**
* Sets the resource key to use for serializing data.
*
Expand All @@ -44,13 +43,12 @@ public function setTransformer($transformer);
*/
public function setResourceKey(string $resourceKey);


/**
* Sets the paginator to use for serializing data.
* Only applicable for collections.
*
* @param PaginatorInterface $paginator
*
*
* @throws \InvalidArgumentException
*
* @return $this
Expand All @@ -59,13 +57,12 @@ public function setResourceKey(string $resourceKey);
*/
public function setPaginator(PaginatorInterface $paginator);


/**
* Sets the cursor to use for serializing data.
* Only applicable for collections.
*
* @param CursorInterface $cursor
*
*
* @throws \InvalidArgumentException
*
* @return $this
Expand All @@ -74,7 +71,6 @@ public function setPaginator(PaginatorInterface $paginator);
*/
public function setCursor(CursorInterface $cursor);


/**
* Sets the serializer to use for serializing data.
*
Expand All @@ -86,15 +82,13 @@ public function setCursor(CursorInterface $cursor);
*/
public function setSerializer(SerializerAbstract $serializer);


/**
* Returns the data as an array, serializing it first if necessary.
*
* @return array
*/
public function toArray(): array;


/**
* Returns the data as a JSON string, serializing it first if necessary.
*
Expand Down
7 changes: 2 additions & 5 deletions src/Contracts/FractalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ interface FractalService
*/
public function item($data, $transformer = null, ?string $resourceKey = null);


/**
* Serializes a collection of items.
*
Expand All @@ -31,25 +30,23 @@ public function item($data, $transformer = null, ?string $resourceKey = null);
*/
public function collection($data, $transformer = null, ?string $resourceKey = null);


/**
* Parses includes from either a string (GET query parameter) or an array
* and stores them so that they are available at the time of serialization.
*
* @param string|array $includes
*
*
* @return $this
*
* @see http://fractal.thephpleague.com/transformers#including-data
*/
public function parseIncludes($includes);


/**
* Sets the default serializer to use for serializing data.
*
* @param SerializerAbstract $serializer
*
*
* @return $this
*
* @see http://fractal.thephpleague.com/serializers/
Expand Down
19 changes: 4 additions & 15 deletions src/FractalBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class FractalBuilder implements FractalBuilderContract
Item::class,
];


/**
* FractalBuilder constructor.
*
Expand All @@ -80,12 +79,11 @@ class FractalBuilder implements FractalBuilderContract
public function __construct(Manager $fractal, string $resourceClass, $data)
{
$this->fractal = $fractal;
$this->data = $data;
$this->data = $data;

$this->setResourceClass($resourceClass);
}


/**
* @inheritdoc
*/
Expand All @@ -96,7 +94,6 @@ public function setMeta(array $meta)
return $this;
}


/**
* @inheritdoc
*/
Expand All @@ -107,7 +104,6 @@ public function setTransformer($transformer)
return $this;
}


/**
* @inheritdoc
*/
Expand All @@ -118,7 +114,6 @@ public function setResourceKey(string $resourceKey)
return $this;
}


/**
* @inheritdoc
*/
Expand All @@ -133,7 +128,6 @@ public function setPaginator(PaginatorInterface $paginator)
return $this;
}


/**
* @inheritdoc
*/
Expand All @@ -148,7 +142,6 @@ public function setCursor(CursorInterface $cursor)
return $this;
}


/**
* @inheritdoc
*/
Expand All @@ -159,7 +152,6 @@ public function setSerializer(SerializerAbstract $serializer)
return $this;
}


/**
* @inheritdoc
*/
Expand All @@ -168,7 +160,6 @@ public function toArray(): array
return $this->makeScope()->toArray();
}


/**
* @inheritdoc
*/
Expand All @@ -177,7 +168,6 @@ public function toJson(): string
return $this->makeScope()->toJson();
}


/**
* Creates the resource for this builder.
*
Expand All @@ -199,7 +189,6 @@ protected function makeResource(): ResourceAbstract
return $resource;
}


/**
* Creates the scope for this builder.
*
Expand All @@ -215,12 +204,12 @@ protected function makeScope(): Scope

return $this->fractal->createData($resource);
}

/**
* @param string $resourceClass
*
* @return $this
*
*
* @throws \InvalidArgumentException
*/
private function setResourceClass(string $resourceClass)
Expand All @@ -230,7 +219,7 @@ private function setResourceClass(string $resourceClass)
}

$this->resourceClass = $resourceClass;

return $this;
}
}
2 changes: 0 additions & 2 deletions src/FractalMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class FractalMiddleware
*/
private $service;


/**
* FractalMiddleware constructor.
*
Expand All @@ -24,7 +23,6 @@ public function __construct(FractalService $service)
$this->service = $service;
}


/**
* Run the request filter.
*
Expand Down
24 changes: 11 additions & 13 deletions src/FractalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class FractalService implements FractalServiceContract
*/
private $defaultSerializer;


/**
* @inheritdoc
*/
Expand All @@ -31,7 +30,6 @@ public function item($data, $transformer = null, ?string $resourceKey = null)
return $this->makeBuilder(Item::class, $data, $transformer, $resourceKey);
}


/**
* @inheritdoc
*/
Expand All @@ -40,7 +38,6 @@ public function collection($data, $transformer = null, ?string $resourceKey = nu
return $this->makeBuilder(Collection::class, $data, $transformer, $resourceKey);
}


/**
* @inheritdoc
*/
Expand All @@ -51,34 +48,36 @@ public function parseIncludes($includes)
}

$this->includes = array_merge($this->includes, $includes);

return $this;
}


/**
* @inheritdoc
*/
public function setDefaultSerializer(SerializerAbstract $serializer)
{
$this->defaultSerializer = $serializer;

return $this;
}


/**
* Creates a builder for serializing data.
*
* @param string $resourceClass
* @param mixed $data
* @param string $resourceClass
* @param mixed $data
* @param TransformerAbstract|callable|null $transformer
* @param string|null $resourceKey
* @param string|null $resourceKey
*
* @return FractalBuilder
*/
protected function makeBuilder(string $resourceClass, $data, $transformer = null, string $resourceKey = null): FractalBuilder
{
protected function makeBuilder(
string $resourceClass,
$data,
$transformer = null,
string $resourceKey = null
): FractalBuilder {
$fractal = $this->makeFractal();
$builder = new FractalBuilder($fractal, $resourceClass, $data);

Expand All @@ -93,7 +92,6 @@ protected function makeBuilder(string $resourceClass, $data, $transformer = null
return $builder;
}


/**
* @return Manager
*/
Expand Down
1 change: 0 additions & 1 deletion src/FractalServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class FractalServiceProvider extends ServiceProvider
{

private const CONFIG_KEY = 'fractal';

/**
Expand Down

0 comments on commit 5441ccb

Please sign in to comment.