RepositoryFolderService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Serviço referente a linha no banco de dados
4
 */
5
6
namespace Fabrica\Services;
7
8
use Illuminate\Filesystem\Filesystem;
9
10
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Input\InputArgument;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
use Fabrica\Models\Code\Project;
16
use Fabrica\Bundle\CoreBundle\EventDispatcher\FabricaEvents;
17
use Fabrica\Bundle\CoreBundle\EventDispatcher\Event\ProjectEvent;
18
19
/**
20
 * 
21
 */
22
class RepositoryFolderService
23
{
24
25
    protected $config;
26
27
    protected $modelServices = false;
28
29
    public function __construct($config = false)
0 ignored issues
show
Unused Code introduced by
The parameter $config 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...
30
    {
31
        // if (!$this->config = $config) {
32
        //     $this->config = \Illuminate\Support\Facades\Config::get('sitec.sitec.models');
33
        // }
34
    }
35
    
36
    public static function findPackages()
37
    {
38
        // Project::truncate();
39
        $realPath = '/sierra/Dev/Libs/';
40
        
41
        collect(scandir($realPath))
42
            ->each(
43
                function ($item) use ($realPath) {
44
                    RepositoryFolderService::readFolderPackages($item, $realPath);
45
                }
46
            );
47
48
    }
49
50
    public static function readFolderPackages($item, $realPath)
51
    {
52
        if (in_array($item, ['.', '..'])) {
53
            return;
54
        }
55
56
        if (is_file($realPath . $item)) {
57
            return;
58
        }
59
60
        if (!is_dir($realPath . $item)) {
61
            return ;
62
        }
63
        $filesystem = app(Filesystem::class);
64
        
65
        if ($filesystem->exists($realPath . $item.'/composer.lock')) {
66
            // Get the composer.lock file
67
            $composer = json_decode(
68
                $filesystem->get($realPath . $item.'/composer.json')
69
            );
70
            $composerLock = json_decode(
0 ignored issues
show
Unused Code introduced by
$composerLock 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...
71
                $filesystem->get($realPath . $item.'/composer.lock')
72
            );
73
74
            $project = new Project();
75
            $project->setName($composer->name);
76
            $project->setSlug($composer->name);
77
78
            $project->save();
79
80
            $event = new ProjectEvent($project);
81
            event($event); // @todo FabricaEvents::PROJECT_CREATE   fabrica_core.event_dispatcher
82
83
            // //@todo
84
            // unset($composerLock->packages);
85
            // dd('Fabrica',
86
            //     // $composerLock,
87
            //     $composer,
88
            //     $realPath . $item
89
            // );
90
91
            // // // Loop through all the packages and get the version of transmissor
92
            // // foreach ($composerLock->packages as $package) {
93
            // //     if ($package->name == $this->packageName) {
94
            // //         $this->version = $package->version;
95
            // //         break;
96
            // //     }
97
            // // }
98
        }
99
100
        return ;
101
    }
102
}
103