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

RepositoryDetectedPipeline::getPipeline()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
// @todo fazer
3
// rascunho serve ra nada aqui
4
5
namespace Finder\Pipelines\Application;
6
7
use League\Pipeline\Pipeline;
8
use Operador\Contracts\StageInterface;
9
10
class RepositoryDetectedPipeline implements StageInterface
11
{
12 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...
13
    {
14
15
16
17
18
19
20
21
22
        return Cache::remember(
23
            'sitec_support_render_database_'.md5(implode('|', $eloquentClasses->values()->all())), 30, function () use ($eloquentClasses) {
24
                    Log::debug(
25
                        'Mount Database -> Renderizando'
26
                    );
27
                    $renderDatabase = (new \Support\Components\Database\Render\Database($eloquentClasses));
28
                    return $renderDatabase;
29
            }
30
        );
31
    }
32
    public static function getPipeline()
33
    {
34
        return (new Pipeline)
35
             ->pipe(new static);
36
    }
37
    public static function make($eloquentClasses)
38
    {
39
        
40
41
42
        // Returns 21
43
        $entitys = $pipeline->process($eloquentClasses);
0 ignored issues
show
Bug introduced by
The variable $pipeline seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
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...
44
45
46
47
        // Re-usable Pipelines
48
        // 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.
49
50
        // For example, if we'd want to compose a pipeline to process API calls, we'd create something along these lines:
51
52
        $processApiRequest = (new Pipeline)
53
            ->pipe(new ExecuteHttpRequest) // 2
54
            ->pipe(new ParseJsonResponse); // 3
55
            
56
        $pipeline = (new Pipeline)
57
            ->pipe(new ConvertToPsr7Request) // 1
58
            ->pipe($processApiRequest) // (2,3)
59
            ->pipe(new ConvertToResponseDto); // 4 
60
            
61
        $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...
62
    }
63
}