Skip to content

Commit

Permalink
cleanup, PSR-2 formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kiboflavin committed Jan 17, 2017
1 parent 11de850 commit 12b49c2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 37 deletions.
4 changes: 3 additions & 1 deletion OrbitalBatch/Exception.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php namespace OrbitalBatch;

class Exception extends \Exception {}
class Exception extends \Exception
{
}
29 changes: 14 additions & 15 deletions OrbitalBatch/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class Request
/**
* Constructor.
*
* @param string company Company name, used for filename generation
* @param string $userid API username
* @param string $industry_type Industry type
* @param string $bin Transaction routing
* @param string $merchant_id Merchant ID
* @param string $terminal_id Terminal ID
* @param string $company Company name, used for filename generation
* @param string $userid API username
* @param string $industry_type Industry type
* @param string $bin Transaction routing
* @param string $merchant_id Merchant ID
* @param string $terminal_id Terminal ID
*/
public function __construct($company, $userid, $industry_type, $bin, $merchant_id, $terminal_id)
{
Expand Down Expand Up @@ -156,7 +156,6 @@ public function refund(array $transaction)

/**
* Send "End of day" transaction to settle today's batch
*
*/
public function endOfDay()
{
Expand Down Expand Up @@ -241,21 +240,21 @@ public function gen_batchFileID($dom)
public function createBatch()
{
$dom = new \DOMDocument('1.0', 'utf-8');
$dom->formatOutput = TRUE;
$dom->formatOutput = true;

$trans_request_element = $dom->createElement(self::TRANS_REQUEST);
$trans_request_node = $dom->appendChild($trans_request_element);

# add batchFileID block
// add batchFileID block
$trans_request_node->appendChild($this->gen_batchFileID($dom));

# add stored transactions in order
// add stored transactions in order
foreach ($this->transaction_order as $trans_type) {

# if there are transactions of this type
// if there are transactions of this type
if (! empty($this->{$trans_type})) {

# recurse through stored transactions
// recurse through stored transactions
foreach ($this->{$trans_type} as $tr) {

$request_no_attr = $dom->createAttribute(self::BATCH_REQUEST_NO);
Expand All @@ -266,10 +265,10 @@ public function createBatch()

$trans_type_node = $trans_request_node->appendChild($trans_type_element);

# recurse through fields, add them in the right order
// recurse through fields, add them in the right order
foreach ($tr->valid_fields() as $field) {

# add the field if its specified
// add the field if its specified
if (isset($tr->parameters[$field])) {
$item = $dom->createElement($field, $tr->parameters[$field]);
$trans_type_node->appendChild($item);
Expand All @@ -279,7 +278,7 @@ public function createBatch()
}
}

# finally, add the request count to the transRequest element at the top
// finally, add the request count to the transRequest element at the top
$request_count_attr = $dom->createAttribute(self::REQUEST_COUNT);
$request_count_attr->value = $this->request_count - 1;
$trans_request_element->appendChild($request_count_attr);
Expand Down
24 changes: 12 additions & 12 deletions OrbitalBatch/Request/Transaction.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php namespace OrbitalBatch\Request;

class Transaction {
public $parameters;
class Transaction
{
public $parameters;

public function __construct(array $parameters)
{
Expand All @@ -21,23 +21,23 @@ protected function valid_fields()
return array();
}

protected function validate()
protected function validate()
{
# check that all required fields are provided
// check that all required fields are provided
foreach ($this->required_fields() as $key) {
if (! array_key_exists($key, $this->parameters)) {
throw new \OrbitalBatch\Exception("Required parameter \"{$key}\" missing in Transaction object");
}
}

# check that all provided fields are valid
// check that all provided fields are valid
$valid_fields = $this->valid_fields();
foreach (array_keys($this->parameters) as $key) {
if (! in_array($key, $valid_fields)) {
foreach (array_keys($this->parameters) as $key) {
if (! in_array($key, $valid_fields)) {
throw new \OrbitalBatch\Exception("Invalid parameter \"{$key}\" in Transaction object");
}
}
}
}

return TRUE;
}
return true;
}
}
2 changes: 1 addition & 1 deletion OrbitalBatch/Request/customerProfileDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public function valid_fields()
{
return array(
"bin", "merchantID", "customerName", "customerRefNum"
);
);
}
}
2 changes: 1 addition & 1 deletion OrbitalBatch/Request/customerProfileFetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public function valid_fields()
return array(
"bin", "merchantID", "customerName", "customerRefNum",
"ccAccountNum", "euddIBAN"
);
);
}
}
2 changes: 1 addition & 1 deletion OrbitalBatch/Response.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace OrbitalBatch;

/**
* Generates Orbital Batch XML request
* Generates Orbital Batch XML response
*
* @package OrbitalBatch
*/
Expand Down
14 changes: 8 additions & 6 deletions OrbitalBatch/Response/Transaction.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php namespace OrbitalBatch\Response;

class Transaction {
public $parameters;
class Transaction
{
public $parameters;

public function __construct(\SimpleXMLElement $parameters)
{
Expand All @@ -15,14 +15,16 @@ public function __get($var)
return (string)$this->parameters->$var;
}

return NULL;
return null;
}

public function approved() {
public function approved()
{
return false;
}

public function status() {
public function status()
{
return null;
}
}

0 comments on commit 12b49c2

Please sign in to comment.