Completed
Branch BETA-4.9-messages-queue-fixed (941081)
by
unknown
17:38 queued 10s
created

Read::handle_request()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 13

Duplication

Lines 3
Ratio 16.67 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 3
loc 18
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 13
nc 2
nop 1
1
<?php
2
namespace EventEspresso\core\libraries\rest_api\controllers\config;
3
if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
	exit( 'No direct script access allowed' );
5
}
6
7
/**
8
 *
9
 * _Read
10
 *
11
 * For handling READ requests for config data
12
 *
13
 * @package			Event Espresso
14
 * @subpackage
15
 * @author				Mike Nelson
16
 *
17
 */
18
class Read {
19
20
	/**
21
	 * @param \WP_REST_Request $request
22
	 * @return \EE_Config|\WP_Error
23
	 */
24
	public static function handle_request( \WP_REST_Request $request) {
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
		$cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap();
26
		if( \EE_Capabilities::instance()->current_user_can( $cap, 'read_over_api' ) ){
27
			return \EE_Config::instance();
28 View Code Duplication
		}else{
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
			return new \WP_Error(
30
				'cannot_read_config',
31
				sprintf(
32
					__(
33
						'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data',
34
						'event_espresso'
35
					),
36
					$cap
37
				),
38
				array( 'status' => 403 )
39
			);
40
		}
41
	}
42
}
43
44
// End of file Read.php