| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public static function constructFromEntity(User $user): self |
||
| 32 | { |
||
| 33 | if (!$user->isAdmin()) { |
||
| 34 | throw new AppRuntimeException( |
||
| 35 | 'User must be ' . self::TYPE . ', but it is: ' . json_encode($user->getRoles()) |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | return new static( |
||
| 40 | $user->getId()->toScalar(), |
||
| 41 | $user->getFullName(), |
||
| 42 | $user->getUsername(), |
||
| 43 | $user->getEmail(), |
||
| 44 | $user->getMobile(), |
||
| 45 | $user->getPassword(), |
||
| 46 | self::TYPE |
||
| 47 | ); |
||
| 48 | } |
||
| 49 | |||
| 55 |