| Conditions | 3 |
| Paths | 13 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function createUser(stdClass $data): int |
||
| 14 | { |
||
| 15 | /** @var Postgresql */ |
||
| 16 | $db = $this->getDI()->get('db'); |
||
| 17 | $db->begin(); |
||
| 18 | |||
| 19 | try { |
||
| 20 | $user = UserFactory::create($data); |
||
| 21 | $repository = new UserRepository(); |
||
| 22 | |||
| 23 | $id = $repository->insertUserIntoDb($user); |
||
| 24 | $db->commit(); |
||
| 25 | |||
| 26 | $user->setId($id); |
||
| 27 | |||
| 28 | return $user->getId(); |
||
| 29 | } catch (UserException $e) { |
||
| 30 | if ($db->isUnderTransaction()) { |
||
| 31 | $db->rollback(); |
||
| 32 | } |
||
| 33 | |||
| 34 | throw $e; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 54 |