QueryBuilder::getCookie()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 1
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 5
    public function getCookie()
13
    {
14 5
        $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 5
        $this->merge($curl);
16 5
        return $this;
17
    }
18
19 5
    public function httpErrorsFalse()
20
    {
21 5
        $errorFalse = ['http_errors' => false];
22 5
        $this->merge($errorFalse);
23 5
        return $this;
24
    }
25
26 5
    public function headers()
27
    {
28
        $headers =
29
        ['headers' => [
30 5
                    'HTTP/1.0',
31 5
                    '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 5
                    'Content-type' => $this->kernel->getHandler()->getAccept(),
33 5
                    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 5
                    ]
35 5
        ];
36 5
        $this->merge($headers);
37 5
        return $this;
38
    }
39
40
    public function debug()
41
    {
42 3
        $debug  = ['on_stats' => function (TransferStats $stats) {
43 1
            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 1
                    'time'    =>  $stats->getTransferTime(),
46
                    'request' =>
47
                        [
48 1
                            'header' => $stats->getRequest()->getHeaders(),
49 1
                            'body'   => $stats->getRequest()->getBody()->getContents(),
50 1
                            'method' => $stats->getRequest()->getMethod(),
51 1
                            'url'    => $stats->getRequest()->getUri()
52 1
                        ]
53 1
                ]);
54 3
        }];
55 3
        $this->merge($debug);
56 3
        return $this;
57
    }
58
59 7
    public function get()
60
    {
61 7
        return $this->parameters;
62
    }
63
64 2
    public function body()
65
    {
66
        $body = [
67 2
            '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 2
        ];
69 2
         $this->merge($body);
70 2
         return $this;
71
    }
72
73 9
    private function merge(array $newParameters)
74
    {
75 9
        return $this->parameters = array_merge($this->parameters, $newParameters);
76
    }
77
}