Completed
Push — master ( 1f8bb9...0c53f4 )
by Phecho
06:42 queued 03:18
created

AddOwnerCommandHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
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