Code Duplication    Length = 35-35 lines in 2 locations

src/Options.php 1 location

@@ 7-41 (lines=35) @@
4
5
use EnergieProduction\Chart\Exceptions\UnavailableOptionException;
6
7
Class Options
8
{
9
	protected $config = [];
10
11
	public function __construct(array $config)
12
	{
13
		$this->config = $config;
14
	}
15
16
	public function make($type, $callback)
17
	{
18
		$availableTypes = array_keys($this->config['available_types']);
19
20
		if (! in_array($type, $availableTypes)) {
21
			throw new UnavailableOptionException;
22
		}
23
24
		$optionClass = $this->makeClass($type);
25
26
		$builder = new Builder($optionClass);
27
28
		return $builder->make($callback);
29
	}
30
31
	protected function makeClass($type)
32
	{
33
		$className = ucfirst($type);
34
35
		$class = __NAMESPACE__ . "\\Highcharts\\Options\\$className";
36
37
		$config = $this->config['available_types'][$type];
38
39
		return new $class($config);
40
	}
41
}
42

src/Series.php 1 location

@@ 7-41 (lines=35) @@
4
5
use EnergieProduction\Chart\Exceptions\UnavailableSerieException;
6
7
Class Series
8
{
9
	protected $config = [];
10
11
	public function __construct(array $config)
12
	{
13
		$this->config = $config;
14
	}
15
16
	public function make($type, $callback)
17
	{
18
		$availableTypes = array_keys($this->config['available_types']);
19
20
		if (! in_array($type, $availableTypes)) {
21
			throw new UnavailableSerieException;
22
		}
23
24
		$optionClass = $this->makeClass($type);
25
26
		$builder = new Builder($optionClass);
27
28
		return ['type' => $type] + $builder->make($callback);
29
	}
30
31
	protected function makeClass($type)
32
	{
33
		$className = ucfirst($type);
34
35
		$class = __NAMESPACE__ . "\\Highcharts\\Series\\$className";
36
37
		$config = $this->config['available_types'][$type];
38
39
		return new $class($config);
40
	}
41
}
42