diff --git a/Readme.md b/Readme.md
index 0feb278..78d1003 100644
--- a/Readme.md
+++ b/Readme.md
@@ -4,6 +4,8 @@ This is a abastract from (https://github.com/kamerk22/AmazonGiftCode) to be not
Uses .env file to load configuration data
+`composer request gullevek/amazon-incentives`
+
## _ENV variables needed
* AWS_GIFT_CARD_KEY
@@ -15,14 +17,15 @@ Uses .env file to load configuration data
## How to use
-The class must be loaded with an autoloader (see test/autoloader.php for example).
-
The above _ENV variables must be set (Except AWS_DEBUG, defaults to off).
### create gift card
```php
-$aws_gc = Amazon\AmazonIncentives::make()->buyGiftCard((float)$value);
+use gullevek\AmazonIncentives\AmazonIncentives;
+// buy a gift card with a value
+$value = 500;
+$aws_gc = AmazonIncentives::make()->buyGiftCard((float)$value);
// the two below are need if we want to cancel the card
// get gift card id (gcID)
$aws_gc->getId();
@@ -55,14 +58,14 @@ Recommended to pool requests. Or check when last requests where sent and then pr
```php
// use getCreationRequestId() and getId() from request
-$aws_gc = Amazon\AmazonIncentives::make()->cancelGiftCard($creation_request_id, $gift_card_id);
+$aws_gc = gullevek\AmazonIncentives\AmazonIncentives::make()->cancelGiftCard($creation_request_id, $gift_card_id);
// return is as above
```
### check balance
```php
-$aws_gc = Amazon\AmazonIncentives::make()->getAvailableFunds();
+$aws_gc = gullevek\AmazonIncentives\AmazonIncentives::make()->getAvailableFunds();
```
## Exceptions
@@ -91,11 +94,10 @@ In this case the request has to be resend after a certain waiting period.
If AWS_DEBUG is set to 1 and internal array will be written with debug info.
-The Amazon\Debug\AmazonDebug class handles all this.
+The gulleek\AmazonIncentives\Debug\AmazonDebug class handles all this.
-In the Amazon\AWS\AWS main class the debugger gets set
-* setFlag that turns debugger on/off
-* setId (to set unique id for each run)
+In the gulleek\AmazonIncentives\AmazonIncentives main class the debugger gets set
+* setDebug that turns debugger on/off and if on sets unique id (getId to check)
New entries can be written with
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..b8ca2dc
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,21 @@
+{
+ "name": "gullevek/amazon-incentives",
+ "description": "Amazon Gift on Demand Incentives",
+ "type": "library",
+ "license": "help",
+ "autoload": {
+ "psr-4": {
+ "gullevek\\AmazonIncentives\\": "src/"
+ }
+ },
+ "authors": [
+ {
+ "name": "Clemens Schwaighofer",
+ "email": "gullevek@gullevek.org"
+ }
+ ],
+ "minimum-stability": "dev",
+ "require": {
+ "php": ">=7.4.0"
+ }
+}
diff --git a/src/Amazon/AWS/AWS.php b/src/AWS/AWS.php
similarity index 96%
rename from src/Amazon/AWS/AWS.php
rename to src/AWS/AWS.php
index 1a3c713..89a5b55 100644
--- a/src/Amazon/AWS/AWS.php
+++ b/src/AWS/AWS.php
@@ -1,14 +1,14 @@
$error_type,
'message' => $message,
// atach log data if exists
- 'log_id' => \Amazon\Debug\AmazonDebug::getId(),
- 'log' => \Amazon\Debug\AmazonDebug::getLog(),
+ 'log_id' => AmazonDebug::getId(),
+ 'log' => AmazonDebug::getLog(),
]),
$_error_code
);
diff --git a/src/Amazon/Response/CancelResponse.php b/src/Response/CancelResponse.php
similarity index 91%
rename from src/Amazon/Response/CancelResponse.php
rename to src/Response/CancelResponse.php
index 0d5df5a..c8bcdb7 100644
--- a/src/Amazon/Response/CancelResponse.php
+++ b/src/Response/CancelResponse.php
@@ -1,6 +1,8 @@
raw_json = $json_response;
- $this->log = \Amazon\Debug\AmazonDebug::getLog(\Amazon\Debug\AmazonDebug::getId());
+ $this->log = AmazonDebug::getLog(AmazonDebug::getId());
$this->parseJsonResponse($json_response);
}
diff --git a/src/Amazon/Response/CreateBalanceResponse.php b/src/Response/CreateBalanceResponse.php
similarity index 93%
rename from src/Amazon/Response/CreateBalanceResponse.php
rename to src/Response/CreateBalanceResponse.php
index 7fdb3e9..88973db 100644
--- a/src/Amazon/Response/CreateBalanceResponse.php
+++ b/src/Response/CreateBalanceResponse.php
@@ -1,6 +1,8 @@
raw_json = $json_response;
- $this->log = \Amazon\Debug\AmazonDebug::getLog(\Amazon\Debug\AmazonDebug::getId());
+ $this->log = AmazonDebug::getLog(AmazonDebug::getId());
$this->parseJsonResponse($json_response);
}
diff --git a/src/Amazon/Response/CreateResponse.php b/src/Response/CreateResponse.php
similarity index 95%
rename from src/Amazon/Response/CreateResponse.php
rename to src/Response/CreateResponse.php
index e7d2162..6cd9396 100644
--- a/src/Amazon/Response/CreateResponse.php
+++ b/src/Response/CreateResponse.php
@@ -1,6 +1,8 @@
raw_json = $json_response;
- $this->log = \Amazon\Debug\AmazonDebug::getLog(\Amazon\Debug\AmazonDebug::getId());
+ $this->log = AmazonDebug::getLog(AmazonDebug::getId());
$this->parseJsonResponse($json_response);
}
diff --git a/test/autoloader.php b/test/autoloader.php
deleted file mode 100644
index e48eca5..0000000
--- a/test/autoloader.php
+++ /dev/null
@@ -1,63 +0,0 @@
-";
- // set directory seperator (we need to replace from namespace)
- $DS = DIRECTORY_SEPARATOR;
- // base lib
- $LIB = defined('LIB') ? LIB : '../src' . $DS;
- // if lib is in path at the end, do not add lib again
- // note that $LIB can have a directory seperator at the end
- // strip that out before we do a match
- $_LIB = rtrim($LIB, $DS);
- if (!preg_match("|$_LIB$|", __DIR__)) {
- $LIB .= $DS;
- } else {
- $LIB = '';
- }
- // default path is unset
- $path = false;
- // set path on full dir
- // if we have the namespace in the class, strip it out
- $len = 0;
- if (strpos($class, __NAMESPACE__) !== false) {
- $len = strlen(__NAMESPACE__);
- }
- // set default extension
- $extension = '.php';
- // set full include path
- $path = __DIR__ . $DS . $LIB . substr($class, $len);
- // replace namespace \ with dir sepeator
- $path = str_replace('\\', $DS, $path) . $extension;
- // print "(2) Class clean: $path
";
- // if path is set and a valid file
- if ($path !== false && is_file($path)) {
- // print "(3) Load Path: $path
";
- // we should sub that
- // self::loadFile($path);
- include $path;
- return true;
- }
- return false;
- }
- // end class define
- }
-
- spl_autoload_register('Autoloader\Autoload::load', true, true);
-} // end check for already defined
-
-// __END__
diff --git a/test/aws_gift_card_tests.php b/test/aws_gift_card_tests.php
index 74db448..4ab9e2f 100644
--- a/test/aws_gift_card_tests.php
+++ b/test/aws_gift_card_tests.php
@@ -52,11 +52,16 @@ function printException(
}
}
-// general auto loader
-require 'autoloader.php';
-// env file loader
+// composer auto loader
+$loader = require '../vendor/autoload.php';
+// need to add this or it will not load here
+$loader->addPsr4('gullevek\\', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src');
+// print "LOADER:
" . print_r($loader, true) . "
";
+// env file loader (simple)
require 'read_env_file.php';
+use gullevek\AmazonIncentives\AmazonIncentives;
+
// load env data with dotenv
readEnvFile(__DIR__);
@@ -67,8 +72,9 @@ print "Amazon Gift Card Incentives
";
// aws key: AWS_GIFT_CARD_KEY
// aws secret: AWS_GIFT_CARD_SECRET
// partner id: AWS_GIFT_CARD_PARTNER_ID
-// optional
// currency: AWS_ICENTIVE_CURRENCY
+// optional
+// debug: AWS_DEBUG (if not set: off)
// as in .env
// AWS_GIFT_CARD_ENDPOINT.TEST
@@ -85,33 +91,7 @@ foreach (
$_ENV[$key] = $_ENV[$key . '.' . strtoupper((LOCATION))] ?? $_ENV[$key] ?? '';
}
-/*
- ENDPOINTS:
-
-- remove '-gamma' for non sandox
-WHERE URL REGION
-North America https://agcod-v2-gamma.amazon.com us-east-1
- https://agcod-v2.amazon.com
-(US, CA, MX)
-Europe and Asia https://agcod-v2-eu-gamma.amazon.com eu-west-1
- https://agcod-v2-eu.amazon.com
-(IT, ES, DE, FR, UK, TR, UAE, KSA, PL, NL, SE)
-Far East https://agcod-v2-fe-gamma.amazon.com us-west-2
- https://agcod-v2-fe.amazon.com
-(JP, AU, SG)
-
-CURRENCY
-USD for US
-EUR for EU (IT, ES, DE, FR, PL, NL, SE)
-JPY for JP
-CAD for CA
-AUD for AU
-TRY for TR
-AED for UAE
-MXN for MX
-GBP for UK
-*/
-
+// open debug file output
$fp = fopen('log/debug.' . date('YmdHis') . '.log', 'w');
// run info test (prints ENV vars)
@@ -119,7 +99,7 @@ $run_info_test = false;
// run test to get funds info
$run_fund_test = true;
// run the normal get/cancel gift card tests
-$run_gift_tests = true;
+$run_gift_tests = false;
// run mock error check tests
$run_mocks = false;
@@ -133,7 +113,7 @@ $mock_debug = false;
$mock_wait = 2;
if ($run_info_test === true) {
- $aws = new Amazon\AmazonIncentives();
+ $aws = new AmazonIncentives();
print "checkMe: " . print_r($aws->checkMe(), true) . "
";
fwrite($fp, writeLog($aws->checkMe()));
print "
";
@@ -142,7 +122,7 @@ if ($run_info_test === true) {
// check balance
if ($run_fund_test === true) {
try {
- $aws_test = Amazon\AmazonIncentives::make()->getAvailableFunds();
+ $aws_test = AmazonIncentives::make()->getAvailableFunds();
print "AWS: getAvailableFunds: " . $aws_test->getStatus() . ": "
. "Amount: " . $aws_test->getAmount() . ", "
. "Currency: " . $aws_test->getCurrency() . ", "
@@ -152,7 +132,7 @@ if ($run_fund_test === true) {
}
fwrite($fp, writeLog((array)$aws_test));
} catch (Exception $e) {
- $error = Amazon\AmazonIncentives::decodeExceptionMessage($e->getMessage());
+ $error = AmazonIncentives::decodeExceptionMessage($e->getMessage());
printException('getAvailableFunds', $e->getCode(), $error, $debug_print);
fwrite($fp, writeLog($error));
};
@@ -169,7 +149,7 @@ if ($run_gift_tests === true) {
$gift_card_id = '';
try {
// we must be sure we pass FLOAT there
- $aws_test = Amazon\AmazonIncentives::make()->buyGiftCard((float)$value);
+ $aws_test = AmazonIncentives::make()->buyGiftCard((float)$value);
$creation_request_id = $aws_test->getCreationRequestId();
$gift_card_id = $aws_test->getId();
$claim_code = $aws_test->getClaimCode();
@@ -184,7 +164,7 @@ if ($run_gift_tests === true) {
}
fwrite($fp, writeLog((array)$aws_test));
} catch (\Exception $e) {
- $error = Amazon\AmazonIncentives::decodeExceptionMessage($e->getMessage());
+ $error = AmazonIncentives::decodeExceptionMessage($e->getMessage());
printException('buyGiftCard', $e->getCode(), $error, $debug_print);
fwrite($fp, writeLog($error));
}
@@ -192,7 +172,7 @@ if ($run_gift_tests === true) {
sleep($debug_wait);
try {
// cancel above created card card
- $aws_test = Amazon\AmazonIncentives::make()->cancelGiftCard($creation_request_id, $gift_card_id);
+ $aws_test = AmazonIncentives::make()->cancelGiftCard($creation_request_id, $gift_card_id);
$request_status = $aws_test->getStatus();
print "AWS: cancelGiftCard: " . $request_status . ": "
. "creationRequestId: " . $creation_request_id . ", gcId: " . $gift_card_id;
@@ -201,7 +181,7 @@ if ($run_gift_tests === true) {
}
fwrite($fp, writeLog((array)$aws_test));
} catch (\Exception $e) {
- $error = Amazon\AmazonIncentives::decodeExceptionMessage($e->getMessage());
+ $error = AmazonIncentives::decodeExceptionMessage($e->getMessage());
print "AWS: cancelGiftCard: " . $error['status']
. " [" . $e->getCode() . "]: "
. $error['code'] . " | " . $error['type']
@@ -216,7 +196,7 @@ if ($run_gift_tests === true) {
// set same request ID twice to get same response test
try {
- $aws_test = Amazon\AmazonIncentives::make()->buyGiftCard((float)$value);
+ $aws_test = AmazonIncentives::make()->buyGiftCard((float)$value);
$creation_request_id = $aws_test->getCreationRequestId();
$gift_card_id = $aws_test->getId();
$claim_code = $aws_test->getClaimCode();
@@ -231,14 +211,14 @@ if ($run_gift_tests === true) {
}
fwrite($fp, writeLog((array)$aws_test));
} catch (\Exception $e) {
- $error = Amazon\AmazonIncentives::decodeExceptionMessage($e->getMessage());
+ $error = AmazonIncentives::decodeExceptionMessage($e->getMessage());
printException('cancelGiftCard', $e->getCode(), $error, $debug_print);
fwrite($fp, writeLog($error));
}
print "
";
sleep($debug_wait);
try {
- $aws_test = Amazon\AmazonIncentives::make()->buyGiftCard((float)$value, $creation_request_id);
+ $aws_test = AmazonIncentives::make()->buyGiftCard((float)$value, $creation_request_id);
$request_status = $aws_test->getStatus();
// same?
$expiration_date = $aws_test->getExpirationDate();
@@ -251,7 +231,7 @@ if ($run_gift_tests === true) {
}
fwrite($fp, writeLog((array)$aws_test));
} catch (\Exception $e) {
- $error = Amazon\AmazonIncentives::decodeExceptionMessage($e->getMessage());
+ $error = AmazonIncentives::decodeExceptionMessage($e->getMessage());
printException('buyGiftCard', $e->getCode(), $error, $debug_print);
fwrite($fp, writeLog($error));
}
@@ -285,7 +265,7 @@ if ($mock_debug === true) {
foreach ($mock as $creation_id => $mock_return) {
print "TS: " . microtime() . ": ";
try {
- $aws_test = Amazon\AmazonIncentives::make()->buyGiftCard((float)$mock_value, $creation_id);
+ $aws_test = AmazonIncentives::make()->buyGiftCard((float)$mock_value, $creation_id);
$creation_request_id = $aws_test->getCreationRequestId();
$gift_card_id = $aws_test->getId();
$claim_code = $aws_test->getClaimCode();
@@ -303,7 +283,7 @@ if ($mock_debug === true) {
}
fwrite($fp, writeLog((array)$aws_test));
} catch (Exception $e) {
- $error = Amazon\AmazonIncentives::decodeExceptionMessage($e->getMessage());
+ $error = AmazonIncentives::decodeExceptionMessage($e->getMessage());
print "AWS: MOCK: " . $creation_id . ": buyGiftCard: " . $error['status']
. " [" . $e->getCode() . "]: "
. $error['code'] . " | " . $error['type']
diff --git a/vendor/autoload.php b/vendor/autoload.php
new file mode 100644
index 0000000..2f80545
--- /dev/null
+++ b/vendor/autoload.php
@@ -0,0 +1,7 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Autoload;
+
+/**
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
+ *
+ * $loader = new \Composer\Autoload\ClassLoader();
+ *
+ * // register classes with namespaces
+ * $loader->add('Symfony\Component', __DIR__.'/component');
+ * $loader->add('Symfony', __DIR__.'/framework');
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * // to enable searching the include path (eg. for PEAR packages)
+ * $loader->setUseIncludePath(true);
+ *
+ * In this example, if you try to use a class in the Symfony\Component
+ * namespace or one of its children (Symfony\Component\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ *
+ * This class is loosely based on the Symfony UniversalClassLoader.
+ *
+ * @author Fabien Potencier
+ * @author Jordi Boggiano
+ * @see https://www.php-fig.org/psr/psr-0/
+ * @see https://www.php-fig.org/psr/psr-4/
+ */
+class ClassLoader
+{
+ /** @var ?string */
+ private $vendorDir;
+
+ // PSR-4
+ /**
+ * @var array[]
+ * @psalm-var array>
+ */
+ private $prefixLengthsPsr4 = array();
+ /**
+ * @var array[]
+ * @psalm-var array>
+ */
+ private $prefixDirsPsr4 = array();
+ /**
+ * @var array[]
+ * @psalm-var array
+ */
+ private $fallbackDirsPsr4 = array();
+
+ // PSR-0
+ /**
+ * @var array[]
+ * @psalm-var array>
+ */
+ private $prefixesPsr0 = array();
+ /**
+ * @var array[]
+ * @psalm-var array
+ */
+ private $fallbackDirsPsr0 = array();
+
+ /** @var bool */
+ private $useIncludePath = false;
+
+ /**
+ * @var string[]
+ * @psalm-var array
+ */
+ private $classMap = array();
+
+ /** @var bool */
+ private $classMapAuthoritative = false;
+
+ /**
+ * @var bool[]
+ * @psalm-var array
+ */
+ private $missingClasses = array();
+
+ /** @var ?string */
+ private $apcuPrefix;
+
+ /**
+ * @var self[]
+ */
+ private static $registeredLoaders = array();
+
+ /**
+ * @param ?string $vendorDir
+ */
+ public function __construct($vendorDir = null)
+ {
+ $this->vendorDir = $vendorDir;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getPrefixes()
+ {
+ if (!empty($this->prefixesPsr0)) {
+ return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
+ }
+
+ return array();
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return array>
+ */
+ public function getPrefixesPsr4()
+ {
+ return $this->prefixDirsPsr4;
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return array
+ */
+ public function getFallbackDirs()
+ {
+ return $this->fallbackDirsPsr0;
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return array
+ */
+ public function getFallbackDirsPsr4()
+ {
+ return $this->fallbackDirsPsr4;
+ }
+
+ /**
+ * @return string[] Array of classname => path
+ * @psalm-var array
+ */
+ public function getClassMap()
+ {
+ return $this->classMap;
+ }
+
+ /**
+ * @param string[] $classMap Class to filename map
+ * @psalm-param array $classMap
+ *
+ * @return void
+ */
+ public function addClassMap(array $classMap)
+ {
+ if ($this->classMap) {
+ $this->classMap = array_merge($this->classMap, $classMap);
+ } else {
+ $this->classMap = $classMap;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix, either
+ * appending or prepending to the ones previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param string[]|string $paths The PSR-0 root directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @return void
+ */
+ public function add($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ if ($prepend) {
+ $this->fallbackDirsPsr0 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr0
+ );
+ } else {
+ $this->fallbackDirsPsr0 = array_merge(
+ $this->fallbackDirsPsr0,
+ (array) $paths
+ );
+ }
+
+ return;
+ }
+
+ $first = $prefix[0];
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
+
+ return;
+ }
+ if ($prepend) {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixesPsr0[$first][$prefix]
+ );
+ } else {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $this->prefixesPsr0[$first][$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace, either
+ * appending or prepending to the ones previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param string[]|string $paths The PSR-4 base directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return void
+ */
+ public function addPsr4($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ // Register directories for the root namespace.
+ if ($prepend) {
+ $this->fallbackDirsPsr4 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr4
+ );
+ } else {
+ $this->fallbackDirsPsr4 = array_merge(
+ $this->fallbackDirsPsr4,
+ (array) $paths
+ );
+ }
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
+ // Register directories for a new namespace.
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ } elseif ($prepend) {
+ // Prepend directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixDirsPsr4[$prefix]
+ );
+ } else {
+ // Append directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $this->prefixDirsPsr4[$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix,
+ * replacing any others previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param string[]|string $paths The PSR-0 base directories
+ *
+ * @return void
+ */
+ public function set($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr0 = (array) $paths;
+ } else {
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace,
+ * replacing any others previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param string[]|string $paths The PSR-4 base directories
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return void
+ */
+ public function setPsr4($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr4 = (array) $paths;
+ } else {
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Turns on searching the include path for class files.
+ *
+ * @param bool $useIncludePath
+ *
+ * @return void
+ */
+ public function setUseIncludePath($useIncludePath)
+ {
+ $this->useIncludePath = $useIncludePath;
+ }
+
+ /**
+ * Can be used to check if the autoloader uses the include path to check
+ * for classes.
+ *
+ * @return bool
+ */
+ public function getUseIncludePath()
+ {
+ return $this->useIncludePath;
+ }
+
+ /**
+ * Turns off searching the prefix and fallback directories for classes
+ * that have not been registered with the class map.
+ *
+ * @param bool $classMapAuthoritative
+ *
+ * @return void
+ */
+ public function setClassMapAuthoritative($classMapAuthoritative)
+ {
+ $this->classMapAuthoritative = $classMapAuthoritative;
+ }
+
+ /**
+ * Should class lookup fail if not found in the current class map?
+ *
+ * @return bool
+ */
+ public function isClassMapAuthoritative()
+ {
+ return $this->classMapAuthoritative;
+ }
+
+ /**
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
+ *
+ * @param string|null $apcuPrefix
+ *
+ * @return void
+ */
+ public function setApcuPrefix($apcuPrefix)
+ {
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
+ }
+
+ /**
+ * The APCu prefix in use, or null if APCu caching is not enabled.
+ *
+ * @return string|null
+ */
+ public function getApcuPrefix()
+ {
+ return $this->apcuPrefix;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param bool $prepend Whether to prepend the autoloader or not
+ *
+ * @return void
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+
+ if (null === $this->vendorDir) {
+ return;
+ }
+
+ if ($prepend) {
+ self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
+ } else {
+ unset(self::$registeredLoaders[$this->vendorDir]);
+ self::$registeredLoaders[$this->vendorDir] = $this;
+ }
+ }
+
+ /**
+ * Unregisters this instance as an autoloader.
+ *
+ * @return void
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array($this, 'loadClass'));
+
+ if (null !== $this->vendorDir) {
+ unset(self::$registeredLoaders[$this->vendorDir]);
+ }
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ * @return true|null True if loaded, null otherwise
+ */
+ public function loadClass($class)
+ {
+ if ($file = $this->findFile($class)) {
+ includeFile($file);
+
+ return true;
+ }
+
+ return null;
+ }
+
+ /**
+ * Finds the path to the file where the class is defined.
+ *
+ * @param string $class The name of the class
+ *
+ * @return string|false The path if found, false otherwise
+ */
+ public function findFile($class)
+ {
+ // class map lookup
+ if (isset($this->classMap[$class])) {
+ return $this->classMap[$class];
+ }
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
+ return false;
+ }
+ if (null !== $this->apcuPrefix) {
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
+ if ($hit) {
+ return $file;
+ }
+ }
+
+ $file = $this->findFileWithExtension($class, '.php');
+
+ // Search for Hack files if we are running on HHVM
+ if (false === $file && defined('HHVM_VERSION')) {
+ $file = $this->findFileWithExtension($class, '.hh');
+ }
+
+ if (null !== $this->apcuPrefix) {
+ apcu_add($this->apcuPrefix.$class, $file);
+ }
+
+ if (false === $file) {
+ // Remember that this class does not exist.
+ $this->missingClasses[$class] = true;
+ }
+
+ return $file;
+ }
+
+ /**
+ * Returns the currently registered loaders indexed by their corresponding vendor directories.
+ *
+ * @return self[]
+ */
+ public static function getRegisteredLoaders()
+ {
+ return self::$registeredLoaders;
+ }
+
+ /**
+ * @param string $class
+ * @param string $ext
+ * @return string|false
+ */
+ private function findFileWithExtension($class, $ext)
+ {
+ // PSR-4 lookup
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
+
+ $first = $class[0];
+ if (isset($this->prefixLengthsPsr4[$first])) {
+ $subPath = $class;
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
+ $subPath = substr($subPath, 0, $lastPos);
+ $search = $subPath . '\\';
+ if (isset($this->prefixDirsPsr4[$search])) {
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
+ if (file_exists($file = $dir . $pathEnd)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-4 fallback dirs
+ foreach ($this->fallbackDirsPsr4 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 lookup
+ if (false !== $pos = strrpos($class, '\\')) {
+ // namespaced class name
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
+ } else {
+ // PEAR-like class name
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
+ }
+
+ if (isset($this->prefixesPsr0[$first])) {
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
+ if (0 === strpos($class, $prefix)) {
+ foreach ($dirs as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-0 fallback dirs
+ foreach ($this->fallbackDirsPsr0 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 include paths.
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
+ return $file;
+ }
+
+ return false;
+ }
+}
+
+/**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ *
+ * @param string $file
+ * @return void
+ * @private
+ */
+function includeFile($file)
+{
+ include $file;
+}
diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE
new file mode 100644
index 0000000..f27399a
--- /dev/null
+++ b/vendor/composer/LICENSE
@@ -0,0 +1,21 @@
+
+Copyright (c) Nils Adermann, Jordi Boggiano
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
new file mode 100644
index 0000000..b26f1b1
--- /dev/null
+++ b/vendor/composer/autoload_classmap.php
@@ -0,0 +1,10 @@
+ $vendorDir . '/composer/InstalledVersions.php',
+);
diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php
new file mode 100644
index 0000000..b7fc012
--- /dev/null
+++ b/vendor/composer/autoload_namespaces.php
@@ -0,0 +1,9 @@
+ array($baseDir . '/src'),
+);
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
new file mode 100644
index 0000000..6972b21
--- /dev/null
+++ b/vendor/composer/autoload_real.php
@@ -0,0 +1,55 @@
+= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
+ if ($useStaticLoader) {
+ require __DIR__ . '/autoload_static.php';
+
+ call_user_func(\Composer\Autoload\ComposerStaticInit0c8f6bec90a6d60040a922f19a1f0e64::getInitializer($loader));
+ } else {
+ $map = require __DIR__ . '/autoload_namespaces.php';
+ foreach ($map as $namespace => $path) {
+ $loader->set($namespace, $path);
+ }
+
+ $map = require __DIR__ . '/autoload_psr4.php';
+ foreach ($map as $namespace => $path) {
+ $loader->setPsr4($namespace, $path);
+ }
+
+ $classMap = require __DIR__ . '/autoload_classmap.php';
+ if ($classMap) {
+ $loader->addClassMap($classMap);
+ }
+ }
+
+ $loader->register(true);
+
+ return $loader;
+ }
+}
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
new file mode 100644
index 0000000..8352776
--- /dev/null
+++ b/vendor/composer/autoload_static.php
@@ -0,0 +1,36 @@
+
+ array (
+ 'gullevek\\AmazonIncentives\\' => 26,
+ ),
+ );
+
+ public static $prefixDirsPsr4 = array (
+ 'gullevek\\AmazonIncentives\\' =>
+ array (
+ 0 => __DIR__ . '/../..' . '/src',
+ ),
+ );
+
+ public static $classMap = array (
+ 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
+ );
+
+ public static function getInitializer(ClassLoader $loader)
+ {
+ return \Closure::bind(function () use ($loader) {
+ $loader->prefixLengthsPsr4 = ComposerStaticInit0c8f6bec90a6d60040a922f19a1f0e64::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInit0c8f6bec90a6d60040a922f19a1f0e64::$prefixDirsPsr4;
+ $loader->classMap = ComposerStaticInit0c8f6bec90a6d60040a922f19a1f0e64::$classMap;
+
+ }, null, ClassLoader::class);
+ }
+}