| Conditions | 4 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public function block( $user, array $extraParams = [] ) { |
||
| 26 | if ( !$user instanceof User && !is_string( $user ) ) { |
||
| 27 | throw new InvalidArgumentException( '$user must be either a string or User object' ); |
||
| 28 | } |
||
| 29 | |||
| 30 | if ( $user instanceof User ) { |
||
| 31 | $user = $user->getName(); |
||
| 32 | } |
||
| 33 | |||
| 34 | $params = [ |
||
| 35 | 'user' => $user, |
||
| 36 | 'token' => $this->api->getToken( 'block' ), |
||
| 37 | ]; |
||
| 38 | |||
| 39 | $params = array_merge( $extraParams, $params ); |
||
| 40 | |||
| 41 | $this->api->postRequest( new SimpleRequest( 'block', $params ) ); |
||
| 42 | return true; |
||
| 43 | } |
||
| 44 | |||
| 46 |