Skip to content

Commit af3f2a8

Browse files
committed
refactor(app): Remove Entitiy dependency in BaseTransformer
1 parent b86320d commit af3f2a8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

system/API/BaseTransformer.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace CodeIgniter\API;
1515

16-
use CodeIgniter\Entity\Entity;
1716
use CodeIgniter\HTTP\IncomingRequest;
1817
use InvalidArgumentException;
1918

@@ -103,10 +102,10 @@ public function transform(mixed $resource = null): array
103102

104103
if ($resource === null) {
105104
$data = $this->toArray(null);
105+
} elseif (is_object($resource) && method_exists($resource, 'toArray')) {
106+
$data = $this->toArray($resource->toArray());
106107
} else {
107-
$data = $resource instanceof Entity
108-
? $this->toArray($resource->toArray())
109-
: $this->toArray((array) $resource);
108+
$data = $this->toArray((array) $resource);
110109
}
111110

112111
$data = $this->limitFields($data);

0 commit comments

Comments
 (0)