*/ public $locations; /** * @param $message * @param array $locations */ public function __construct($message, $locations = []) { $this->message = $message; $this->locations = array_map(function($loc) { return $loc->toArray();}, $locations); } /** * @return array */ public function toArray() { return [ 'message' => $this->message, 'locations' => $this->locations ]; } }