Repository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 25 2
1
<?php
2
3
namespace Finder\Pipelines\Finder;
4
5
use Operador\Contracts\Stage as StageBase;
6
use Fabrica\Models\Code\Commit;
7
use Illuminate\Support\Collection;
8
use Fabrica\Helps\Git\GitRepo;
9
10
class Repository extends StageBase
11
{
12
    public function __invoke($payload)
13
    {
14
        $this->info('Analisando Repository: '.$payload->getTargetPath());
15
        
16
        $p = new GitRepo($payload->getTargetPath());
17
18
        // (new Collection($p->listBranches()))->map(function ($branch) use ($p) {
19
        //     if (!$commit = Commit::
20
        //     $payload->commits
21
        // });
22
23
        (new Collection($p->getRevisions()))->map(function ($revision) use ($p) {
24
            if (!$commit = Commit::where('code', $revision['sha1'])->first()) {
25
                $commit = Commit::create([
26
                    'code' => $revision['sha1'],
27
                    'date' => $revision['date'],
28
                    'author' => $revision['author'],
29
                    'message' => $revision['message'],
30
                ]);
31
            }
32
            $payload->commits()->attach($commit);
0 ignored issues
show
Bug introduced by
The variable $payload 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...
33
        });
34
35
        return $payload;
36
    }
37
}