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

ApplicationUriListJsonResponder::found()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 1
eloc 18
nc 1
nop 2
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 keeko\core\model\ApplicationUri;
9
use keeko\core\model\Application;
10
use keeko\core\model\Localization;
11
use Tobscure\JsonApi\Document;
12
use Tobscure\JsonApi\Collection;
13
use Tobscure\JsonApi\Parameters;
14
15
/**
16
 * Automatically generated JsonResponder for List all application-uris
17
 * 
18
 * @author gossi
19
 */
20
class ApplicationUriListJsonResponder extends AbstractPayloadResponder {
21
22
	/**
23
	 * @param Request $request
24
	 * @param PayloadInterface $payload
25
	 */
26
	public function found(Request $request, PayloadInterface $payload) {
27
		$params = new Parameters($request->query->all());
28
		$data = $payload->get('model');
29
		$serializer = ApplicationUri::getSerializer();
30
		$resource = new Collection($data, $serializer);
31
		$resource = $resource->with($params->getInclude(['application', 'localization']));
32
		$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('application-uri' ...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...
33
			'application-uri' => ApplicationUri::getSerializer()->getFields(),
34
			'application' => Application::getSerializer()->getFields(),
35
			'localization' => Localization::getSerializer()->getFields()
36
		]));
37
		$document = new Document($resource);
38
39
		// meta
40
		$document->setMeta([
41
			'total' => $data->getNbResults(),
42
			'first' => $data->getFirstPage(),
43
			'next' => $data->getNextPage(),
44
			'previous' => $data->getPreviousPage(),
45
			'last' => $data->getLastPage()
46
		]);
47
48
		// return response
49
		return new JsonResponse($document->toArray());
50
	}
51
52
	/**
53
	 */
54
	protected function getPayloadMethods() {
55
		return [
56
			'keeko\framework\domain\payload\Found' => 'found'
57
		];
58
	}
59
}
60