public static function create($data) { $response = new Response(); try { $data = json_decode($data, true); /** @var Robots $robot */ $robot = new Robots(); $robot->setAttributes($data); $response->data = $robot->create(); $response->status = $response::STATUS_CREATED; } catch (Exception $e) { $response->setException($e); } finally { return $response->toArray(); } }