Completed
Push — master ( 47ea5c...7bab12 )
by Julien
03:03
created

DirectEliminationTeamTreeGen   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 0
cbo 4
dl 41
loc 41
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFighter() 4 4 1
A getFighters() 4 4 1
A syncGroup() 5 5 1
A createByeFighter() 4 4 1
A addFighterToGroup() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Xoco70\KendoTournaments\TreeGen;
4
5
use Illuminate\Support\Collection;
6
use Xoco70\KendoTournaments\Models\FightersGroup;
7
use Xoco70\KendoTournaments\Models\Team;
8
9 View Code Duplication
class DirectEliminationTeamTreeGen extends DirectEliminationTreeGen
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
12
    /**
13
     * get Fighter by Id
14
     * @return Team
15
     */
16
    protected function getFighter($teamId)
17
    {
18
        return Team::find($teamId);
19
    }
20
    /**
21
     * Fighter is the name for competitor or team, depending on the case
22
     * @return Collection
23
     */
24
    protected function getFighters()
25
    {
26
        return $this->championship->teams;
27
    }
28
29
    /**
30
     * @param FightersGroup $group
31
     * @param $fighters
32
     * @return FightersGroup
33
     */
34
    public function syncGroup(FightersGroup $group, $fighters)
35
    {
36
        // Add all competitors to Pivot Table
37
        return $group->syncTeams($fighters);
38
    }
39
40
    protected function createByeFighter()
41
    {
42
        return new Team();
43
    }
44
45
    protected function addFighterToGroup(FightersGroup $group, $team)
46
    {
47
        $group->teams()->attach($team->id);
48
    }
49
}
50