Skip to content

Commit

Permalink
Merge pull request #8 from morloderex/master
Browse files Browse the repository at this point in the history
Add None transformer
  • Loading branch information
morloderex authored Apr 18, 2018
2 parents 0f1d0f7 + 739d6b6 commit 1e2ed50
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Transformers/NoneTransformer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Napp\Core\Api\Transformers;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;

class NoneTransformer implements TransformerInterface
{
/**
* @param array|Arrayable $data
* @return array
*/
public function transformInput($data): array
{
if ($data instanceof Arrayable) {
return $data->toArray();
}

return Arr::wrap($data);
}

/**
* @param array|Arrayable $data
* @return array
*/
public function transformOutput($data): array
{
if ($data instanceof Arrayable) {
return $data->toArray();
}

return Arr::wrap($data);
}
}

0 comments on commit 1e2ed50

Please sign in to comment.