Completed
Push — master ( 8714ce...91124c )
by Thomas
10:30 queued 06:04
created

ActivityObjectCreateJsonResponder::notValid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
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\framework\exceptions\ValidationException;
9
use Tobscure\JsonApi\Document;
10
use Tobscure\JsonApi\Resource;
11
use keeko\core\model\ActivityObject;
12
13
/**
14
 * Automatically generated JsonResponder for Creates an activity-object
15
 * 
16
 * @author gossi
17
 */
18
class ActivityObjectCreateJsonResponder extends AbstractPayloadResponder {
19
20
	/**
21
	 * @param Request $request
22
	 * @param PayloadInterface $payload
23
	 */
24
	public function created(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...
25
		$serializer = ActivityObject::getSerializer();
26
		$resource = new Resource($payload->getModel(), $serializer);
0 ignored issues
show
Bug introduced by
The method getModel() 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
		$document = new Document($resource);
28
29
		return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]);
30
	}
31
32
	/**
33
	 * @param Request $request
34
	 * @param PayloadInterface $payload
35
	 */
36
	public function notValid(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...
37
		throw new ValidationException($payload->getViolations());
0 ignored issues
show
Bug introduced by
The method getViolations() 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...
38
	}
39
40
	/**
41
	 */
42
	protected function getPayloadMethods() {
43
		return [
44
			'keeko\framework\domain\payload\NotValid' => 'notValid',
45
			'keeko\framework\domain\payload\Created' => 'created'
46
		];
47
	}
48
}
49