CreateCollection   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 2
1
<?php
2
3
namespace Colligator\Console\Commands;
4
5
use Colligator\Collection;
6
use Illuminate\Console\Command;
7
8
class CreateCollection extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'colligator:create-collection
16
                            {name  : Name of the collection}
17
                            {label : A descriptionve label}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Create a new collection.';
25
26
    /**
27
     * Execute the console command.
28
     *
29
     * @return mixed
30
     */
31
    public function handle()
32
    {
33
        $name = $this->argument('name');
34
        $label = $this->argument('label');
35
        $c = Collection::firstOrNew(['name' => $name, 'label' => $label]);
36
        if ($c->isDirty()) {
37
            $this->info("Created collection '$name'.");
38
            $c->save();
39
        } else {
40
            $this->info("Collection '$name' already exists.");
41
        }
42
    }
43
}
44