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

Current_User_Role_Condition::get_user_roles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 5
rs 9.4285
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
}