Code Duplication    Length = 52-52 lines in 2 locations

src/Method/CancelReservation.php 1 location

@@ 9-60 (lines=52) @@
6
use HelePartnerSyncApi\Validator;
7
use HelePartnerSyncApi\ValidatorException;
8
9
class CancelReservation extends Method
10
{
11
12
	/**
13
	 * @return string
14
	 */
15
	public function getName()
16
	{
17
		return 'cancelReservation';
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

src/Method/CreateReservation.php 1 location

@@ 9-60 (lines=52) @@
6
use HelePartnerSyncApi\Validator;
7
use HelePartnerSyncApi\ValidatorException;
8
9
class CreateReservation extends Method
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