for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Api\Transformers;
use App\Models\Port;
use League\Fractal;
class PortTransformer extends Fractal\TransformerAbstract
{
/**
* List of resources possible to include
*
* @var array
*/
protected $availableIncludes = ['device'];
* Turn this item object into a generic array
* @return array
public function transform(Port $port)
return [
'id' => (int) $port->port_id,
'alias' => $port->ifAlias,
'speed' => (int) $port->ifSpeed,
'out_unicast_pkts_delta' => (int) $port->ifOutUcastPkts_delta,
'in_unicast_pkts_delta' => (int) $port->ifInUcastPkts_delta,
'type' => $port->ifType,
'description' => $port->ifDescr,
];
}
* Include Device
* @return Fractal\Resource\Item
public function includeDevice(Port $port)
$device = $port->device;
return $this->item($device, new DeviceTransformer);
new \App\Api\Transformers\DeviceTransformer()
object<App\Api\Transformers\DeviceTransformer>
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);
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: