Completed
Push — master ( 26d986...9b7bb9 )
by Julien
09:29
created

SingleEliminationTeamTreeGen::createByeFighter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Xoco70\LaravelTournaments\TreeGen;
4
5
use Illuminate\Support\Collection;
6
use Xoco70\LaravelTournaments\Models\FightersGroup;
7
use Xoco70\LaravelTournaments\Models\Team;
8
9 View Code Duplication
class SingleEliminationTeamTreeGen extends SingleEliminationTreeGen
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
     * get Fighter by Id.
13
     *
14
     * @return Team
15
     */
16
    protected function getFighter($teamId)
17
    {
18
        return Team::find($teamId);
19
    }
20
21
    /**
22
     * Fighter is the name for competitor or team, depending on the case.
23
     *
24
     * @return Collection
25
     */
26
    protected function getFighters()
27
    {
28
        return $this->championship->teams;
29
    }
30
31
    /**
32
     * @param FightersGroup $group
33
     * @param $fighters
34
     *
35
     * @return FightersGroup
36
     */
37
    public function syncGroup(FightersGroup $group, $fighters)
38
    {
39
        // Add all competitors to Pivot Table
40
        return $group->syncTeams($fighters);
41
    }
42
43
    protected function createByeFighter()
44
    {
45
        return new Team();
46
    }
47
48
    protected function addFighterToGroup(FightersGroup $group, $team)
49
    {
50
        $group->teams()->attach($team->id);
51
    }
52
}
53