getParams(); try { $db->beginTransaction(); $manager = new AdminUserManager(); $messages = $manager->initForCreateAdmin() ->fill($params) ->create(); if (count($messages) !== 0) { throw new AppCommonException(Arr::first($messages)); } $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } return self::RESULTCODE_SUCCESS; } private function getParams(): array { $email = $this->option("email"); if (!$email) { throw new Exception("引数不正:email"); } $name = $this->option("name"); if (!$name) { throw new Exception("引数不正:name"); } $password = $this->option("password"); if (!$password) { throw new Exception("引数不正:password"); } return [ User::COL_NAME_NAME => $name, User::COL_NAME_EMAIL => $email, User::COL_NAME_PASSWORD => $password, ]; } }