|
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()]]; |
|
|
|
|
|
|
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(), |
|
|
|
|
|
|
32
|
5 |
|
'Content-type' => $this->kernel->getHandler()->getAccept(), |
|
33
|
5 |
|
app(Authentication::class)->getPrefixCSRF() => app(Authentication::class)->getCsrf() |
|
|
|
|
|
|
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', |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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
|
|
|
} |
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.