CreateReservation::parseResponseData()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace HelePartnerSyncApi\Method;
4
5
use DateTime;
6
use HelePartnerSyncApi\Validator;
7
use HelePartnerSyncApi\ValidatorException;
8
9 View Code Duplication
class CreateReservation extends Method
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
12
	/**
13
	 * @return string
14
	 */
15
	public function getName()
16
	{
17
		return 'createReservation';
18
	}
19
20
	/**
21
	 * @param array $data
22
	 * @return array
23
	 */
24
	protected function parseRequestData($data)
25
	{
26
		try {
27
			Validator::checkStructure($data, array(
28
				'startDateTime' => Validator::TYPE_DATE_TIME_STRING,
29
				'endDateTime' => Validator::TYPE_DATE_TIME_STRING,
30
				'quantity' => Validator::TYPE_INT,
31
				'parameters' => Validator::TYPE_ARRAY,
32
			));
33
		} catch (ValidatorException $e) {
34
			throw new MethodException('Bad method input: ' . $e->getMessage(), $e);
35
		}
36
37
		return array(
38
			DateTime::createFromFormat(DateTime::W3C, $data['startDateTime']),
39
			DateTime::createFromFormat(DateTime::W3C, $data['endDateTime']),
40
			$data['quantity'],
41
			$data['parameters'],
42
		);
43
	}
44
45
	/**
46
	 * @param mixed $data
47
	 * @return null
48
	 */
49
	protected function parseResponseData($data)
50
	{
51
		try {
52
			Validator::checkNull($data);
53
		} catch (ValidatorException $e) {
54
			throw new MethodException('Bad method output: ' . $e->getMessage(), $e);
55
		}
56
57
		return null;
58
	}
59
60
}
61