Skip to content

Commit 1e13ed1

Browse files
committed
tabs -> spaces
1 parent 7887ca0 commit 1e13ed1

File tree

6 files changed

+164
-164
lines changed

6 files changed

+164
-164
lines changed

Form/ChoosePaymentMethodType.php

+45-45
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class ChoosePaymentMethodType extends AbstractType
2525
{
26-
private $pluginController;
26+
private $pluginController;
2727
private $paymentMethods;
2828

2929
public function __construct(PluginControllerInterface $pluginController, array $paymentMethods)
@@ -38,12 +38,12 @@ public function __construct(PluginControllerInterface $pluginController, array $
3838

3939
public function buildForm(FormBuilder $builder, array $options)
4040
{
41-
if (!isset($options['currency'])) {
42-
throw new \InvalidArgumentException(sprintf('The option "currency" must be given for form type "%s".', $this->getName()));
43-
}
44-
if (!isset($options['amount'])) {
45-
throw new \InvalidArgumentException(sprintf('The option "amount" must be given for form type "%s".', $this->getName()));
46-
}
41+
if (!isset($options['currency'])) {
42+
throw new \InvalidArgumentException(sprintf('The option "currency" must be given for form type "%s".', $this->getName()));
43+
}
44+
if (!isset($options['amount'])) {
45+
throw new \InvalidArgumentException(sprintf('The option "amount" must be given for form type "%s".', $this->getName()));
46+
}
4747

4848
$allowAllMethods = !isset($options['allowed_methods']);
4949

@@ -93,16 +93,16 @@ public function transform($data, array $options)
9393
}
9494

9595
if ($data instanceof PaymentInstruction) {
96-
$method = $data->getPaymentSystemName();
97-
$methodData = array_map(function($v) { return $v[0]; }, $data->getExtendedData()->all());
98-
if (isset($options['predefined_data'][$method])) {
99-
$methodData = array_diff_key($methodData, $options['predefined_data'][$method]);
100-
}
101-
102-
return array(
103-
'method' => $method,
104-
'data_'.$method => $methodData,
105-
);
96+
$method = $data->getPaymentSystemName();
97+
$methodData = array_map(function($v) { return $v[0]; }, $data->getExtendedData()->all());
98+
if (isset($options['predefined_data'][$method])) {
99+
$methodData = array_diff_key($methodData, $options['predefined_data'][$method]);
100+
}
101+
102+
return array(
103+
'method' => $method,
104+
'data_'.$method => $methodData,
105+
);
106106
}
107107

108108
throw new \RuntimeException(sprintf('Unsupported data of type "%s".', ('object' === $type = gettype($data)) ? get_class($data) : $type));
@@ -119,13 +119,13 @@ public function reverseTransform($data, array $options)
119119
}
120120

121121
if (isset($options['predefined_data'][$method])) {
122-
if (!is_array($options['predefined_data'][$method])) {
123-
throw new \RuntimeException(sprintf('"predefined_data" is expected to be an array for each method, but got "%s" for method "%s".', json_encode($options['extra_data'][$method]), $method));
124-
}
122+
if (!is_array($options['predefined_data'][$method])) {
123+
throw new \RuntimeException(sprintf('"predefined_data" is expected to be an array for each method, but got "%s" for method "%s".', json_encode($options['extra_data'][$method]), $method));
124+
}
125125

126-
foreach ($options['predefined_data'][$method] as $k => $v) {
127-
$extendedData->set($k, $v);
128-
}
126+
foreach ($options['predefined_data'][$method] as $k => $v) {
127+
$extendedData->set($k, $v);
128+
}
129129
}
130130

131131
return new PaymentInstruction($options['amount'], $options['currency'], $method, $extendedData);
@@ -148,24 +148,24 @@ public function validate(FormInterface $form, array $options)
148148

149149
$result = $this->pluginController->checkPaymentInstruction($instruction);
150150
if (Result::STATUS_SUCCESS !== $result->getStatus()) {
151-
$this->applyErrorsToForm($form, $result);
151+
$this->applyErrorsToForm($form, $result);
152152

153-
return;
153+
return;
154154
}
155155

156156
$result = $this->pluginController->validatePaymentInstruction($instruction);
157157
if (Result::STATUS_SUCCESS !== $result->getStatus()) {
158-
$this->applyErrorsToForm($form, $result);
158+
$this->applyErrorsToForm($form, $result);
159159
}
160160
}
161161

162162
public function getDefaultOptions(array $options)
163163
{
164-
return array(
165-
'currency' => null,
166-
'amount' => null,
167-
'predefined_data' => array(),
168-
);
164+
return array(
165+
'currency' => null,
166+
'amount' => null,
167+
'predefined_data' => array(),
168+
);
169169
}
170170

