From e46bfcfeaa1f6511c17fe3a81e6fa58827135cdc Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sat, 7 Sep 2013 19:41:51 +0200 Subject: [PATCH] cs fixer --- src/Payment/Saferpay/Data/AbstractBase.php | 12 ++++----- src/Payment/Saferpay/Data/AbstractGetSet.php | 6 ++--- src/Payment/Saferpay/Data/KeyValueBag.php | 23 ++++++++-------- .../Saferpay/Data/PayConfirmParameter.php | 2 +- .../Data/PayConfirmParameterInterface.php | 4 +-- src/Payment/Saferpay/Data/SubBaseBag.php | 2 +- .../Saferpay/Data/SubBaseInterface.php | 2 +- src/Payment/Saferpay/Saferpay.php | 27 ++++++++++--------- 8 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/Payment/Saferpay/Data/AbstractBase.php b/src/Payment/Saferpay/Data/AbstractBase.php index 2cab380..dd3f3fb 100644 --- a/src/Payment/Saferpay/Data/AbstractBase.php +++ b/src/Payment/Saferpay/Data/AbstractBase.php @@ -29,17 +29,17 @@ public function addSubObject(SubBaseInterface $subBase) } /** - * @param string $name - * @param array $arguments + * @param string $name + * @param array $arguments * @return mixed * @throws \ErrorException */ public function __call($name, $arguments) { - foreach($this->subObjectBags as $subObjectBag) { - if($subObjectBag->getReflection()->hasMethod($name)) { + foreach ($this->subObjectBags as $subObjectBag) { + if ($subObjectBag->getReflection()->hasMethod($name)) { $methodReflection = $subObjectBag->getReflection()->getMethod($name); - if($methodReflection->isPublic()) { + if ($methodReflection->isPublic()) { return $methodReflection->invokeArgs($subObjectBag->getObject(), $arguments); } else { throw new \ErrorException("Method {$name} is not public on {$subObjectBag->getReflection()->getName()}"); @@ -65,4 +65,4 @@ public function getInvalidData() { return $this->keyValueBag->getInvalidData(); } -} \ No newline at end of file +} diff --git a/src/Payment/Saferpay/Data/AbstractGetSet.php b/src/Payment/Saferpay/Data/AbstractGetSet.php index a38b51a..429f093 100644 --- a/src/Payment/Saferpay/Data/AbstractGetSet.php +++ b/src/Payment/Saferpay/Data/AbstractGetSet.php @@ -14,8 +14,8 @@ abstract class AbstractGetSet protected function registerValidationKeys() { $reflectionClass = new \ReflectionClass($this); - foreach($reflectionClass->getConstants() as $constName => $constValue) { - if(SaferpayConditionConverter::isCondition($constValue)) { + foreach ($reflectionClass->getConstants() as $constName => $constValue) { + if (SaferpayConditionConverter::isCondition($constValue)) { $this->keyValueBag->addValidationKey($constName, $constValue); } } @@ -38,4 +38,4 @@ protected function get($offset) { return $this->keyValueBag[$offset]; } -} \ No newline at end of file +} diff --git a/src/Payment/Saferpay/Data/KeyValueBag.php b/src/Payment/Saferpay/Data/KeyValueBag.php index 5b212d4..df71316 100644 --- a/src/Payment/Saferpay/Data/KeyValueBag.php +++ b/src/Payment/Saferpay/Data/KeyValueBag.php @@ -41,7 +41,7 @@ public function __construct() } /** - * @param mixed $offset + * @param mixed $offset * @return bool */ public function offsetExists($offset) @@ -50,7 +50,7 @@ public function offsetExists($offset) } /** - * @param mixed $offset + * @param mixed $offset * @return mixed|null */ public function offsetGet($offset) @@ -59,21 +59,22 @@ public function offsetGet($offset) } /** - * @param mixed $offset - * @param mixed $value + * @param mixed $offset + * @param mixed $value * @throws \InvalidArgumentException */ public function offsetSet($offset, $value) { - if(!is_scalar($value)) { + if (!is_scalar($value)) { throw new \InvalidArgumentException("Only scalar values (integer, float, string or boolean) are allowed!"); } - if(array_key_exists($offset, $this->validKeys)) { + if (array_key_exists($offset, $this->validKeys)) { $condition = $this->validKeys[$offset]; - if(preg_match(SaferpayConditionConverter::toRegex($condition), $value) === 1) { + if (preg_match(SaferpayConditionConverter::toRegex($condition), $value) === 1) { $this->data[$offset] = $value; $this->keys = array_keys($this->data); + return; } } @@ -86,7 +87,7 @@ public function offsetSet($offset, $value) */ public function offsetUnset($offset) { - if(in_array($offset, $this->keys)) { + if (in_array($offset, $this->keys)) { unset($this->keys[array_search($offset, $this->keys)]); $this->keys = array_keys($this->data); } @@ -97,7 +98,7 @@ public function offsetUnset($offset) */ public function current() { - if(array_key_exists($this->pointer, $this->keys)) { + if (array_key_exists($this->pointer, $this->keys)) { return $this->data[$this->keys[$this->pointer]]; } @@ -114,7 +115,7 @@ public function next() */ public function key() { - if(array_key_exists($this->pointer, $this->keys)) { + if (array_key_exists($this->pointer, $this->keys)) { return $this->keys[$this->pointer]; } @@ -161,4 +162,4 @@ public function getInvalidData() { return $this->invalidData; } -} \ No newline at end of file +} diff --git a/src/Payment/Saferpay/Data/PayConfirmParameter.php b/src/Payment/Saferpay/Data/PayConfirmParameter.php index 09b15a6..987bdf4 100644 --- a/src/Payment/Saferpay/Data/PayConfirmParameter.php +++ b/src/Payment/Saferpay/Data/PayConfirmParameter.php @@ -349,7 +349,7 @@ public function getMpiTxCavv() } /** - * @param string $mpi_mpi_xid + * @param string $mpi_mpi_xid * @return mixed * @deprecated */ diff --git a/src/Payment/Saferpay/Data/PayConfirmParameterInterface.php b/src/Payment/Saferpay/Data/PayConfirmParameterInterface.php index fb2948a..bed2243 100644 --- a/src/Payment/Saferpay/Data/PayConfirmParameterInterface.php +++ b/src/Payment/Saferpay/Data/PayConfirmParameterInterface.php @@ -333,7 +333,7 @@ public function setMpiliabilityshift($mpi_liabilityshift); public function getMpiliabilityshift(); /** - * @param string $mpi_tx_cavv + * @param string $mpi_tx_cavv * @return mixed * @deprecated */ @@ -346,7 +346,7 @@ public function setMpiTxCavv($mpi_tx_cavv); public function getMpiTxCavv(); /** - * @param string $mpi_xid + * @param string $mpi_xid * @return mixed * @deprecated */ diff --git a/src/Payment/Saferpay/Data/SubBaseBag.php b/src/Payment/Saferpay/Data/SubBaseBag.php index 2775a0a..58c0bbf 100644 --- a/src/Payment/Saferpay/Data/SubBaseBag.php +++ b/src/Payment/Saferpay/Data/SubBaseBag.php @@ -35,4 +35,4 @@ public function getReflection() { return $this->reflection; } -} \ No newline at end of file +} diff --git a/src/Payment/Saferpay/Data/SubBaseInterface.php b/src/Payment/Saferpay/Data/SubBaseInterface.php index 121c689..39f78c0 100644 --- a/src/Payment/Saferpay/Data/SubBaseInterface.php +++ b/src/Payment/Saferpay/Data/SubBaseInterface.php @@ -5,4 +5,4 @@ interface SubBaseInterface { public function setValueBag(KeyValueBag $valueBag); -} \ No newline at end of file +} diff --git a/src/Payment/Saferpay/Saferpay.php b/src/Payment/Saferpay/Saferpay.php index 82d2452..00c6a7e 100644 --- a/src/Payment/Saferpay/Saferpay.php +++ b/src/Payment/Saferpay/Saferpay.php @@ -75,7 +75,7 @@ protected function getLogger() } /** - * @param PayInitParameterInterface $payInitParameter + * @param PayInitParameterInterface $payInitParameter * @return mixed */ public function createPayInit(PayInitParameterInterface $payInitParameter) @@ -86,12 +86,12 @@ public function createPayInit(PayInitParameterInterface $payInitParameter) /** * @param $xml * @param $signature - * @param PayConfirmParameterInterface $payConfirmParameter + * @param PayConfirmParameterInterface $payConfirmParameter * @return PayConfirmParameterInterface */ public function verifyPayConfirm($xml, $signature, PayConfirmParameterInterface $payConfirmParameter = null) { - if(is_null($payConfirmParameter)) { + if (is_null($payConfirmParameter)) { $payConfirmParameter = new PayConfirmParameter(); } @@ -105,11 +105,11 @@ public function verifyPayConfirm($xml, $signature, PayConfirmParameterInterface } /** - * @param PayConfirmParameter $payConfirmParameter - * @param string $action - * @param null $spPassword - * @param PayCompleteParameterInterface $payCompleteParameter - * @param PayCompleteResponseInterface $payCompleteResponse + * @param PayConfirmParameter $payConfirmParameter + * @param string $action + * @param null $spPassword + * @param PayCompleteParameterInterface $payCompleteParameter + * @param PayCompleteResponseInterface $payCompleteResponse * @return PayCompleteResponse|PayCompleteResponseInterface * @throws Exception\NoPasswordGivenException * @throws \Exception @@ -126,7 +126,7 @@ public function payCompleteV2( throw new \Exception('Saferpay: call confirm before complete!'); } - if(is_null($payCompleteParameter)) { + if (is_null($payCompleteParameter)) { $payCompleteParameter = new PayCompleteParameter(); } @@ -139,13 +139,13 @@ public function payCompleteV2( if ($this->isTestAccountId($payCompleteParameter->getAccountid())) { $payCompleteParameterData = array_merge($payCompleteParameterData, array('spPassword' => PayInitParameterInterface::SAFERPAYTESTACCOUNT_SPPASSWORD)); - } else if ($action != PayCompleteParameterInterface::ACTION_SETTLEMENT && !$spPassword) { + } elseif ($action != PayCompleteParameterInterface::ACTION_SETTLEMENT && !$spPassword) { throw new NoPasswordGivenException(); } $response = $this->request($payCompleteParameter->getRequestUrl(), $payCompleteParameterData); - if(is_null($payCompleteResponse)) { + if (is_null($payCompleteResponse)) { $payCompleteResponse = new PayCompleteResponse(); } @@ -202,7 +202,7 @@ protected function fillDataFromXML(AbstractBase $data, $xml) $method = 'set'; $offsetParts = explode('_', $attribute->nodeName); - foreach($offsetParts as $offsetPart) { + foreach ($offsetParts as $offsetPart) { $method .= ucfirst(strtolower($offsetPart)); } $data->$method($attribute->nodeValue); @@ -210,12 +210,13 @@ protected function fillDataFromXML(AbstractBase $data, $xml) } /** - * @param string $accountId + * @param string $accountId * @return bool */ protected function isTestAccountId($accountId) { $prefix = PayInitParameterInterface::TESTACCOUNT_PREFIX; + return substr($accountId, 0, strlen($prefix)) === $prefix; } }