]> git.mxchange.org Git - core.git/blobdiff - framework/main/third_party/api/wernisportal/class_WernisApi.php
Continued:
[core.git] / framework / main / third_party / api / wernisportal / class_WernisApi.php
index aa251029855fcbd6090129f3b9b700bc5ae1ae8b..e8dd99d78294075dc878bc438f04b462a5e62881 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Wds66\Api;
+namespace Com\Wds66\Api;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
@@ -82,18 +82,21 @@ class WernisApi extends BaseFrameworkSystem {
        /**
         * Creates an instance of this API class
         *
-        * @param       $cfg                    Configuration array
+        * @param       $configArray                    Configuration array
         * @return      $apiInstance    An instance of this API class
         */
-       public static final function createWernisApi (array $cfg) {
+       public static final function createWernisApi (array $configArray) {
                // Create a new instance
                $apiInstance = new WernisApi();
 
-               // Fix missing
-               if (!isset($cfg['api_url'])) $cfg['api_url'] = self::$apiUrl;
+               // If not an api_url is given (e.g. on local development system)
+               if (!isset($configArray['api_url'])) {
+                       // ... then set the productive URL
+                       $configArray['api_url'] = self::$apiUrl;
+               }
 
                // Konfiguration uebertragen
-               $apiInstance->setCoonfigArray($cfg);
+               $apiInstance->setCoonfigArray($configArray);
 
                // Return the instance
                return $apiInstance;
@@ -106,7 +109,7 @@ class WernisApi extends BaseFrameworkSystem {
         * @param       $w_pwd  Clear password of the gamer
         * @return      void
         */
-       public function setUser ($w_id, $w_pwd) {
+       public function setUser (int $w_id, string $w_pwd) {
                // Set username (id)
                $this->w_id = $w_id;
 
@@ -118,10 +121,8 @@ class WernisApi extends BaseFrameworkSystem {
         * The following methods are not yet rewritten! *
         ************************************************/
 
-       public function einziehen ($amount) {
+       public function einziehen (int $amount) {
                // amount auf Gueltigkeit pruefen
-               $amount = isset($amount) ? $amount+0 : 0;
-
                if ($amount < $this->config['mineinsatz']) {
                        $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz']));
                        return false;
@@ -131,10 +132,8 @@ class WernisApi extends BaseFrameworkSystem {
                return $this->executeWithdraw($amount);
        }
 
-       public function verschicken ($amount) {
+       public function verschicken (int $amount) {
                // amount auf Gueltigkeit pruefen
-               $amount = isset($amount) ? $amount+0 : 0;
-
                if ($amount < $this->config['mineinsatz']) {
                        $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz']));
                        return false;
@@ -159,7 +158,7 @@ class WernisApi extends BaseFrameworkSystem {
        }
 
        // Sets a status message and code
-       public function setStatusMessage ($msg, $status) {
+       public function setStatusMessage (string $msg, string $status) {
                $this->statusArray['message'] = $msg;
                $this->statusArray['status'] = $status;
        }
@@ -187,7 +186,7 @@ class WernisApi extends BaseFrameworkSystem {
        }
 
        // Sends out a request to the API and returns it's result
-       private function sendRequest ($scriptName, array $requestData = array()) {
+       private function sendRequest (string $scriptName, array $requestData = []) {
                // Is the requestData an array?
                if (!is_array($requestData)) {
                        // Then abort here!
@@ -307,7 +306,7 @@ class WernisApi extends BaseFrameworkSystem {
        }
 
        // Widthdraw this amount
-       private function executeWithdraw ($amount) {
+       private function executeWithdraw (int $amount) {
                // First all fails...
                $result = false;
 
@@ -340,7 +339,7 @@ class WernisApi extends BaseFrameworkSystem {
        }
 
        // Payout this amount
-       private function executePayout ($amount) {
+       private function executePayout (int $amount) {
                // First all fails...
                $result = false;
 
@@ -373,7 +372,7 @@ class WernisApi extends BaseFrameworkSystem {
        }
 
        // Send raw GET request
-       private function sendRawRequest ($script) {
+       private function sendRawRequest (string $script) {
                // Use the hostname from script URL as new hostname
                $url = substr($script, 7);
                $extract = explode('/', $url);