Completed
Pull Request — master (#37)
by Vitaliy
19:06 queued 09:04
created

DebugHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isDebug() 0 4 1
A addDebugOptionsToHttpClient() 0 10 1
1
<?php
2
3
namespace Xsolla\SDK\Tests\Helper;
4
5
use Guzzle\Common\Event;
6
use Guzzle\Http\Client;
7
8
class DebugHelper
9
{
10
    public static function isDebug()
11
    {
12
        return in_array('--debug', $GLOBALS['argv'], true);
13
    }
14
15
    public static function addDebugOptionsToHttpClient(Client $guzzleClient)
16
    {
17
        $guzzleClient->setDefaultOption('debug', true);
18
        $echoCb = function (Event $event) {
19
            echo (string) $event['request'].PHP_EOL;
20
            echo (string) $event['response'].PHP_EOL;
21
        };
22
        $guzzleClient->getEventDispatcher()->addListener('request.complete', $echoCb);
23
        $guzzleClient->getEventDispatcher()->addListener('request.exception', $echoCb);
24
    }
25
}
26