Method   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 46
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A call() 0 7 1
getName() 0 1 ?
parseRequestData() 0 1 ?
parseResponseData() 0 1 ?
1
<?php
2
3
namespace HelePartnerSyncApi\Method;
4
5
use Closure;
6
use HelePartnerSyncApi\Request\Request;
7
8
abstract class Method
9
{
10
11
	/**
12
	 * @var Closure|null
13
	 */
14
	private $callback;
15
16
	/**
17
	 * @param Closure $callback
18
	 */
19
	public function __construct(Closure $callback)
20
	{
21
		$this->callback = $callback;
22
	}
23
24
	/**
25
	 * @param Request $request
26
	 * @return mixed
27
	 */
28
	public function call(Request $request)
29
	{
30
		return $this->parseResponseData(call_user_func_array(
31
			$this->callback,
32
			$this->parseRequestData($request->getData())
33
		));
34
	}
35
36
	/**
37
	 * @return string
38
	 */
39
	abstract public function getName();
40
41
	/**
42
	 * @param array $data
43
	 * @return array
44
	 */
45
	abstract protected function parseRequestData($data);
46
47
	/**
48
	 * @param mixed $data
49
	 * @return mixed
50
	 */
51
	abstract protected function parseResponseData($data);
52
53
}
54