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

RolesColumn   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 1
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\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