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

Update   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 18.42 %

Coupling/Cohesion

Components 2
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 14
loc 76
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 2
cbo 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 4 1
A setData() 0 4 1
A getData() 0 4 1
A injectionKernel() 0 4 1
A processData() 0 5 1
A query() 14 14 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\Contracts\ActionGet;
9
use agoalofalife\bpm\Contracts\ActionSet;
10
use agoalofalife\bpm\KernelBpm;
11
12
/**
13
 * Class Update
14
 * @property KernelBpm kernel
15
 * @property string HTTP_TYPE
16
 * @property array data
17
 * @property string url
18
 * @package agoalofalife\bpm\Actions
19
 */
20
class Update implements Action, ActionGet, ActionSet
21
{
22
    use ConstructorUrl, QueryBuilder, AuthenticationHelper;
23
24
    protected $url = '?';
25
26
    /**
27
     * Request type to created
28
     * @var string
29
     */
30
    protected $HTTP_TYPE = 'PUT';
31
    protected $data = [];
32
    protected $kernel;
33
34
    /**
35
     * @param KernelBpm $bpm
36
     * @return void
37
     */
38 1
    public function injectionKernel(KernelBpm $bpm)
39
    {
40 1
        $this->kernel = $bpm;
41 1
    }
42
43
    /**
44
     * @return string
45
     */
46 2
    public function getUrl()
47
    {
48 2
        return $this->url;
49
    }
50
51
    /**
52
     * @param array $data
53
     * @return array
54
     */
55 2
    public function setData(array $data)
56
    {
57 2
        return $this->data = $data;
58
    }
59
60
    /**
61
     * @return \agoalofalife\bpm\Contracts\Handler
62
     */
63 1
    public function processData()
64
    {
65 1
        $this->query();
66 1
        return $this->kernel->getHandler();
67
    }
68
69
    /**
70
     * @return array
71
     */
72 1
    public function getData()
73
    {
74 1
        return $this->data;
75
    }
76
77
    /**
78
     * @return mixed
79
     */
80 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...
81
    {
82 1
        $parameters = str_replace(' ', '%20', $this->url);
83 1
        $url        = $this->kernel->getCollection() . $parameters;
84 1
        $urlHome    = config($this->kernel->getPrefixConfig() . '.UrlHome');
85
86 1
        $response   =  $this->kernel->getCurl()->request($this->HTTP_TYPE, $urlHome . $url,
87 1
                       $this->headers()->getCookie()->body()->httpErrorsFalse()->get()
88 1
        );
89 1
        $body       = $response->getBody();
90
91 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...
92 1
        $this->checkResponseUnauthorized($response);
93 1
    }
94
95
}