| Conditions | 2 |
| Paths | 2 |
| Total Lines | 8 |
| Code Lines | 3 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function is_valid( $key ) { |
||
| 30 | |||
| 31 | // Request the dataset URI as a way to validate the key |
||
| 32 | $response = wp_remote_get( wl_configuration_get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) ); |
||
| 33 | |||
| 34 | // If the response is valid, the key is valid. |
||
| 35 | return ! is_wp_error( $response ) && 200 === (int) $response['response']['code']; |
||
| 36 | } |
||
| 37 | |||
| 59 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: