| Conditions | 4 |
| Paths | 7 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function registerUser($data) { |
||
| 19 | if (!$data["name"] || !$data["email"]) { |
||
| 20 | return false; |
||
| 21 | } |
||
| 22 | |||
| 23 | $user = false; |
||
| 24 | |||
| 25 | try { |
||
| 26 | $username = Import::generateUniqueUsername($data); |
||
| 27 | $password = generate_random_cleartext_password(); |
||
| 28 | $guid = register_user($username, $password, $data["name"], $data["email"]); |
||
| 29 | elgg_set_user_validation_status($guid, true, "email"); |
||
|
|
|||
| 30 | $user = get_entity($guid); |
||
| 31 | } catch (Exception $e) { |
||
| 32 | elgg_log("Could not register user " . $e->getMessage(), "ERROR"); |
||
| 33 | } |
||
| 34 | |||
| 35 | return $user; |
||
| 36 | } |
||
| 37 | |||
| 76 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.