for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PHPHub\Transformers;
/**
* Class TopicTransformer.
*/
class TopicTransformer extends BaseTransformer
{
* Resources that can be included if requested.
*
* @var array
protected $availableIncludes = ['user', 'last_reply_user', 'replies', 'node'];
* Include resources without needing it to be requested.
protected $defaultIncludes = [];
* Transform the \Topic entity.
* @param Topic $model
* @return array
public function transformData($model)
$data = $model->toArray();
$data['links'] = [
'details_web_view' => route('topic.web_view', $model->id),
'replies_web_view' => route('replies.web_view', $model->id),
'web_url' => trim(config('app.url'), '/').'/topics/'.$model->id,
];
return $data;
}
public function includeUser($model)
return $this->item($model->user, new UserTransformer());
new \PHPHub\Transformers\UserTransformer()
object<PHPHub\Transformers\UserTransformer>
callable
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
public function includeLastReplyUser($model)
return $this->item($model->lastReplyUser ?: $model->user, new UserTransformer());
public function includeReplies($model)
return $this->collection($model->replies, new ReplyTransformer());
new \PHPHub\Transformers\ReplyTransformer()
object<PHPHub\Transformers\ReplyTransformer>
public function includeNode($model)
return $this->item($model->node, new NodeTransformer());
new \PHPHub\Transformers\NodeTransformer()
object<PHPHub\Transformers\NodeTransformer>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: