Completed
Push — master ( 061e94...8714ce )
by Thomas
06:16
created

ApiActionUpdateAction::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 9
nc 2
nop 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 Tobscure\JsonApi\Exception\InvalidParameterException;
10
use keeko\core\domain\ApiDomain;
11
12
/**
13
 */
14
class ApiActionUpdateAction extends AbstractAction {
15
16
	/**
17
	 * @param OptionsResolver $resolver
18
	 */
19
	public function configureParams(OptionsResolver $resolver) {
20
		$resolver->setRequired(['id']);
21
	}
22
23
	/**
24
	 * Automatically generated run method
25
	 * 
26
	 * @param Request $request
27
	 * @return Response
28
	 */
29
	public function run(Request $request) {
30
		$body = 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...
31
		if (!isset($body['data'])) {
32
			throw new InvalidParameterException();
33
		}
34
		$data = $body['data'];
35
		$id = $this->getParam('id');
36
		$domain = new ApiDomain($this->getServiceContainer());
37
		$payload = $domain->setAction($id, $data);
0 ignored issues
show
Bug introduced by
The method setAction() does not exist on keeko\core\domain\ApiDomain. Did you maybe mean setActionId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
38
		return $this->responder->run($request, $payload);
39
	}
40
}
41