Skip to content

Commit

Permalink
docs: add summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Jun 8, 2024
1 parent 3845577 commit 6174709
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 34 deletions.
18 changes: 11 additions & 7 deletions src/Macros/ResponseTransformer/Accepted.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
class Accepted {
public function __invoke(): callable
{
return function (): JsonResponse {
/** @var ResponseTransformer $this */
if (is_null($this->getTransformer())) {
$this->transformWith(Transformer::empty());
}
return $this->respond(202);
};
return
/**
* Returns a 202 Accepted response.
*/
function (): JsonResponse {
/** @var ResponseTransformer $this */
if (is_null($this->getTransformer())) {
$this->transformWith(Transformer::empty());
}
return $this->respond(202);
};
}
}
10 changes: 7 additions & 3 deletions src/Macros/ResponseTransformer/CreateFrom.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
class CreateFrom {
public function __invoke(): callable
{
return function (mixed $data = null, callable|TransformerAbstract|null $transformer = null, SerializerAbstract|null $serializer = null): ResponseTransformer {
return ResponseTransformer::create($data, $transformer, $serializer);
};
return
/**
* Create a new Response instance.
*/
function (mixed $data = null, callable|TransformerAbstract|null $transformer = null, SerializerAbstract|null $serializer = null): ResponseTransformer {
return ResponseTransformer::create($data, $transformer, $serializer);
};
}
}
18 changes: 11 additions & 7 deletions src/Macros/ResponseTransformer/Created.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
class Created {
public function __invoke(): callable
{
return function (): JsonResponse {
/** @var ResponseTransformer $this */
if (is_null($this->getTransformer())) {
$this->transformWith(Transformer::empty());
}
return $this->respond(201);
};
return
/**
* Returns a 201 Created response.
*/
function (): JsonResponse {
/** @var ResponseTransformer $this */
if (is_null($this->getTransformer())) {
$this->transformWith(Transformer::empty());
}
return $this->respond(201);
};
}
}
12 changes: 9 additions & 3 deletions src/Macros/ResponseTransformer/GetRequestedIncludes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ class GetRequestedIncludes
{
public function __invoke(): callable
{
return function (): array {
return app(Manager::class)->parseIncludes(Request::get(Config::get('apiato.requests.params.include', 'include'), []))->getRequestedIncludes();
};
return
/**
* Parse the include parameter from the request and return an array of resources to include.
*
* Includes can be Array or csv string of resources to include.
*/
function (): array {
return app(Manager::class)->parseIncludes(Request::get(Config::get('apiato.requests.params.include', 'include'), []))->getRequestedIncludes();
};
}
}
18 changes: 11 additions & 7 deletions src/Macros/ResponseTransformer/NoContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
class NoContent {
public function __invoke(): callable
{
return function (): JsonResponse {
/** @var ResponseTransformer $this */
if (is_null($this->getTransformer())) {
$this->transformWith(Transformer::empty());
}
return $this->respond(204);
};
return
/**
* Returns a 204 No Content response.
*/
function (): JsonResponse {
/** @var ResponseTransformer $this */
if (is_null($this->getTransformer())) {
$this->transformWith(Transformer::empty());
}
return $this->respond(204);
};
}
}
18 changes: 11 additions & 7 deletions src/Macros/ResponseTransformer/Ok.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
class Ok {
public function __invoke(): callable
{
return function (): JsonResponse {
/** @var ResponseTransformer $this */
if (is_null($this->getTransformer())) {
$this->transformWith(Transformer::empty());
}
return $this->respond(200);
};
return
/**
* Returns a 200 OK response.
*/
function (): JsonResponse {
/** @var ResponseTransformer $this */
if (is_null($this->getTransformer())) {
$this->transformWith(Transformer::empty());
}
return $this->respond(200);
};
}
}

0 comments on commit 6174709

Please sign in to comment.