| Conditions | 6 | 
| Paths | 5 | 
| Total Lines | 26 | 
| Code Lines | 17 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 13 | 
| CRAP Score | 6.7717 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 36 | 1 | 	public function create( $username, $password, $email = null ) { | |
| 37 | 1 | 		if ( !is_string( $username ) ) { | |
| 38 | throw new InvalidArgumentException( '$username should be a string' ); | ||
| 39 | } | ||
| 40 | 1 | 		if ( !is_string( $password ) ) { | |
| 41 | throw new InvalidArgumentException( '$password should be a string' ); | ||
| 42 | } | ||
| 43 | 1 | 		if ( !is_string( $email ) && !is_null( $email ) ) { | |
| 44 | throw new InvalidArgumentException( '$email should be a string or null' ); | ||
| 45 | } | ||
| 46 | |||
| 47 | $params = [ | ||
| 48 | 1 | 'createreturnurl' => $this->api->getApiUrl(), | |
| 49 | 1 | 'createtoken' => $this->api->getToken( 'createaccount' ), | |
| 50 | 1 | 'username' => $username, | |
| 51 | 1 | 'password' => $password, | |
| 52 | 1 | 'retype' => $password, | |
| 53 | 1 | ]; | |
| 54 | |||
| 55 | 1 | 		if ( !is_null( $email ) ) { | |
| 56 | $params['email'] = $email; | ||
| 57 | } | ||
| 58 | |||
| 59 | 1 | $result = $this->api->postRequest( new SimpleRequest( 'createaccount', $params ) ); | |
| 60 | 1 | return $result['createaccount']['status'] === 'PASS'; | |
| 61 | } | ||
| 62 | |||
| 64 |