RolesColumn::render_cell()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 26
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 8.439
cc 5
eloc 11
nc 5
nop 1
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