Factory::makeFactory()   B
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 20
rs 8.8571
cc 6
eloc 15
nc 6
nop 1
1
<?php
2
3
namespace Jalle19\HaPHProxy\Section;
4
5
/**
6
 * Class Factory
7
 * @package Jalle19\HaPHProxy\Section
8
 * @author  Sam Stenvall <[email protected]>
9
 * @license GNU General Public License 2.0+
10
 */
11
class Factory
12
{
13
14
	/**
15
	 * @param string $line
16
	 *
17
	 * @return AbstractSection|null
18
	 */
19
	public static function makeFactory($line)
20
	{
21
		$words     = explode(' ', $line);
22
		$firstWord = $words[0];
23
24
		switch ($firstWord) {
25
			case Sections::SECTION_GLOBAL:
26
				return new GlobalSection();
27
			case Sections::SECTION_DEFAULTS:
28
				return new DefaultsSection();
29
			case Sections::SECTION_FRONTEND:
30
				return new FrontendSection($line);
31
			case Sections::SECTION_BACKEND:
32
				return new BackendSection($line);
33
			case Sections::SECTION_LISTEN:
34
				return new ListenSection($line);
35
		}
36
37
		return null;
38
	}
39
40
}
41