171171
public function getName()
@@ -175,25 +175,25 @@ public function getName()
175175

176176
private function applyErrorsToForm(FormInterface $form, Result $result)
177177
{
178-
$ex = $result->getPluginException();
178+
$ex = $result->getPluginException();
179179

180-
$globalErrors = $ex->getGlobalErrors();
181-
$dataErrors = $ex->getDataErrors();
180+
$globalErrors = $ex->getGlobalErrors();
181+
$dataErrors = $ex->getDataErrors();
182182

183-
// add a generic error message
184-
if (!$dataErrors && !$globalErrors) {
185-
$form->addError(new FormError('form.error.invalid_payment_instruction'));
183+
// add a generic error message
184+
if (!$dataErrors && !$globalErrors) {
185+
$form->addError(new FormError('form.error.invalid_payment_instruction'));
186186

187-
return;
188-
}
187+
return;
188+
}
189189

190-
foreach ($globalErrors as $error) {
191-
$form->addError(new FormError($error));
192-
}
190+
foreach ($globalErrors as $error) {
191+
$form->addError(new FormError($error));
192+
}
193193

194-
foreach ($dataErrors as $field => $error) {
195-
$form->get($field)->addError(new FormError($error));
196-
}
194+
foreach ($dataErrors as $field => $error) {
195+
$form->get($field)->addError(new FormError($error));
196+
}
197197
}
198198

199199
private function buildChoices(array $methods)

Plugin/Exception/InvalidPaymentInstructionException.php

+42-42
Original file line numberDiff line numberDiff line change
@@ -29,51 +29,51 @@
2929
*/
3030
class InvalidPaymentInstructionException extends FinancialException
3131
{
32-
private $dataErrors = array();
33-
private $globalErrors = array();
32+
private $dataErrors = array();
33+
private $globalErrors = array();
3434

35-
public function __construct($message = null, $code = 0, \Exception $previous = null)
36-
{
37-
parent::__construct($message ?: 'The payment instruction is invalid.', $code, $previous);
38-
}
35+
public function __construct($message = null, $code = 0, \Exception $previous = null)
36+
{
37+
parent::__construct($message ?: 'The payment instruction is invalid.', $code, $previous);
38+
}
3939

40-
/**
41-
* Sets an error map for data parameters.
42-
*
43-
* The keys are expected to match the keys of the offending entry in the
44-
* ExtendedData class.
45-
*
46-
* For example, if the "cc_holder" key is missing, this should be set to:
47-
*
48-
* array("cc_holder" => "The credit card holder is required.")
49-
*
50-
* @param array $errors
51-
*/
52-
public function setDataErrors(array $errors)
53-
{
54-
$this->dataErrors = $errors;
55-
}
40+
/**
41+
* Sets an error map for data parameters.
42+
*
43+
* The keys are expected to match the keys of the offending entry in the
44+
* ExtendedData class.
45+
*
46+
* For example, if the "cc_holder" key is missing, this should be set to:
47+
*
48+
* array("cc_holder" => "The credit card holder is required.")
49+
*
50+
* @param array $errors
51+
*/
52+
public function setDataErrors(array $errors)
53+
{
54+
$this->dataErrors = $errors;
55+
}
5656

57-
/**
58-
* Sets an error list for the entire PaymentInstruction.
59-
*
60-
* This list is globally for the entire PaymentInstruction, and not
61-
* directly related to any specific data entry.
62-
*
63-
* @param array $errors
64-
*/
65-
public function setGlobalErrors(array $errors)
66-
{
67-
$this->globalErrors = $errors;
68-
}
57+
/**
58+
* Sets an error list for the entire PaymentInstruction.
59+
*
60+
* This list is globally for the entire PaymentInstruction, and not
61+
* directly related to any specific data entry.
62+
*
63+
* @param array $errors
64+
*/
65+
public function setGlobalErrors(array $errors)
66+
{
67+
$this->globalErrors = $errors;
68+
}
6969

70-
public function getDataErrors()
71-
{
72-
return $this->dataErrors;
73-
}
70+
public function getDataErrors()
71+
{
72+
return $this->dataErrors;
73+
}
7474

75-
public function getGlobalErrors()
76-
{
77-
return $this->globalErrors;
78-
}
75+
public function getGlobalErrors()
76+
{
77+
return $this->globalErrors;
78+
}
7979
}

Tests/Functional/AppKernel.php

+42-42
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,46 @@
88

