Completed
Push — master ( db80f0...72976a )
by Pavel
02:46
created

NetteDatabaseSelectionHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDriver() 0 6 1
A getContext() 0 9 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\Utils;
10
11
use Nette\Database\Table\Selection;
12
13
final class NetteDatabaseSelectionHelper
14
{
15
16
	public static function getDriver(Selection $selection)
17
	{
18
		$connection = self::getContext($selection)->getConnection();
19
20
		return $connection->getSupplementalDriver();
21
	}
22
23
24
	public static function getContext(Selection $selection)
25
	{
26
		$reflection = new \ReflectionClass($selection);
27
28
		$context_property = $reflection->getProperty('context');
29
		$context_property->setAccessible(TRUE);
30
31
		return $context_property->getValue($selection);
32
	}
33
34
}
35