Completed
Push — milestone/2_0/container-condit... ( c41f81...3ee472 )
by
unknown
04:49
created

Current_User_Role_Condition::is_fulfilled()   B

Complexity

Conditions 6
Paths 10

Size

Total Lines 25
Code Lines 20

Duplication

Lines 14
Ratio 56 %

Importance

Changes 0
Metric Value
cc 6
eloc 20
nc 10
nop 1
dl 14
loc 25
rs 8.439
c 0
b 0
f 0
1
<?php
2
3
namespace Carbon_Fields\Container\Condition;
4
5
/**
6
 * Check if the currently logged in user has a specific role
7
 * 
8
 * Operator "CUSTOM" is passed an array of all user roles
9
 */
10
class Current_User_Role_Condition extends User_Role_Condition {
11
	
12
	/**
13
	 * Get roles for a user from the environment
14
	 * 
15
	 * @param  array         $environment
16
	 * @return array<string>
17
	 */
18
	protected function get_user_roles( $environment ) {
19
		$user = wp_get_current_user();
20
		$roles = $user ? $user->roles : array();
21
		return $roles;
22
	}
23
}