PublishTodo::handle()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 16

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 16
nc 2
nop 0
dl 24
loc 24
rs 8.9713
c 0
b 0
f 0
1
<?php
2
3
namespace Acacha\ForgePublish\Commands;
4
5
use Acacha\ForgePublish\Commands\Traits\AborstIfEnvVariableIsnotInstalled;
6
use Acacha\ForgePublish\Commands\Traits\ItFetchesAssignments;
7
use GuzzleHttp\Client;
8
use Illuminate\Console\Command;
9
10
/**
11
 * Class PublishTodo.
12
 *
13
 * @package Acacha\ForgePublish\Commands
14
 */
15 View Code Duplication
class PublishTodo extends Command
0 ignored issues
show
Duplication introduced by
This class 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...
16
{
17
18
    use ItFetchesAssignments, AborstIfEnvVariableIsnotInstalled;
19
20
    /**
21
     * The name and signature of the console command.
22
     *
23
     * @var string
24
     */
25
    protected $signature = 'publish:todo';
26
27
    /**
28
     * The console command description.
29
     *
30
     * @var string
31
     */
32
    protected $description = 'List current student assignments';
33
34
    /**
35
     * Assignments.
36
     *
37
     * @var
38
     */
39
    protected $assignments;
40
41
    /**
42
     * Server names.
43
     *
44
     * @var Client
45
     */
46
    protected $http;
47
48
    /**
49
     * SaveEnvVariable constructor.
50
     *
51
     */
52
    public function __construct(Client $http)
53
    {
54
        parent::__construct();
55
        $this->http = $http;
56
    }
57
58
    /**
59
     * Execute the console command.
60
     *
61
     */
62
    public function handle()
63
    {
64
        //TODO
65
        $this->abortCommandExecution();
66
        $this->assignments = $this->fetchAssignments();
67
68
        $headers = ['Id', 'Name','Repository','Repo Type','Forge site','Forge Server','Created','Updated'];
69
70
        $rows = [];
71
        foreach ($this->assignments as $assignment) {
72
            $rows[] = [
73
                $assignment->id,
74
                $assignment->name,
75
                $assignment->repository_uri,
76
                $assignment->repository_type,
77
                $assignment->forge_site,
78
                $assignment->forge_server,
79
                $assignment->created_at,
80
                $assignment->updated_at
81
            ];
82
        }
83
84
        $this->table($headers, $rows);
85
    }
86
87
    /**
88
     * Abort command execution.
89
     */
90
    protected function abortCommandExecution()
91
    {
92
        $this->abortsIfEnvVarIsNotInstalled('ACACHA_FORGE_ACCESS_TOKEN');
93
    }
94
}
95