Completed
Push — master ( 5895ce...415b34 )
by Thomas
08:36
created

ContinentReadJsonResponder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 11

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 11
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A found() 0 12 1
A notFound() 0 3 1
A getPayloadMethods() 0 6 1
1
<?php
2
namespace keeko\core\responder;
3
4
use Symfony\Component\HttpFoundation\Request;
5
use Symfony\Component\HttpFoundation\JsonResponse;
6
use keeko\framework\domain\payload\PayloadInterface;
7
use keeko\framework\foundation\AbstractPayloadResponder;
8
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
9
use keeko\core\model\Continent;
10
use Tobscure\JsonApi\Document;
11
use Tobscure\JsonApi\Resource;
12
use Tobscure\JsonApi\Parameters;
13
14
/**
15
 * Automatically generated JsonResponder for Reads a continent
16
 * 
17
 * @author gossi
18
 */
19
class ContinentReadJsonResponder extends AbstractPayloadResponder {
20
21
	/**
22
	 * @param Request $request
23
	 * @param PayloadInterface $payload
24
	 */
25
	public function found(Request $request, PayloadInterface $payload) {
26
		$params = new Parameters($request->query->all());
27
		$serializer = Continent::getSerializer();
28
		$resource = new Resource($payload->get('model'), $serializer);
29
		$resource = $resource->with($params->getInclude([]));
30
		$resource = $resource->fields($params->getFields([
1 ignored issue
show
Unused Code introduced by
The call to Parameters::getFields() has too many arguments starting with array('continent' => \ke...ializer()->getFields()).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
31
			'continent' => Continent::getSerializer()->getFields()
32
		]));
33
		$document = new Document($resource);
34
35
		return new JsonResponse($document->toArray(), 200);
36
	}
37
38
	/**
39
	 * @param Request $request
40
	 * @param PayloadInterface $payload
41
	 */
42
	public function notFound(Request $request, PayloadInterface $payload) {
1 ignored issue
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
		throw new ResourceNotFoundException($payload->get('message'));
44
	}
45
46
	/**
47
	 */
48
	protected function getPayloadMethods() {
49
		return [
50
			'keeko\framework\domain\payload\Found' => 'found',
51
			'keeko\framework\domain\payload\NotFound' => 'notFound'
52
		];
53
	}
54
}
55