for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Kerox\Messenger\Model;
use Kerox\Messenger\Helper\ValidatorTrait;
class Persona implements \JsonSerializable
{
use ValidatorTrait;
/**
* @var string|null
*/
protected $id;
protected $name;
protected $profile_picture_url;
* Persona constructor.
*
* @param array $data
public function __construct(array $data = [])
foreach ($data as $field => $value) {
if (property_exists($this, $field)) {
$this->{$field} = $value;
}
* @return Persona
public static function create(array $data = []): self
return new static($data);
* @param string $id
public function setId(string $id): self
$this->id = $id;
return $this;
* @param string $name
public function setName(string $name): self
$this->name = $name;
* @param string $url
public function setProfilePictureUrl(string $url): self
$this->isValidUrl($url);
$this->profile_picture_url = $url;
* @return string|null
public function getId(): ?string
return $this->id;
public function getName(): ?string
return $this->name;
public function getProfilePictureUrl(): ?string
return $this->profile_picture_url;
* @return array
public function toArray(): array
$array = [
'id' => $this->id,
'name' => $this->name,
'profile_picture_url' => $this->profile_picture_url,
];
return \array_filter($array);
public function jsonSerialize(): array
return $this->toArray();