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

PlayOffCompetitorTreeGen::getFighters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

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