for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Xsolla\SDK\Tests\Helper;
use Guzzle\Common\Event;
use Guzzle\Http\Client;
class DebugHelper
{
public static function isDebug()
global $argv;
global
Instead of relying on global state, we recommend one of these alternatives:
function myFunction($a, $b) { // Do something }
class MyClass { private $a; private $b; public function __construct($a, $b) { $this->a = $a; $this->b = $b; } public function myFunction() { // Do something } }
return in_array('--debug', $argv, true);
}
public static function addDebugOptionsToHttpClient(Client $guzzleClient)
$guzzleClient->setDefaultOption('debug', true);
$echoCb = function (Event $event) {
echo (string) $event['request'].PHP_EOL;
echo (string) $event['response'].PHP_EOL;
};
$guzzleClient->getEventDispatcher()->addListener('request.complete', $echoCb);
$guzzleClient->getEventDispatcher()->addListener('request.exception', $echoCb);
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state