@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | private function getPagantisOrderId() |
| 208 | 208 | { |
| 209 | 209 | try { |
| 210 | - $this->pagantisOrderId= Db::getInstance()->getValue( |
|
| 210 | + $this->pagantisOrderId = Db::getInstance()->getValue( |
|
| 211 | 211 | 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.$this->merchantOrderId |
| 212 | 212 | ); |
| 213 | 213 | |
@@ -269,20 +269,20 @@ discard block |
||
| 269 | 269 | $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0]; |
| 270 | 270 | if ($totalAmount != $merchantAmount) { |
| 271 | 271 | try { |
| 272 | - $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0); |
|
| 272 | + $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0); |
|
| 273 | 273 | |
| 274 | 274 | $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 275 | 275 | $pgTotalAmount = substr_replace( |
| 276 | 276 | $pgTotalAmountInCents, |
| 277 | 277 | '.', |
| 278 | - (Tools::strlen($pgTotalAmountInCents) -2), |
|
| 278 | + (Tools::strlen($pgTotalAmountInCents) - 2), |
|
| 279 | 279 | 0 |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId . |
|
| 283 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . |
|
| 284 | - '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . |
|
| 285 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; |
|
| 282 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId. |
|
| 283 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. |
|
| 284 | + '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. |
|
| 285 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; |
|
| 286 | 286 | $this->saveLog(array( |
| 287 | 287 | 'message' => $this->amountMismatchError |
| 288 | 288 | )); |
@@ -302,20 +302,20 @@ discard block |
||
| 302 | 302 | try { |
| 303 | 303 | if ($this->merchantOrder->orderExists() !== false) { |
| 304 | 304 | throw new WrongStatusException('PS->orderExists() cart_id = ' |
| 305 | - . $this->merchantOrderId . ' pagantis_id = ' |
|
| 306 | - . $this->pagantisOrderId . '): already_processed'); |
|
| 305 | + . $this->merchantOrderId.' pagantis_id = ' |
|
| 306 | + . $this->pagantisOrderId.'): already_processed'); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // Double check |
| 310 | - $tableName = _DB_PREFIX_ . 'pagantis_order'; |
|
| 311 | - $sql = ('select ps_order_id from `' . $tableName . '` where `id` = ' . $this->merchantOrderId |
|
| 312 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' |
|
| 310 | + $tableName = _DB_PREFIX_.'pagantis_order'; |
|
| 311 | + $sql = ('select ps_order_id from `'.$tableName.'` where `id` = '.$this->merchantOrderId |
|
| 312 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' |
|
| 313 | 313 | . ' and `ps_order_id` is not null'); |
| 314 | 314 | $results = Db::getInstance()->ExecuteS($sql); |
| 315 | 315 | if (is_array($results) && count($results) === 1) { |
| 316 | - throw new WrongStatusException('PS->record found in ' . $tableName |
|
| 317 | - . ' (cart_id = ' . $this->merchantOrderId . ' pagantis_id = ' |
|
| 318 | - . $this->pagantisOrderId . '): already_processed'); |
|
| 316 | + throw new WrongStatusException('PS->record found in '.$tableName |
|
| 317 | + . ' (cart_id = '.$this->merchantOrderId.' pagantis_id = ' |
|
| 318 | + . $this->pagantisOrderId.'): already_processed'); |
|
| 319 | 319 | } |
| 320 | 320 | } catch (\Exception $exception) { |
| 321 | 321 | throw new UnknownException($exception->getMessage()); |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | Configuration::get('PS_OS_PAYMENT'), |
| 345 | 345 | $this->merchantOrder->getOrderTotal(true), |
| 346 | 346 | $this->module->displayName, |
| 347 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . |
|
| 348 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . |
|
| 349 | - $this->amountMismatchError . |
|
| 347 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. |
|
| 348 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). |
|
| 349 | + $this->amountMismatchError. |
|
| 350 | 350 | $metadataInfo, |
| 351 | 351 | array('transaction_id' => $this->pagantisOrderId), |
| 352 | 352 | null, |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | Db::getInstance()->update( |
| 361 | 361 | 'pagantis_order', |
| 362 | 362 | array('ps_order_id' => $this->module->currentOrder), |
| 363 | - 'id = \''. $this->merchantOrderId . '\' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
| 363 | + 'id = \''.$this->merchantOrderId.'\' and order_id = \''.$this->pagantisOrderId.'\'' |
|
| 364 | 364 | ); |
| 365 | 365 | } catch (\Exception $exception) { |
| 366 | 366 | // Do nothing |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 379 | 379 | try { |
| 380 | 380 | $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION'; |
| 381 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . |
|
| 382 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
| 383 | - '. Prestashop OrderId=' . $this->module->currentOrder; |
|
| 381 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. |
|
| 382 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
| 383 | + '. Prestashop OrderId='.$this->module->currentOrder; |
|
| 384 | 384 | $this->saveLog(array( |
| 385 | 385 | 'message' => $message |
| 386 | 386 | )); |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | ); |
| 428 | 428 | $resultSeconds = Db::getInstance()->getValue($query); |
| 429 | 429 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
| 430 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 430 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 431 | 431 | |
| 432 | 432 | $logMessage = sprintf( |
| 433 | 433 | "Redirect concurrency, User have to wait %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | $this->saveLog(array( |
| 440 | 440 | 'message' => $logMessage |
| 441 | 441 | )); |
| 442 | - sleep($secondsToExpire+1); |
|
| 442 | + sleep($secondsToExpire + 1); |
|
| 443 | 443 | // After waiting...user continue the confirmation, hoping that previous call have finished. |
| 444 | 444 | return true; |
| 445 | 445 | } |
@@ -456,12 +456,12 @@ discard block |
||
| 456 | 456 | if (is_null($orderId)) { |
| 457 | 457 | Db::getInstance()->delete( |
| 458 | 458 | 'pagantis_cart_process', |
| 459 | - 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT |
|
| 459 | + 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT |
|
| 460 | 460 | ) |
| 461 | 461 | ); |
| 462 | 462 | return; |
| 463 | 463 | } |
| 464 | - Db::getInstance()->delete('pagantis_cart_process', 'id = \'' . $orderId . '\''); |
|
| 464 | + Db::getInstance()->delete('pagantis_cart_process', 'id = \''.$orderId.'\''); |
|
| 465 | 465 | } catch (\Exception $exception) { |
| 466 | 466 | throw new ConcurrencyException(); |
| 467 | 467 | } |
@@ -483,8 +483,8 @@ discard block |
||
| 483 | 483 | $data = array( |
| 484 | 484 | 'merchantOrderId' => $this->merchantOrderId, |
| 485 | 485 | 'pagantisOrderId' => $this->pagantisOrderId, |
| 486 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
| 487 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 486 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
| 487 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 488 | 488 | 'method' => $method, |
| 489 | 489 | 'file' => __FILE__, |
| 490 | 490 | 'line' => $line, |
@@ -508,9 +508,9 @@ discard block |
||
| 508 | 508 | 'id_cart' => $this->merchantOrderId, |
| 509 | 509 | 'key' => $this->config['secureKey'], |
| 510 | 510 | 'id_module' => $this->module->id, |
| 511 | - 'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null, |
|
| 511 | + 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
|
| 512 | 512 | ); |
| 513 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 513 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 514 | 514 | return $this->redirect($url, $parameters); |
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require(__DIR__ . '/src/Httpful/Bootstrap.php'); |
|
| 3 | +require(__DIR__.'/src/Httpful/Bootstrap.php'); |
|
| 4 | 4 | \Httpful\Bootstrap::init(); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Httpful\Test; |
| 11 | 11 | |
| 12 | -require(dirname(dirname(dirname(__FILE__))) . '/bootstrap.php'); |
|
| 12 | +require(dirname(dirname(dirname(__FILE__))).'/bootstrap.php'); |
|
| 13 | 13 | \Httpful\Bootstrap::init(); |
| 14 | 14 | |
| 15 | 15 | use Httpful\Httpful; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | use Httpful\Response; |
| 20 | 20 | use Httpful\Handlers\JsonHandler; |
| 21 | 21 | |
| 22 | -define('TEST_SERVER', WEB_SERVER_HOST . ':' . WEB_SERVER_PORT); |
|
| 22 | +define('TEST_SERVER', WEB_SERVER_HOST.':'.WEB_SERVER_PORT); |
|
| 23 | 23 | |
| 24 | 24 | class HttpfulTest extends \PHPUnit_Framework_TestCase |
| 25 | 25 | { |
@@ -101,21 +101,21 @@ discard block |
||
| 101 | 101 | function testShortMime() |
| 102 | 102 | { |
| 103 | 103 | // Valid short ones |
| 104 | - $this->assertEquals(Mime::JSON, Mime::getFullMime('json')); |
|
| 105 | - $this->assertEquals(Mime::XML, Mime::getFullMime('xml')); |
|
| 106 | - $this->assertEquals(Mime::HTML, Mime::getFullMime('html')); |
|
| 107 | - $this->assertEquals(Mime::CSV, Mime::getFullMime('csv')); |
|
| 108 | - $this->assertEquals(Mime::UPLOAD, Mime::getFullMime('upload')); |
|
| 104 | + $this->assertEquals(Mime::JSON, Mime::getFullMime('json')); |
|
| 105 | + $this->assertEquals(Mime::XML, Mime::getFullMime('xml')); |
|
| 106 | + $this->assertEquals(Mime::HTML, Mime::getFullMime('html')); |
|
| 107 | + $this->assertEquals(Mime::CSV, Mime::getFullMime('csv')); |
|
| 108 | + $this->assertEquals(Mime::UPLOAD, Mime::getFullMime('upload')); |
|
| 109 | 109 | |
| 110 | 110 | // Valid long ones |
| 111 | 111 | $this->assertEquals(Mime::JSON, Mime::getFullMime(Mime::JSON)); |
| 112 | - $this->assertEquals(Mime::XML, Mime::getFullMime(Mime::XML)); |
|
| 112 | + $this->assertEquals(Mime::XML, Mime::getFullMime(Mime::XML)); |
|
| 113 | 113 | $this->assertEquals(Mime::HTML, Mime::getFullMime(Mime::HTML)); |
| 114 | 114 | $this->assertEquals(Mime::CSV, Mime::getFullMime(Mime::CSV)); |
| 115 | 115 | $this->assertEquals(Mime::UPLOAD, Mime::getFullMime(Mime::UPLOAD)); |
| 116 | 116 | |
| 117 | 117 | // No false positives |
| 118 | - $this->assertNotEquals(Mime::XML, Mime::getFullMime(Mime::HTML)); |
|
| 118 | + $this->assertNotEquals(Mime::XML, Mime::getFullMime(Mime::HTML)); |
|
| 119 | 119 | $this->assertNotEquals(Mime::JSON, Mime::getFullMime(Mime::XML)); |
| 120 | 120 | $this->assertNotEquals(Mime::HTML, Mime::getFullMime(Mime::JSON)); |
| 121 | 121 | $this->assertNotEquals(Mime::XML, Mime::getFullMime(Mime::CSV)); |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | $this->assertEquals("object", gettype($sxe)); |
| 277 | 277 | $this->assertEquals("SimpleXMLElement", get_class($sxe)); |
| 278 | 278 | $bools = $sxe->xpath('/stdClass/boolProp'); |
| 279 | - list( , $bool ) = each($bools); |
|
| 279 | + list(, $bool) = each($bools); |
|
| 280 | 280 | $this->assertEquals("TRUE", (string) $bool); |
| 281 | 281 | $ints = $sxe->xpath('/stdClass/arrayProp/array/k1/myClass/intProp'); |
| 282 | - list( , $int ) = each($ints); |
|
| 282 | + list(, $int) = each($ints); |
|
| 283 | 283 | $this->assertEquals("2", (string) $int); |
| 284 | 284 | $strings = $sxe->xpath('/stdClass/stringProp'); |
| 285 | - list( , $string ) = each($strings); |
|
| 285 | + list(, $string) = each($strings); |
|
| 286 | 286 | $this->assertEquals("a string", (string) $string); |
| 287 | 287 | } |
| 288 | 288 | |
@@ -322,14 +322,14 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | function testAttach() { |
| 324 | 324 | $req = Request::init(); |
| 325 | - $testsPath = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..'); |
|
| 326 | - $filename = $testsPath . DIRECTORY_SEPARATOR . 'test_image.jpg'; |
|
| 325 | + $testsPath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'); |
|
| 326 | + $filename = $testsPath.DIRECTORY_SEPARATOR.'test_image.jpg'; |
|
| 327 | 327 | $req->attach(array('index' => $filename)); |
| 328 | 328 | $payload = $req->payload['index']; |
| 329 | 329 | // PHP 5.5 + will take advantage of CURLFile while previous |
| 330 | 330 | // versions just use the string syntax |
| 331 | 331 | if (is_string($payload)) { |
| 332 | - $this->assertEquals($payload, '@' . $filename . ';type=image/jpeg'); |
|
| 332 | + $this->assertEquals($payload, '@'.$filename.';type=image/jpeg'); |
|
| 333 | 333 | } else { |
| 334 | 334 | $this->assertInstanceOf('CURLFile', $payload); |
| 335 | 335 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | try { |
| 420 | 420 | Request::get('malformed://url') |
| 421 | - ->beforeSend(function($request) use(&$invoked,$self) { |
|
| 421 | + ->beforeSend(function($request) use(&$invoked, $self) { |
|
| 422 | 422 | $self->assertEquals('malformed://url', $request->uri); |
| 423 | 423 | $self->assertEquals('A payload', $request->serialized_payload); |
| 424 | 424 | $request->uri('malformed2://url'); |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | { |
| 449 | 449 | $req = Request::init()->sendsAndExpects(Mime::JSON); |
| 450 | 450 | $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req); |
| 451 | - $this->assertEquals(self::SAMPLE_JSON_RESPONSE, (string)$response); |
|
| 451 | + $this->assertEquals(self::SAMPLE_JSON_RESPONSE, (string) $response); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | function test_parseHeaders() |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | try { |
| 572 | 572 | $result = $handler->parse('invalid{json'); |
| 573 | - } catch(\Exception $e) { |
|
| 573 | + } catch (\Exception $e) { |
|
| 574 | 574 | $this->assertEquals('Unable to parse response as JSON', $e->getMessage()); |
| 575 | 575 | return; |
| 576 | 576 | } |
@@ -26,12 +26,12 @@ |
||
| 26 | 26 | $server_logs = file_get_contents("./server.log"); |
| 27 | 27 | if (strpos($server_logs, "Fail") !== false) { |
| 28 | 28 | // server failed to start for some reason |
| 29 | - print "Failed to start server! Logs:" . PHP_EOL . PHP_EOL; |
|
| 29 | + print "Failed to start server! Logs:".PHP_EOL.PHP_EOL; |
|
| 30 | 30 | print_r($server_logs); |
| 31 | 31 | exit(1); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - echo sprintf('%s - Web server started on %s:%d with PID %d', date('r'), WEB_SERVER_HOST, WEB_SERVER_PORT, $pid) . PHP_EOL; |
|
| 34 | + echo sprintf('%s - Web server started on %s:%d with PID %d', date('r'), WEB_SERVER_HOST, WEB_SERVER_PORT, $pid).PHP_EOL; |
|
| 35 | 35 | |
| 36 | 36 | register_shutdown_function(function() { |
| 37 | 37 | // cleanup after ourselves -- remove log file, shut down server |
@@ -43,12 +43,12 @@ |
||
| 43 | 43 | |
| 44 | 44 | protected function stripBom($body) |
| 45 | 45 | { |
| 46 | - if ( substr($body,0,3) === "\xef\xbb\xbf" ) // UTF-8 |
|
| 47 | - $body = substr($body,3); |
|
| 48 | - else if ( substr($body,0,4) === "\xff\xfe\x00\x00" || substr($body,0,4) === "\x00\x00\xfe\xff" ) // UTF-32 |
|
| 49 | - $body = substr($body,4); |
|
| 50 | - else if ( substr($body,0,2) === "\xff\xfe" || substr($body,0,2) === "\xfe\xff" ) // UTF-16 |
|
| 51 | - $body = substr($body,2); |
|
| 46 | + if (substr($body, 0, 3) === "\xef\xbb\xbf") // UTF-8 |
|
| 47 | + $body = substr($body, 3); |
|
| 48 | + else if (substr($body, 0, 4) === "\xff\xfe\x00\x00" || substr($body, 0, 4) === "\x00\x00\xfe\xff") // UTF-32 |
|
| 49 | + $body = substr($body, 4); |
|
| 50 | + else if (substr($body, 0, 2) === "\xff\xfe" || substr($body, 0, 2) === "\xfe\xff") // UTF-16 |
|
| 51 | + $body = substr($body, 2); |
|
| 52 | 52 | return $body; |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | return null; |
| 20 | 20 | |
| 21 | 21 | $parsed = array(); |
| 22 | - $fp = fopen('data://text/plain;base64,' . base64_encode($body), 'r'); |
|
| 22 | + $fp = fopen('data://text/plain;base64,'.base64_encode($body), 'r'); |
|
| 23 | 23 | while (($r = fgetcsv($fp)) !== FALSE) { |
| 24 | 24 | $parsed[] = $r; |
| 25 | 25 | } |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function serialize($payload) |
| 37 | 37 | { |
| 38 | - $fp = fopen('php://temp/maxmemory:'. (6*1024*1024), 'r+'); |
|
| 38 | + $fp = fopen('php://temp/maxmemory:'.(6 * 1024 * 1024), 'r+'); |
|
| 39 | 39 | $i = 0; |
| 40 | 40 | foreach ($payload as $fields) { |
| 41 | - if($i++ == 0) { |
|
| 41 | + if ($i++ == 0) { |
|
| 42 | 42 | fputcsv($fp, array_keys($fields)); |
| 43 | 43 | } |
| 44 | 44 | fputcsv($fp, $fields); |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function __construct(array $conf = array()) |
| 27 | 27 | { |
| 28 | - $this->namespace = isset($conf['namespace']) ? $conf['namespace'] : ''; |
|
| 29 | - $this->libxml_opts = isset($conf['libxml_opts']) ? $conf['libxml_opts'] : 0; |
|
| 28 | + $this->namespace = isset($conf['namespace']) ? $conf['namespace'] : ''; |
|
| 29 | + $this->libxml_opts = isset($conf['libxml_opts']) ? $conf['libxml_opts'] : 0; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | $xml = new \XMLWriter; |
| 67 | 67 | $xml->openMemory(); |
| 68 | - $xml->startDocument('1.0','ISO-8859-1'); |
|
| 68 | + $xml->startDocument('1.0', 'ISO-8859-1'); |
|
| 69 | 69 | $this->serialize_node($xml, $payload); |
| 70 | 70 | return $xml->outputMemory(true); |
| 71 | 71 | } |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | * @param mixed $node to serialize |
| 76 | 76 | * @author Ted Zellers |
| 77 | 77 | */ |
| 78 | - public function serialize_node(&$xmlw, $node){ |
|
| 79 | - if (!is_array($node)){ |
|
| 78 | + public function serialize_node(&$xmlw, $node) { |
|
| 79 | + if (!is_array($node)) { |
|
| 80 | 80 | $xmlw->text($node); |
| 81 | 81 | } else { |
| 82 | - foreach ($node as $k => $v){ |
|
| 82 | + foreach ($node as $k => $v) { |
|
| 83 | 83 | $xmlw->startElement($k); |
| 84 | 84 | $this->serialize_node($xmlw, $v); |
| 85 | 85 | $xmlw->endElement(); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $node->appendChild($arrNode); |
| 113 | 113 | $this->_future_serializeArrayAsXml($value, $arrNode, $dom); |
| 114 | 114 | } else if (is_bool($value)) { |
| 115 | - $node->appendChild($dom->createTextNode($value?'TRUE':'FALSE')); |
|
| 115 | + $node->appendChild($dom->createTextNode($value ? 'TRUE' : 'FALSE')); |
|
| 116 | 116 | } else { |
| 117 | 117 | $node->appendChild($dom->createTextNode($value)); |
| 118 | 118 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $this->_interpretHeaders(); |
| 45 | 45 | |
| 46 | - $this->body = $this->_parse($body); |
|
| 46 | + $this->body = $this->_parse($body); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | // If a header appears more than once, it must also be able to |
| 128 | 128 | // be represented as a single header with a comma-separated |
| 129 | 129 | // list of values. We transform accordingly. |
| 130 | - $parse_headers[$key] .= ',' . $value; |
|
| 130 | + $parse_headers[$key] .= ','.$value; |
|
| 131 | 131 | } else { |
| 132 | 132 | $parse_headers[$key] = $value; |
| 133 | 133 | } |
@@ -389,9 +389,9 @@ discard block |
||
| 389 | 389 | if (function_exists('curl_file_create')) { |
| 390 | 390 | $this->payload[$key] = curl_file_create($file, $mimeType); |
| 391 | 391 | } else { |
| 392 | - $this->payload[$key] = '@' . $file; |
|
| 392 | + $this->payload[$key] = '@'.$file; |
|
| 393 | 393 | if ($mimeType) { |
| 394 | - $this->payload[$key] .= ';type=' . $mimeType; |
|
| 394 | + $this->payload[$key] .= ';type='.$mimeType; |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | public function contentType($mime) |
| 407 | 407 | { |
| 408 | 408 | if (empty($mime)) return $this; |
| 409 | - $this->content_type = Mime::getFullMime($mime); |
|
| 409 | + $this->content_type = Mime::getFullMime($mime); |
|
| 410 | 410 | if ($this->isUpload()) { |
| 411 | 411 | $this->neverSerializePayload(); |
| 412 | 412 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | { |
| 456 | 456 | $this->addOnCurlOption(CURLOPT_PROXY, "{$proxy_host}:{$proxy_port}"); |
| 457 | 457 | $this->addOnCurlOption(CURLOPT_PROXYTYPE, $proxy_type); |
| 458 | - if (in_array($auth_type, array(CURLAUTH_BASIC,CURLAUTH_NTLM))) { |
|
| 458 | + if (in_array($auth_type, array(CURLAUTH_BASIC, CURLAUTH_NTLM))) { |
|
| 459 | 459 | $this->addOnCurlOption(CURLOPT_PROXYAUTH, $auth_type) |
| 460 | 460 | ->addOnCurlOption(CURLOPT_PROXYUSERPWD, "{$auth_username}:{$auth_password}"); |
| 461 | 461 | } |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | if ($this->hasBasicAuth()) { |
| 851 | - curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password); |
|
| 851 | + curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this->password); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | if ($this->hasClientSideCert()) { |
@@ -859,11 +859,11 @@ discard block |
||
| 859 | 859 | if (!file_exists($this->client_cert)) |
| 860 | 860 | throw new \Exception('Could not read Client Certificate'); |
| 861 | 861 | |
| 862 | - curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding); |
|
| 863 | - curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding); |
|
| 864 | - curl_setopt($ch, CURLOPT_SSLCERT, $this->client_cert); |
|
| 865 | - curl_setopt($ch, CURLOPT_SSLKEY, $this->client_key); |
|
| 866 | - curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->client_passphrase); |
|
| 862 | + curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding); |
|
| 863 | + curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding); |
|
| 864 | + curl_setopt($ch, CURLOPT_SSLCERT, $this->client_cert); |
|
| 865 | + curl_setopt($ch, CURLOPT_SSLKEY, $this->client_key); |
|
| 866 | + curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->client_passphrase); |
|
| 867 | 867 | // curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $this->client_cert_passphrase); |
| 868 | 868 | } |
| 869 | 869 | |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | */ |
| 984 | 984 | public function buildUserAgent() |
| 985 | 985 | { |
| 986 | - $user_agent = 'User-Agent: Httpful/' . Httpful::VERSION . ' (cURL/'; |
|
| 986 | + $user_agent = 'User-Agent: Httpful/'.Httpful::VERSION.' (cURL/'; |
|
| 987 | 987 | $curl = \curl_version(); |
| 988 | 988 | |
| 989 | 989 | if (isset($curl['version'])) { |
@@ -992,10 +992,10 @@ discard block |
||
| 992 | 992 | $user_agent .= '?.?.?'; |
| 993 | 993 | } |
| 994 | 994 | |
| 995 | - $user_agent .= ' PHP/'. PHP_VERSION . ' (' . PHP_OS . ')'; |
|
| 995 | + $user_agent .= ' PHP/'.PHP_VERSION.' ('.PHP_OS.')'; |
|
| 996 | 996 | |
| 997 | 997 | if (isset($_SERVER['SERVER_SOFTWARE'])) { |
| 998 | - $user_agent .= ' ' . \preg_replace('~PHP/[\d\.]+~U', '', |
|
| 998 | + $user_agent .= ' '.\preg_replace('~PHP/[\d\.]+~U', '', |
|
| 999 | 999 | $_SERVER['SERVER_SOFTWARE']); |
| 1000 | 1000 | } else { |
| 1001 | 1001 | if (isset($_SERVER['TERM_PROGRAM'])) { |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | if ($curlErrorNumber = curl_errno($this->_ch)) { |
| 1026 | 1026 | $curlErrorString = curl_error($this->_ch); |
| 1027 | 1027 | $this->_error($curlErrorString); |
| 1028 | - throw new ConnectionErrorException('Unable to connect to "'.$this->uri.'": ' . $curlErrorNumber . ' ' . $curlErrorString); |
|
| 1028 | + throw new ConnectionErrorException('Unable to connect to "'.$this->uri.'": '.$curlErrorNumber.' '.$curlErrorString); |
|
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | $this->_error('Unable to connect to "'.$this->uri.'".'); |