CreateEventCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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 CreateEventCommand.
11
 * @package Acacha\Events\Console\Commands
12
 */
13
class CreateEventCommand extends Command
14
{
15
    /**
16
     * The name and signature of the console command.
17
     *
18
     * @var string
19
     */
20
    protected $signature = 'event:create {name? : The event name} {user_id? : The user id} {description? : The event description}';
21
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Creates a new event';
28
29
    /**
30
     * Create a new command instance.
31
     *
32
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
33
     */
34
    public function __construct()
35
    {
36
        parent::__construct();
37
    }
38
39
    /**
40
     * Execute the console command.
41
     *
42
     * @return mixed
43
     */
44
    public function handle()
45
    {
46
        try {
47
            Event::create([
0 ignored issues
show
Bug introduced by
The method create() does not exist on Acacha\Events\Models\Event. Did you maybe mean created()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
48
                'name' => $this->argument('name') ? $this->argument('name') : $this->ask('Event name?'),
49
                'user_id' => $this->argument('user_id') ? $this->argument('user_id') : $this->ask('User id?'),
50
                'description' => $this->argument('description') ? $this->argument('description') : $this->ask('Event description?')
51
            ]);
52
        } 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...
53
            $this->error('Error');
54
        }
55
        $this->info('Event has been added to database succesfully');
56
    }
57
}
58