Completed
Push — master ( db89a0...661260 )
by
unknown
02:00
created

Builder::callFunc()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
Namespace EnergieProduction\Chart;
4
5
use Closure;
6
use Exception;
7
use EnergieProduction\Chart\Exceptions\CallbackNotValidException;
8
9
Class Builder {
10
11
	protected $class;
12
13
	public function __construct($class)
14
	{
15
		$this->class = $class;
16
	}
17
18
	public function make($callback)
19
	{
20
		$this->callFunc($callback, $this->class);
21
22
		return $this->class->render();
23
	}
24
25
	protected function callFunc($callback, $option)
26
	{
27
		if (! $callback instanceof Closure)
28
		{
29
			throw new CallbackNotValidException();
30
		}
31
32
		return call_user_func($callback, $option);
33
	}
34
}
35