Completed
Push — master ( 415b34...7ef068 )
by Thomas
13:10 queued 06:22
created

ApplicationUpdateAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 5
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureParams() 0 3 1
A run() 0 7 1
1
<?php
2
namespace keeko\core\action;
3
4
use keeko\framework\foundation\AbstractAction;
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\Response;
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
use phootwork\json\Json;
9
use keeko\core\domain\ApplicationDomain;
10
11
/**
12
 * Action Class for application-update
13
 * 
14
 * This code is automatically created. Modifications will probably be overwritten.
15
 */
16
class ApplicationUpdateAction extends AbstractAction {
17
18
	/**
19
	 * @param OptionsResolver $resolver
20
	 */
21
	public function configureParams(OptionsResolver $resolver) {
22
		$resolver->setRequired(['id']);
23
	}
24
25
	/**
26
	 * Automatically generated run method
27
	 * 
28
	 * @param Request $request
29
	 * @return Response
30
	 */
31
	public function run(Request $request) {
32
		$id = $this->getParam('id');
33
		$data = Json::decode($request->getContent());
1 ignored issue
show
Bug introduced by
It seems like $request->getContent() targeting Symfony\Component\HttpFo...n\Request::getContent() can also be of type resource; however, phootwork\json\Json::decode() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
34
		$domain = new ApplicationDomain($this->getServiceContainer());
35
		$payload = $domain->update($id, $data);
36
		return $this->response->run($request, $payload);
0 ignored issues
show
Bug introduced by
The property response does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37
	}
38
}
39