Skip to content

Commit

Permalink
move affecting type hints (#47)
Browse files Browse the repository at this point in the history
Moving the type hint at the end of the function.
  • Loading branch information
rdeutz authored Jul 16, 2024
1 parent f695c57 commit 86d47ce
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ public static function makeFromJson(JsonResponse $json)
*/
public function morph($format = 'json')
{
$this->content = $this->getOriginalContent() ?? '';
$content = $this->getOriginalContent() ?? '';

$this->fireMorphingEvent();

if (isset(static::$transformer) && static::$transformer->transformableResponse($this->content)) {
$this->content = static::$transformer->transform($this->content);
if (isset(static::$transformer) && static::$transformer->transformableResponse($content)) {
$content = static::$transformer->transform($content);
}

$formatter = static::getFormatter($format);
Expand All @@ -147,20 +147,22 @@ public function morph($format = 'json')

$this->fireMorphedEvent();

if ($this->content instanceof EloquentModel) {
$this->content = $formatter->formatEloquentModel($this->content);
} elseif ($this->content instanceof EloquentCollection) {
$this->content = $formatter->formatEloquentCollection($this->content);
} elseif (is_array($this->content) || $this->content instanceof ArrayObject || $this->content instanceof Arrayable) {
$this->content = $formatter->formatArray($this->content);
} elseif ($this->content instanceof stdClass) {
$this->content = $formatter->formatArray((array) $this->content);
if ($content instanceof EloquentModel) {
$content = $formatter->formatEloquentModel($content);
} elseif ($content instanceof EloquentCollection) {
$content = $formatter->formatEloquentCollection($content);
} elseif (is_array($content) || $content instanceof ArrayObject || $content instanceof Arrayable) {
$content = $formatter->formatArray($content);
} elseif ($content instanceof stdClass) {
$content = $formatter->formatArray((array) $content);
} else {
if (! empty($defaultContentType)) {
$this->headers->set('Content-Type', $defaultContentType);
}
}

$this->content = $content;

return $this;
}

Expand Down

0 comments on commit 86d47ce

Please sign in to comment.