Passed
Branch 2.0.0 (b2656d)
by Chubarov
02:44
created

Delete::query()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3.072

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 2
nop 0
dl 0
loc 21
ccs 12
cts 15
cp 0.8
crap 3.072
rs 9.3142
c 0
b 0
f 0
1
<?php
2
namespace agoalofalife\bpm\Actions;
3
4
use agoalofalife\bpm\Assistants\ConstructorUrl;
5
use agoalofalife\bpm\Assistants\QueryBuilder;
6
use agoalofalife\bpm\Contracts\Action;
7
use agoalofalife\bpm\Contracts\ActionGet;
8
use agoalofalife\bpm\KernelBpm;
9
10
/**
11
 * Class Delete
12
 * @property KernelBpm kernel
13
 * @property string HTTP_TYPE
14
 * @property string url
15
 * @property array data
16
 * @package agoalofalife\bpm\Actions
17
 */
18
class Delete implements Action
19
{
20
    use ConstructorUrl, QueryBuilder;
21
22
    protected $kernel;
23
    protected $url = '?';
24
    /**
25
     * Type of Request to delete
26
     * @var string
27
     */
28
    protected $HTTP_TYPE = 'DELETE';
29
30 3
    public function injectionKernel(KernelBpm $bpm)
31
    {
32 3
        $this->kernel = $bpm;
33 3
    }
34
35
    /**
36
     * @return string
37
     */
38 2
    public function getUrl()
39
    {
40 2
        return $this->url;
41
    }
42
43
    /**
44
     * @return \agoalofalife\bpm\Contracts\Handler
45
     */
46 1
    public function processData()
47
    {
48 1
        $this->query();
49 1
        return $this->kernel->getHandler();
50
    }
51
52 1
    private function query()
53
    {
54 1
        $parameters = str_replace(' ', '%20', $this->url);
55
56 1
        $url        = $this->kernel->getCollection() . $parameters;
57 1
        $urlHome    = config($this->kernel->getPrefixConfig() . '.UrlHome');
58
59
60 1
        $response =  $this->kernel->getCurl()->request($this->HTTP_TYPE, $urlHome . $url,
61 1
                     $this->headers()->getCookie()->httpErrorsFalse()->get()
62 1
        );
63
64 1
        $body = $response->getBody();
65 1
        $this->kernel->getHandler()->parse($body->getContents());
0 ignored issues
show
Bug introduced by
The method parse() 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...
66
67 1
        if ( $response->getStatusCode() == 401 && $response->getReasonPhrase() == 'Unauthorized' )
68 1
        {
69
            $this->kernel->authentication();
70
            $this->query();
71
        }
72
    }
73
}