Passed
Push — master ( a6b5c0...1b00af )
by Jean-Christophe
05:56
created

BaseControllerCreator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 5
eloc 18
dl 0
loc 47
ccs 12
cts 16
cp 0.75
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addRoute() 0 7 2
A setTemplateName() 0 2 1
A __construct() 0 5 1
A getTemplateName() 0 2 1
1
<?php
2
3
namespace Ubiquity\scaffolding\creators;
4
5
use Ubiquity\utils\base\UString;
6
use Ubiquity\scaffolding\ScaffoldController;
7
use Ubiquity\controllers\Startup;
8
9
/**
10
 * Base class for class creation in scaffolding.
11
 * Ubiquity\scaffolding\creators$BaseControllerCreator
12
 * This class is part of Ubiquity
13
 *
14
 * @author jcheron <[email protected]>
15
 * @version 1.0.2
16
 *
17
 */
18
abstract class BaseControllerCreator {
19
	protected $controllerName;
20
	protected $routePath;
21
	protected $views;
22
	protected $controllerNS;
23
	protected $templateName;
24
25
	/**
26
	 *
27
	 * @var ScaffoldController
28
	 */
29
	protected $scaffoldController;
30
31 2
	public function __construct($controllerName, $routePath, $views) {
32 2
		$this->controllerName = $controllerName;
33 2
		$this->routePath = $routePath;
34 2
		$this->views = $views;
35 2
		$this->controllerNS = Startup::getNS ( "controllers" );
36 2
	}
37
38 3
	protected function addRoute(&$routePath) {
39 3
		if (! UString::startswith ( $routePath, "/" )) {
40 2
			$routePath = "/" . $routePath;
41
		}
42 3
		$routeName = $routePath;
43 3
		$routePath = "\n * @route(\"{$routePath}\",\"inherited\"=>true,\"automated\"=>true)";
44 3
		return $routeName;
45
	}
46
47
	abstract public function create(ScaffoldController $scaffoldController);
48
49
	abstract protected function addViews(&$uses, &$messages, &$classContent);
50
51
	/**
52
	 *
53
	 * @return mixed
54
	 */
55
	public function getTemplateName() {
56
		return $this->templateName;
57
	}
58
59
	/**
60
	 *
61
	 * @param mixed $templateName
62
	 */
63
	public function setTemplateName($templateName) {
64
		$this->templateName = $templateName;
65
	}
66
}
67
68