RolesColumn   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 34
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B render_cell() 0 26 5
1
<?php
2
3
/*
4
 * This file is part of the Icybee package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Icybee\Modules\Users\Block\ManageBlock;
13
14
use Icybee\Block\ManageBlock\Column;
15
use Icybee\Modules\Users\Roles\Binding\UserBindings;
16
use Icybee\Modules\Users\User;
17
18
/**
19
 * Representation of the `roles` column.
20
 */
21
class RolesColumn extends Column
22
{
23
	/**
24
	 * @param User|UserBindings $record
25
	 *
26
	 * @inheritdoc
27
	 */
28
	public function render_cell($record)
29
	{
30
		if ($record->uid == 1)
31
		{
32
			return '<em>Admin</em>';
33
		}
34
35
		if (!$record->roles)
36
		{
37
			return null;
38
		}
39
40
		$label = '';
41
42
		foreach ($record->roles as $role)
43
		{
44
			if ($role->rid == 2)
45
			{
46
				continue;
47
			}
48
49
			$label .= ', ' . $role->name;
50
		}
51
52
		return substr($label, 2);
53
	}
54
}
55