QueryBuilder   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 70
ccs 38
cts 38
cp 1
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 2

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getCookie() 0 6 1
A httpErrorsFalse() 0 6 1
A headers() 0 13 1
A debug() 0 18 1
A get() 0 4 1
A body() 0 8 1
A merge() 0 4 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
}