ListEventsCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 3
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 19 3
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