AddOwnerCommandHandler::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 14
rs 9.4286
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 *
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Handlers\Commands\Owner;
13
14
use Gitamin\Commands\Owner\AddOwnerCommand;
15
use Gitamin\Events\Owner\OwnerWasAddedEvent;
16
use Gitamin\Models\Owner;
17
18
class AddOwnerCommandHandler
19
{
20
    /**
21
     * Handle the add project owner command.
22
     *
23
     * @param \Gitamin\Commands\Owner\AddOwnerCommand $command
24
     *
25
     * @return \Gitamin\Models\Owner
26
     */
27
    public function handle(AddOwnerCommand $command)
28
    {
29
        $group = Owner::create([
30
            'name' => $command->name,
31
            'path' => $command->path,
32
            'user_id' => $command->user_id,
33
            'description' => $command->description,
34
            'type' => $command->type,
35
        ]);
36
37
        event(new OwnerWasAddedEvent($group));
38
39
        return $group;
40
    }
41
}
42