ListEventsCommand::handle()   A
last analyzed

Complexity

Conditions 3
Paths 7

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
c 1
b 0
f 0
nc 7
nop 0
dl 0
loc 19
rs 9.4285
1
<?php
2
3
namespace Acacha\Events\Console\Commands;
4
5
use Acacha\Events\Models\Event;
6
use Illuminate\Console\Command;
7
use Mockery\Exception;
8
9
/**
10
 * Class ListEventsCommand.
11
 *
12
 * @package Acacha\Events\Console\Commands
13
 */
14
class ListEventsCommand extends Command
15
{
16
    /**
17
     * The name and signature of the console command.
18
     *
19
     * @var string
20
     */
21
    protected $signature = 'event:list';
22
23
    /**
24
     * The console command description.
25
     *
26
     * @var string
27
     */
28
    protected $description = 'List events';
29
30
    /**
31
     * Execute the console command.
32
     *
33
     * @return mixed
34
     */
35
    public function handle()
36
    {
37
        try {
38
            $headers = ['Name', 'User id','User name', 'Description'];
39
40
            $events = Event::all();
41
42
            $events_rows = [];
43
            foreach ($events as $event) {
44
                $events_rows[] = [
45
                    $event->name, $event->user_id, $event->user->name, $event->description
46
                ];
47
            }
48
49
            $this->table($headers, $events_rows);
50
        } catch ( Exception $e) {
0 ignored issues
show
Bug introduced by
The class Mockery\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
51
            $this->error('Error');
52
        }
53
    }
54
}
55