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

RepositoryPipeline::runTwo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29

Duplication

Lines 29
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 29
loc 29
rs 9.456
c 0
b 0
f 0
1
<?php
2
/**
3
 * Rascunho @todo
4
 */
5
6
namespace Finder\Pipelines\Application;
7
8
use League\Pipeline\Pipeline;
9
use Operador\Contracts\StageInterface;
10
11
class RepositoryPipeline
12
{
13
14
    /**
15
     * Repositorio Detectado
16
     */
17
    public function run($eloquentClasses)
0 ignored issues
show
Unused Code introduced by
The parameter $eloquentClasses is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
    {
19
        
20
21
        $tables = (new Pipeline)
0 ignored issues
show
Unused Code introduced by
$tables 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...
22
            // Retorna Todas as Tabelas
23
            ->pipe(new TablesParser)
24
            // Mapea as Tabelas
25
            ->pipe(new TablesBuilder)
26
            // Builda e Retorna o Entity
27
            ->pipe(new TablesMount);
28
29
        // Returns 21
30
        $entitys = $pipeline->process(10);
0 ignored issues
show
Bug introduced by
The variable $pipeline 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...
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...
31
32
33
34
    }
35 View Code Duplication
    public function runTwo($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...
Unused Code introduced by
The parameter $eloquentClasses is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        
38
39
        $tables = (new Pipeline)
0 ignored issues
show
Unused Code introduced by
$tables 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...
40
            ->pipe(new DatabaseRender)
41
            ->pipe(new DatabaseMount);
42
43
        // Returns 21
44
        $entitys = $pipeline->process(10);
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...
45
46
47
48
        // Re-usable Pipelines
49
        // 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.
50
51
        // For example, if we'd want to compose a pipeline to process API calls, we'd create something along these lines:
52
53
        $databaseEntity = (new Pipeline)
0 ignored issues
show
Unused Code introduced by
$databaseEntity 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...
54
            ->pipe(new ExecuteHttpRequest) // 2
55
            ->pipe(new ParseJsonResponse); // 3
56
            
57
        $pipeline = (new Pipeline)
58
            ->pipe(new ConvertToPsr7Request) // 1
59
            ->pipe($processApiRequest) // (2,3)
0 ignored issues
show
Bug introduced by
The variable $processApiRequest 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...
60
            ->pipe(new ConvertToResponseDto); // 4 
61
            
62
        $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...
63
    }
64
}