TRenderCondition   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 33
rs 10
ccs 5
cts 5
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setRenderCondition() 0 6 1
A shouldBeRendered() 0 6 2
1
<?php
2
3
/**
4
 * @copyright   Copyright (c) 2015 ublaboo <[email protected]>
5
 * @author      Pavel Janda <[email protected]>
6
 * @package     Ublaboo
7
 */
8
9
namespace Ublaboo\DataGrid\Traits;
10
11
use Ublaboo\DataGrid\Row;
12
13 1
trait TRenderCondition
14
{
15
16
	/**
17
	 * @var callable|null
18
	 */
19
	protected $render_condition_callback;
20
21
22
	/**
23
	 * @param callable $condition
24
	 * @return static
25
	 */
26
	public function setRenderCondition(callable $condition)
27
	{
28 1
		$this->render_condition_callback = $condition;
29
30 1
		return $this;
31
	}
32
33
34
	/**
35
	 * @param Row $row
36
	 * @return bool
37
	 */
38
	public function shouldBeRendered(Row $row)
39
	{
40 1
		$condition = $this->render_condition_callback;
41
42 1
		return $condition ? $condition($row->getItem()) : true;
43
	}
44
45
}
46