for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
*
* This file is part of the Aura project for PHP.
* @package Aura.Marshal
* @license https://opensource.org/licenses/mit-license.php MIT
*/
namespace Aura\Marshal\Entity;
* Creates a new entity object for a type.
class Builder implements BuilderInterface
{
* The class to use for new instances.
* @var class-string<GenericEntity>
class-string<GenericEntity>
0
protected $class = 'Aura\Marshal\Entity\GenericEntity';
* Creates a new entity object.
* @param array<int|string, mixed> $data Data to load into the entity.
* @return GenericEntity
public function newInstance(array $data)
$class = $this->class;
$entity = new $class;
// set fields
foreach ($data as $field => $value) {
$entity->$field = $value;
}
return $entity;