Completed
Push — master ( cff822...7a1dba )
by Ricardo
04:15
created

ReaderPipeline   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 90.32 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 28
loc 31
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 28 28 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
// @todo
3
4
namespace Finder\Pipelines\Application;
5
6
use League\Pipeline\Pipeline;
7
use Operador\Contracts\StageInterface;
8
9
class FolderFound implements StageInterface
10
{
11 View Code Duplication
    public function __invoke($eloquentClasses)
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...
12
    {
13
        return Cache::remember(
14
            'sitec_support_render_database_'.md5(implode('|', $eloquentClasses->values()->all())), 30, function () use ($eloquentClasses) {
15
                Log::debug(
16
                    'Mount Database -> Renderizando'
17
                );
18
                $renderDatabase = (new \Support\Components\Database\Render\Database($eloquentClasses));
19
                return $renderDatabase;
20
            }
21
        );
22
    }
23
}
24
25
// class DatabaseMount implements StageInterface
26
// {
27
28
29
//     public function __invoke($renderDatabaseArray)
30
//     {
31
//         $eloquentClasses =  collect($renderDatabaseArray["Leitoras"]["displayClasses"]);
32
33
34
//         $this->entitys = $eloquentClasses->reject(function($eloquentData, $className) {
35
//             return $this->eloquentHasError($className);
36
//         })->map(function($eloquentData, $className) use ($renderDatabaseArray) {
37
//             return (new EloquentMount($className, $renderDatabaseArray))->getEntity();
38
//         });
39
//     }
40
// }
41
class ReaderPipeline
42
{
43 View Code Duplication
    public function __invoke($eloquentClasses)
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...
44
    {
45
46
        $pipeline = (new Pipeline)
47
            ->pipe(new DatabaseRender)
48
            ->pipe(new DatabaseMount);
49
        
50
        // Returns 21
51
        $entitys = $pipeline->process(10);
0 ignored issues
show
Unused Code introduced by
$entitys is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
52
        
53
        
54
        
55
        // Re-usable Pipelines
56
        // Because the PipelineInterface is an extension of the StageInterface pipelines can be re-used as stages. This creates a highly composable model to create complex execution patterns while keeping the cognitive load low.
57
        
58
        // For example, if we'd want to compose a pipeline to process API calls, we'd create something along these lines:
59
        
60
        $processApiRequest = (new Pipeline)
61
            ->pipe(new ExecuteHttpRequest) // 2
62
            ->pipe(new ParseJsonResponse); // 3
63
            
64
        $pipeline = (new Pipeline)
65
            ->pipe(new ConvertToPsr7Request) // 1
66
            ->pipe($processApiRequest) // (2,3)
67
            ->pipe(new ConvertToResponseDto); // 4 
68
            
69
        $pipeline->process(new DeleteBlogPost($postId));
0 ignored issues
show
Bug introduced by
The variable $postId does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
70
    }
71
}
72