Passed
Branch 2.0.0 (2e9c5e)
by Chubarov
02:56
created

Delete::query()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 9

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 17
loc 17
ccs 11
cts 11
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace agoalofalife\bpm\Actions;
3
4
use agoalofalife\bpm\Assistants\AuthenticationHelper;
5
use agoalofalife\bpm\Assistants\ConstructorUrl;
6
use agoalofalife\bpm\Assistants\QueryBuilder;
7
use agoalofalife\bpm\Contracts\Action;
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, AuthenticationHelper;
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 View Code Duplication
    private function query()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
        $this->checkResponseUnauthorized($response);
68
    }
69
}