Passed
Branch master (e96466)
by Chubarov
03:06
created

Delete   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 32.69 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 17
loc 52
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 4 1
A injectionKernel() 0 4 1
A processData() 0 5 1
A query() 17 17 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 2
    public function injectionKernel(KernelBpm $bpm)
31
    {
32 2
        $this->kernel = $bpm;
33 2
    }
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
}