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

AbstractResponse::setData()   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 1
1
<?php
2
namespace keeko\core\package;
3
4
use Symfony\Component\HttpFoundation\Request;
5
use keeko\core\utils\TwigRenderTrait;
6
7
abstract class AbstractResponse {
8
	
9
	use TwigRenderTrait;
10
11
	protected $data = [];
12
13
	protected $twig;
14
15
	protected $module;
16
17
	public function __construct(AbstractModule $module, $format) {
18
		$this->module = $module;
19
		$templatePath = sprintf('%s/%s/templates/%s', KEEKO_PATH_MODULES, $module->getModel()->getName(), $format);
20
		
21
		if (file_exists($templatePath)) {
22
			$loader = new \Twig_Loader_Filesystem($templatePath);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 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...
23
			$this->twig = new \Twig_Environment($loader);
24
		}
25
	}
26
27
	/**
28
	 * Returns the service container
29
	 *
30
	 * @return ServiceContainer
31
	 */
32
	protected function getServiceContainer() {
33
		return $this->module->getServiceContainer();
34
	}
35
36
	public function setData($data) {
37
		$this->data = $data;
38
	}
39
	
40
	protected 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...
41
		return $this->module->getTwig();
42
	}
43
44
	abstract public function run(Request $request, $data = null);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
45
}