Passed
Branch 2.0.0 (c5bb78)
by Chubarov
09:06
created

QueryBuilder::debug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.2963

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 18
ccs 4
cts 12
cp 0.3333
crap 1.2963
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace agoalofalife\bpm\Assistants;
3
4
use agoalofalife\bpm\Contracts\Authentication;
5
use GuzzleHttp\TransferStats;
6
use Monolog\Logger;
7
8
trait QueryBuilder
9
{
10
    protected $parameters = [];
11
12 1
    public function getCookie()
13
    {
14 1
        $curl = ['curl' => [ CURLOPT_COOKIEFILE => app(Authentication::class)->getPathCookieFile()]];
0 ignored issues
show
Bug introduced by
The method getPathCookieFile() does not seem to exist on object<Illuminate\Container\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
15 1
        $this->merge($curl);
16 1
        return $this;
17
    }
18
19 1
    public function httpErrorsFalse()
20
    {
21 1
        $errorFalse = ['http_errors' => false];
22 1
        $this->merge($errorFalse);
23 1
        return $this;
24
    }
25
26 1
    public function headers()
27
    {
28
        $headers =
29
        ['headers' => [
30 1
                    'HTTP/1.0',
31 1
                    'Accept'       => $this->kernel->getHandler()->getContentType(),
0 ignored issues
show
Bug introduced by
The property kernel does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
32 1
                    'Content-type' => $this->kernel->getHandler()->getAccept(),
33 1
                    app(Authentication::class)->getPrefixCSRF()     => app(Authentication::class)->getCsrf()
0 ignored issues
show
Bug introduced by
The method getPrefixCSRF() does not seem to exist on object<Illuminate\Container\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method getCsrf() does not seem to exist on object<Illuminate\Container\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34 1
                    ]
35 1
        ];
36 1
        $this->merge($headers);
37 1
        return $this;
38
    }
39
40
    public function debug()
41
    {
42 1
        $debug  = ['on_stats' => function (TransferStats $stats) {
43
            app(Logger::class)->debug('api',
0 ignored issues
show
Bug introduced by
The method debug() does not seem to exist on object<Illuminate\Container\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
                [
45
                    'time'    =>  $stats->getTransferTime(),
46
                    'request' =>
47
                        [
48
                            'header' => $stats->getRequest()->getHeaders(),
49
                            'body'   => $stats->getRequest()->getBody()->getContents(),
50
                            'method' => $stats->getRequest()->getMethod(),
51
                            'url'    => $stats->getRequest()->getUri()
52
                        ]
53
                ]);
54 1
        }];
55 1
        $this->merge($debug);
56 1
        return $this;
57
    }
58
59 2
    public function get()
60
    {
61 2
        return $this->parameters;
62
    }
63
64
    public function body()
65
    {
66
        $body = [
67
            'body' => $this->kernel->getHandler()->create($this->data)
0 ignored issues
show
Bug introduced by
The property data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
68
        ];
69
         $this->merge($body);
70
         return $this;
71
    }
72
73 4
    private function merge(array $newParameters)
74
    {
75 4
        return $this->parameters = array_merge($this->parameters, $newParameters);
76
    }
77
}