Completed
Push — master ( f579b8...c5e777 )
by Thomas
07:12 queued 02:33
created

ApplicationListJsonResponder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
c 3
b 0
f 0
lcom 0
cbo 9
dl 0
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A found() 0 23 1
A getPayloadMethods() 0 5 1
1
<?php
2
namespace keeko\core\responder;
3
4
use keeko\framework\domain\payload\PayloadInterface;
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\JsonResponse;
7
use keeko\framework\foundation\AbstractPayloadResponder;
8
use keeko\core\model\Application;
9
use Tobscure\JsonApi\Document;
10
use Tobscure\JsonApi\Collection;
11
use Tobscure\JsonApi\Parameters;
12
13
/**
14
 * Automatically generated JsonResponder for List all applications
15
 * 
16
 * @author gossi
17
 */
18
class ApplicationListJsonResponder extends AbstractPayloadResponder {
19
20
	/**
21
	 * @param Request $request
22
	 * @param PayloadInterface $payload
23
	 */
24
	public function found(Request $request, PayloadInterface $payload) {
25
		$params = new Parameters($request->query->all());
26
		$data = $payload->Model();
0 ignored issues
show
Bug introduced by
The method Model() does not seem to exist on object<keeko\framework\d...yload\PayloadInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
		$serializer = Application::getSerializer();
28
		$resource = new Collection($data, $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('application' => \...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
			'application' => Application::getSerializer()->getFields()
32
		]));
33
		$document = new Document($resource);
34
35
		// meta
36
		$document->setMeta([
37
			'total' => $data->getNbResults(),
38
			'first' => $data->getFirstPage(),
39
			'next' => $data->getNextPage(),
40
			'previous' => $data->getPreviousPage(),
41
			'last' => $data->getLastPage()
42
		]);
43
44
		// return response
45
		return new JsonResponse($document->toArray());
46
	}
47
48
	/**
49
	 */
50
	protected function getPayloadMethods() {
51
		return [
52
			'keeko\framework\domain\payload\Found' => 'found'
53
		];
54
	}
55
}
56