EditEventCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 16 6
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 EditEventCommand.
11
 *
12
 * @package Acacha\Events\Console\Commands
13
 */
14
class EditEventCommand extends Command
15
{
16
    use AsksForEvents;
17
18
    /**
19
     * The name and signature of the console command.
20
     *
21
     * @var string
22
     */
23
    protected $signature = 'event:edit {id? : The event id to edit} {name? : The event name} {user_id? : The user id} {description? : The event description}';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = 'Edits an existing event';
31
32
    /**
33
     * Execute the console command.
34
     *
35
     * @return mixed
36
     */
37
    public function handle()
38
    {
39
        $id = $this->argument('id') ? $this->argument('id') : $this->askForEvents();
40
41
        $event = Event::findOrFail($id);
42
        try {
43
            $event->update([
44
                'name' => $this->argument('name') ? $this->argument('name') : $this->ask('Event name?'),
45
                'user_id' => $this->argument('user_id') ? $this->argument('user_id') : $this->ask('User id?'),
46
                'description' => $this->argument('description') ? $this->argument('description') : $this->ask('Event description?')
47
            ]);
48
        } 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...
49
            $this->error('Error');
50
        }
51
        $this->info('Event has been edited succesfully');
52
    }
53
54
}
55