TRenderCondition::setRenderCondition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
ccs 2
cts 2
cp 1
cc 1
eloc 3
nc 1
nop 1
crap 1
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