99
class AppKernel extends Kernel
1010
{
11-
private $config;
12-
13-
public function __construct($config)
14-
{
15-
parent::__construct('test', true);
16-
17-
$fs = new Filesystem();
18-
if (!$fs->isAbsolutePath($config)) {
19-
$config = __DIR__.'/config/'.$config;
20-
}
21-
22-
if (!file_exists($config)) {
23-
throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config));
24-
}
25-
26-
$this->config = $config;
27-
}
28-
29-
public function registerBundles()
30-
{
31-
return array(
32-
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
33-
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
34-
new \Symfony\Bundle\TwigBundle\TwigBundle(),
35-
new \JMS\Payment\CoreBundle\Tests\Functional\TestBundle\TestBundle(),
36-
new \JMS\Payment\CoreBundle\JMSPaymentCoreBundle(),
37-
new \JMS\Payment\PaypalBundle\JMSPaymentPaypalBundle(),
38-
new \JMS\AopBundle\JMSAopBundle(),
39-
new \JMS\DiExtraBundle\JMSDiExtraBundle($this),
40-
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
41-
);
42-
}
43-
44-
public function registerContainerConfiguration(LoaderInterface $loader)
45-
{
46-
$loader->load($this->config);
47-
}
48-
49-
public function getCacheDir()
50-
{
51-
return sys_get_temp_dir().'/JMSPaymentCoreBundle';
52-
}
11+
private $config;
12+
13+
public function __construct($config)
14+
{
15+
parent::__construct('test', true);
16+
17+
$fs = new Filesystem();
18+
if (!$fs->isAbsolutePath($config)) {
19+
$config = __DIR__.'/config/'.$config;
20+
}
21+
22+
if (!file_exists($config)) {
23+
throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config));
24+
}
25+
26+
$this->config = $config;
27+
}
28+
29+
public function registerBundles()
30+
{
31+
return array(
32+
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
33+
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
34+
new \Symfony\Bundle\TwigBundle\TwigBundle(),
35+
new \JMS\Payment\CoreBundle\Tests\Functional\TestBundle\TestBundle(),
36+
new \JMS\Payment\CoreBundle\JMSPaymentCoreBundle(),
37+
new \JMS\Payment\PaypalBundle\JMSPaymentPaypalBundle(),
38+
new \JMS\AopBundle\JMSAopBundle(),
39+
new \JMS\DiExtraBundle\JMSDiExtraBundle($this),
40+
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
41+
);
42+
}
43+
44+
public function registerContainerConfiguration(LoaderInterface $loader)
45+
{
46+
$loader->load($this->config);
47+
}
48+
49+
public function getCacheDir()
50+
{
51+
return sys_get_temp_dir().'/JMSPaymentCoreBundle';
52+
}
5353
}

Tests/Functional/BaseTestCase.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77

88
class BaseTestCase extends WebTestCase
99
{
10-
static protected function createKernel(array $options = array())
11-
{
12-
return self::$kernel = new AppKernel(
13-
isset($options['config']) ? $options['config'] : 'default.yml'
14-
);
15-
}
10+
static protected function createKernel(array $options = array())
11+
{
12+
return self::$kernel = new AppKernel(
13+
isset($options['config']) ? $options['config'] : 'default.yml'
14+
);
15+
}
1616

17-
protected function setUp()
18-
{
19-
$fs = new Filesystem();
17+
protected function setUp()
18+
{
19+
$fs = new Filesystem();
2020
$fs->remove(sys_get_temp_dir().'/JMSPaymentCoreBundle/');
21-
}
21+
}
2222

23-
protected final function importDatabaseSchema()
24-
{
23+
protected final function importDatabaseSchema()
24+
{
2525
$em = self::$kernel->getContainer()->get('doctrine.orm.entity_manager');
2626

2727
$metadata = $em->getMetadataFactory()->getAllMetadata();
2828
if (!empty($metadata)) {
29-
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
30-
$schemaTool->createSchema($metadata);
29+
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
30+
$schemaTool->createSchema($metadata);
3131
}
32-
}
32+
}
3333
}

Tests/bootstrap.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
$dir = __DIR__;
55
$lastDir = null;
66
while (($dir = dirname($dir)) && $dir !== $lastDir) {
7-
$lastDir = $dir;
7+
$lastDir = $dir;
88

9-
if (file_exists($file = $dir.'/app/autoload.php')) {
10-
require_once $file;
11-
return;
12-
}
9+
if (file_exists($file = $dir.'/app/autoload.php')) {
10+
require_once $file;
11+
return;
12+
}
1313
}
1414

1515
throw new \RuntimeException('Could not locate the project\'s bootstrap.php.cache. If your bundle is not inside a project, you need to replace this bootstrap file.');

0 commit comments

Comments
 (0)