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

Builder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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