Skip to content

Commit e8a93bf

Browse files
committed
Added PhpDocumentor support + Separated configuration information management, decoupling it from library + Fixed some minor fixes (NEXWAY-1)
1 parent 48e4ed8 commit e8a93bf

File tree

11 files changed

+123
-96
lines changed

11 files changed

+123
-96
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
_ide_helper.php
55
composer.lock
66
vendor
7+
output

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"zendframework/zend-soap": "2.3.*"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "4.1.*"
24+
"phpunit/phpunit": "4.1.*",
25+
"phpdocumentor/phpdocumentor": "2.*"
2526
},
2627
"config": {
2728
"preferred-install": "dist"

src/Audith/Providers/Nexway.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
*/
77
class Nexway
88
{
9+
private $config = array();
10+
11+
12+
public function __construct($config)
13+
{
14+
$this->config = $config;
15+
}
16+
17+
918
/**
1019
* Wrapper to process Nexway API Methods (single-run version)
1120
*
@@ -55,7 +64,7 @@ public function run(Nexway\Data\Request $data)
5564

5665
private function exceptionHandler($msg, $code, $responseObject)
5766
{
58-
$_globalExceptionMappings = \Audith\Providers\Nexway\Exception::$exceptionCodeMapping;
67+
$_globalExceptionMappings = Nexway\Exception::$exceptionCodeMapping;
5968

6069
$_responseObjectNamespace = '\\' . get_class($responseObject);
6170
$_localExceptionMappings = $_responseObjectNamespace::$exceptionCodeMapping;
@@ -78,20 +87,18 @@ private function exceptionHandler($msg, $code, $responseObject)
7887
*/
7988
private function sendRequest(Nexway\Data\Request $data)
8089
{
81-
$_config = \Audith\Providers\Nexway\Data::getConfig("Nexway");
82-
8390
$_wsdlHttpBinding = "";
8491
$_wsdlServiceName = "";
85-
if ($data->request instanceof \Audith\Providers\Nexway\Data\Request\CatalogApi) {
92+
if ($data->request instanceof Nexway\Data\Request\CatalogApi) {
8693
$_wsdlServiceName = "CatalogApi";
87-
} elseif ($data->request instanceof \Audith\Providers\Nexway\Data\Request\OrderApi) {
94+
} elseif ($data->request instanceof Nexway\Data\Request\OrderApi) {
8895
$_wsdlServiceName = "OrderApi";
89-
} elseif ($data->request instanceof \Audith\Providers\Nexway\Data\Request\CustomerApi) {
96+
} elseif ($data->request instanceof Nexway\Data\Request\CustomerApi) {
9097
$_wsdlServiceName = "CustomerApi";
9198
}
9299

93-
if (isset($_config['service']['nexway']['url'][lcfirst($_wsdlServiceName)])) {
94-
$_wsdlHttpBinding = $_config['service']['nexway']['url'][lcfirst($_wsdlServiceName)];
100+
if (isset($this->config['service']['nexway']['url'][lcfirst($_wsdlServiceName)])) {
101+
$_wsdlHttpBinding = $this->config['service']['nexway']['url'][lcfirst($_wsdlServiceName)];
95102
}
96103

97104
$client = new \Zend\Soap\Client();

src/Audith/Providers/Nexway/Data.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,6 @@ abstract class Data
3636
);
3737

3838

39-
/**
40-
* Returns contents of config.ini file for working environment
41-
*
42-
* @param string $providerName
43-
*
44-
* @return array
45-
* @throws \Audith\Providers\Nexway\Exception\ConfigFileNotReadableException
46-
*/
47-
public static function getConfig($providerName)
48-
{
49-
$_environment = "development";
50-
51-
if (isset($_ENV['APPLICATION_ENV']) and !empty($_ENV['APPLICATION_ENV'])) {
52-
$_environment = $_ENV['APPLICATION_ENV'];
53-
}
54-
55-
$_zendConfigReader = new \Zend\Config\Reader\Ini();
56-
$_configFileLocation = dirname(dirname(__FILE__)) . "/" . ucfirst($providerName) . "/config.ini";
57-
try {
58-
$_configInformationFromIniFile = $_zendConfigReader->fromFile($_configFileLocation);
59-
} catch (\Zend\Config\Exception\RuntimeException $e) {
60-
throw new \Audith\Providers\Nexway\Exception\ConfigFileNotReadableException("Error reading INI file at location " . $_configFileLocation);
61-
}
62-
63-
return $_configInformationFromIniFile[$_environment];
64-
}
65-
66-
6739
/**
6840
* Maps PHP-DOMNode to Provider Response Object
6941
*

src/Audith/Providers/Nexway/Data/Request.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
11
<?php
22
namespace Audith\Providers\Nexway\Data;
33

4-
use \Audith\Providers\Nexway\Data;
5-
64
/**
75
* @author Shahriyar Imanov <[email protected]>
86
*/
97
class Request extends \Audith\Providers\Nexway\Data
108
{
11-
const SALES_TERRITORY_EU = "EU";
9+
const SALES_TERRITORY_EU = "eu";
1210

13-
const SALES_TERRITORY_UK = "UK";
11+
const SALES_TERRITORY_UK = "uk";
1412

15-
const SALES_TERRITORY_US = "US";
13+
const SALES_TERRITORY_US = "us";
1614

1715
/**
1816
* @var string
1917
*/
2018
public $secret;
2119

2220
/**
23-
* @var Data
21+
* @var \Audith\Providers\Nexway\Data
2422
*/
2523
public $request;
2624

2725

2826
/**
2927
* Creates Request struct for any operation
3028
*/
31-
public function __construct(Data $data, $salesTerritory = self::SALES_TERRITORY_EU)
29+
public function __construct(\Audith\Providers\Nexway\Data $data)
3230
{
33-
$config = \Audith\Providers\Nexway\Data::getConfig("Nexway");
34-
35-
$this->secret = $config['service']['nexway']['secret'][strtolower($salesTerritory)];
3631
$this->request = $data;
3732

3833
return $this;

src/Audith/Providers/Nexway/Data/Response/CatalogApi/getCategories/subcategory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class subcategory extends \Audith\Providers\Nexway\Data
1111
*/
1212
public $id;
1313

14-
1514
/**
1615
* @var string
1716
*/

src/Audith/Providers/Nexway/Data/Response/CustomerApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
/**
55
* @author Shahriyar Imanov <[email protected]>
66
*/
7-
class CustomerApi extends \Audith\Providers\Nexway\Data
7+
class CustomerApi extends \Audith\Providers\Nexway\Data\Response
88
{
99
}

src/Audith/Providers/Nexway/Data/Response/OrderApi/updateDownloadTime.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ class updateDownloadTime extends \Audith\Providers\Nexway\Data\Response\OrderApi
2929
*/
3030
public $newDownloadEndDate;
3131

32-
/**
33-
* @var getDownloadInfo\orderLines[]
34-
*/
35-
public $orderLines = array();
36-
3732
/**
3833
* @var integer
3934
*/

src/Audith/Providers/Nexway/Exception.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
class Exception extends \Exception
99
{
1010
public static $exceptionCodeMapping = array(
11-
70 => "SecretIsMissingException",
12-
71 => "SecretNotValidException"
11+
70 => "SecretIsMissingException",
12+
71 => "SecretNotValidException"
1313
);
1414

1515

0 commit comments

Comments
 (0)