1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright 2013 Jan Eichhorn <[email protected]> |
4
|
|
|
* |
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
6
|
|
|
* you may not use this file except in compliance with the License. |
7
|
|
|
* You may obtain a copy of the License at |
8
|
|
|
* |
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
10
|
|
|
* |
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14
|
|
|
* See the License for the specific language governing permissions and |
15
|
|
|
* limitations under the License. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace ApaiIO\Operations; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* A base implementation of the OperationInterface |
22
|
|
|
* |
23
|
|
|
* @author Jan Eichhorn <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
abstract class AbstractOperation implements OperationInterface |
26
|
|
|
{ |
27
|
|
|
protected $parameter = array(); |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Returns an array of responseGroups |
31
|
|
|
* |
32
|
2 |
|
* @return array |
33
|
|
|
*/ |
34
|
2 |
|
public function getResponseGroup() |
35
|
|
|
{ |
36
|
2 |
|
return $this->getSingleOperationParameter('ResponseGroup'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
16 |
|
public function setResponseGroup(array $responseGroup) |
43
|
|
|
{ |
44
|
16 |
|
$this->parameter['ResponseGroup'] = $responseGroup; |
45
|
|
|
|
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
public function getOperationParameter() |
53
|
|
|
{ |
54
|
|
|
return $this->parameter; |
55
|
12 |
|
} |
56
|
|
|
|
57
|
12 |
|
/** |
58
|
1 |
|
* Returns a single operation parameter if set |
59
|
|
|
* |
60
|
1 |
|
* @param string $keyName |
61
|
|
|
* @return mixed|null |
62
|
|
|
*/ |
63
|
12 |
|
public function getSingleOperationParameter($keyName) { |
64
|
11 |
|
return isset($this->parameter[$keyName]) ? $this->parameter[$keyName] : null; |
65
|
|
|
} |
66
|
11 |
|
|
67
|
|
|
/** |
68
|
|
|
* Magic setter and getter functions |
69
|
1 |
|
* |
70
|
|
|
* @param string $methodName Methodname |
71
|
|
|
* @param string $parameter Parameters |
72
|
|
|
* |
73
|
|
|
* @return \ApaiIO\Operations\AbstractOperation |
74
|
|
|
*/ |
75
|
|
|
public function __call($methodName, $parameter) |
76
|
|
|
{ |
77
|
|
|
if (substr($methodName, 0, 3) == 'set') { |
78
|
|
|
$this->parameter[substr($methodName, 3)] = array_shift($parameter); |
79
|
|
|
|
80
|
|
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
if (substr($methodName, 0, 3) == 'get') { |
84
|
|
|
$keyName = substr($methodName, 3); |
85
|
|
|
|
86
|
|
|
return isset($this->parameter[$keyName]) ? $this->parameter[$keyName] : null; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
throw new \BadFunctionCallException(sprintf('The function "%s" does not exist!', $methodName)); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|