Completed
Push — master ( 84255c...a7d7e4 )
by Thomas
14:38
created

AbstractApplication::getTargetPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
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 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace keeko\core\package;
3
4
use keeko\core\kernel\KernelTargetInterface;
5
use keeko\core\kernel\Page;
6
use keeko\core\model\Application;
7
use keeko\core\model\Localization;
8
use keeko\core\service\ServiceContainer;
9
use keeko\core\utils\TwigRenderTrait;
10
use keeko\core\utils\TwigTrait;
11
use Symfony\Component\HttpFoundation\Request;
12
13
abstract class AbstractApplication implements KernelTargetInterface {
14
	
15
	use TwigTrait;
16
	use TwigRenderTrait;
17
18
	/**
19
	 * @var Application
20
	 */
21
	protected $model;
22
23
	/**
24
	 * @var Localization
25
	 */
26
	protected $localization;
27
28
	protected $rootUrl;
29
	
30
	protected $appPath;
31
32
	protected $destinationPath;
33
	
34
	protected $appUrl;
35
	
36
	/** @var ServiceContainer */
37
	protected $service;
38
	
39
	/** @var Page */
40
	protected $page;
41
42
	/**
43
	 * Creates a new Keeko Application
44
	 */
45
	public function __construct(Application $model, ServiceContainer $service) {
46
		$this->model = $model;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
47
		$this->service = $service;
48
		$this->page = new Page();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
49
	}
50
	
51
	/**
52
	 * Returns the applications name
53
	 *
54
	 * @return string
55
	 */
56
	public function getName() {
57
		return $this->model->getName();
58
	}
59
	
60
	/**
61
	 * Returns the applications canonical name
62
	 *
63
	 * @return string
64
	 */
65
	public function getCanonicalName() {
66
		return str_replace('/', '.', $this->model->getName());
67
	}
68
	
69
	/**
70
	 * Returns the applications title
71
	 *
72
	 * @return string
73
	 */
74
	public function getTitle() {
75
		return $this->model->getTitle();
76
	}
77
	
78
	/**
79
	 * Returns the service container
80
	 *
81
	 * @return ServiceContainer
82
	 */
83
	public function getServiceContainer() {
84
		return $this->service;
85
	}
86
	
87
	/**
88
	 * @return Page
89
	 */
90
	public function getPage() {
91
		return $this->page;
92
	}
93
	
94
	/**
95
	 * Returns the associated application model
96
	 *
97
	 * @return Application
98
	 */
99
	public function getModel() {
100
		return $this->model;
101
	}
102
103
	public function setAppPath($prefix) {
104
		$this->appPath = $prefix;
105
		$this->updateAppUrl();
106
	}
107
108
	public function getAppPath() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
109
		return $this->appPath;
110
	}
111
112
	public function setRootUrl($root) {
113
		$this->rootUrl = $root;
114
		$this->updateAppUrl();
115
	}
116
	
117
	public function getRootUrl() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
118
		return $this->rootUrl;
119
	}
120
	
121
	private function updateAppUrl() {
122
		$this->appUrl = $this->rootUrl . $this->appPath;
123
	}
124
	
125
	public function getAppUrl() {
126
		return $this->appUrl;
127
	}
128
	
129
	public function setDestinationPath($destination) {
130
		$this->destinationPath = $destination;
131
	}
132
133
	public function getDestinationPath() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
134
		return $this->destinationPath;
135
	}
136
	
137
	public function getTargetPath() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
138
		return $this->destinationPath;
139
	}
140
	
141
	public function getTailPath() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
142
		return $this->destinationPath;
143
	}
144
145
	public function setLocalization(Localization $localization) {
146
		$this->localization = $localization;
147
	}
148
149
	/**
150
	 *
151
	 * @return Localization
152
	 */
153
	public function getLocalization() {
154
		return $this->localization;
155
	}
156
	
157
	public function getTwig() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
158
		return $this->getRawTwig(sprintf('%s/%s/templates/', KEEKO_PATH_APPS, $this->model->getName()));
159
	}
160
	
161
	protected function runAction(AbstractAction $action, Request $request) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
162
		$runner = $this->getServiceContainer()->getRunner();
0 ignored issues
show
Bug introduced by
The method getRunner() does not seem to exist on object<keeko\core\service\ServiceContainer>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
163
		return $runner->run($action, $request);
164
	}
165
	
166
	abstract public function run(Request $request);
167
	
168
}