Completed
Push — brickrouge3 ( 23d6f2...241af5 )
by Olivier
08:26
created

RolesColumn::render_cell()   B

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\User;
16
17
/**
18
 * Representation of the `roles` column.
19
 */
20
class RolesColumn extends Column
21
{
22
	/**
23
	 * @param User $record
24
	 *
25
	 * @inheritdoc
26
	 */
27
	public function render_cell($record)
28
	{
29
		if ($record->uid == 1)
30
		{
31
			return '<em>Admin</em>';
32
		}
33
34
		if (!$record->roles)
35
		{
36
			return null;
37
		}
38
39
		$label = '';
40
41
		foreach ($record->roles as $role)
42
		{
43
			if ($role->rid == 2)
44
			{
45
				continue;
46
			}
47
48
			$label .= ', ' . $role->name;
49
		}
50
51
		return substr($label, 2);
52
	}
53
}
54