What is best practices to convert multiple array objects into class objects?
I have following use case,
class Queue {
private $id;
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
private $name;
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
return $this;
}
public static function getAll( ) {
// Guzzle HTTP Request returns JSON
$responseArray = json_decode ( $response->getBody() );
}
}
This is part of composer package. So now when using this Queue
we can request multiple Queues
from parent application. Now how do i convert this json response to Queue
Object.
Also is it a good decision to declare getAll()
method static?