Completed
Push — master ( 635bed...988e80 )
by Phecho
03:22
created

RemoveProjectTeamCommandHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A RemoveProjectNamespaceCommandHandler::handle() 0 13 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\ProjectNamespace;
13
14
use Gitamin\Commands\ProjectNamespace\RemoveProjectNamespaceCommand;
15
use Gitamin\Events\ProjectNamespace\ProjectNamespaceWasRemovedEvent;
16
17
class RemoveProjectNamespaceCommandHandler
18
{
19
    /**
20
     * Handle the remove project team command.
21
     *
22
     * @param \Gitamin\Commands\ProjectTeam\RemoveProjectTeamCommand $command
23
     *
24
     * @return void
25
     */
26
    public function handle(RemoveProjectNamespaceCommand $command)
27
    {
28
        $group = $command->group;
0 ignored issues
show
Bug introduced by
The property group does not seem to exist in Gitamin\Commands\Project...ProjectNamespaceCommand.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
29
30
        event(new ProjectTeamWasRemovedEvent($team));
0 ignored issues
show
Bug introduced by
The variable $team does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
31
32
        // Remove the namespace id from all project.
33
        $group->projects->map(function ($project) {
34
            $project->update(['namespace_id' => 0]);
35
        });
36
37
        $group->delete();
38
    }
39
}
40