for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace VGirol\JsonApiFaker\Laravel\Factory;
use Illuminate\Database\Eloquent\Model;
use VGirol\JsonApiFaker\Exception\JsonApiFakerException;
/**
* An abstract factory for resources (resource object or resource identifer).
*/
trait IsResource
{
use HasModel;
* Class constructor.
*
* @param Model|null $model
* @param string|null $resourceType
* @return void
* @throws JsonApiFakerException
public function __construct($model = null, ?string $resourceType = null)
if (($model !== null) && ($resourceType !== null)) {
$this->setValues($model, $resourceType);
}
* Set the model and the resource type.
* @param Model $model
* @param string $resourceType
* @return static
public function setValues($model, string $resourceType)
return $this->setModel($model)
->setId($model->getKey())
setId()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
->/** @scrutinizer ignore-call */ setId($model->getKey())
->setResourceType($resourceType);