Passed
Branch bigRefactor (c260a1)
by Julien
34:53
created

DirectEliminationTreeGen::pushEmptyGroupsToTree()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Xoco70\KendoTournaments\TreeGen;
4
5
use Illuminate\Support\Collection;
6
use Xoco70\KendoTournaments\Models\Championship;
7
8
class DirectEliminationTreeGen extends TreeGen
9
{
10
11
    /**
12
     * Calculate the Byes need to fill the Championship Tree.
13
     * @param Championship $championship
14
     * @return Collection
15
     */
16
    protected function getByeGroup(Championship $championship, $fighters)
0 ignored issues
show
Unused Code introduced by
The parameter $championship is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        $fighterCount = $fighters->count();
19
        $preliminaryGroupSize = 2;
20
        $treeSize = $this->getTreeSize($fighterCount, $preliminaryGroupSize);
21
        $byeCount = $treeSize - $fighterCount;
22
23
        return $this->createNullsGroup($byeCount);
24
    }
25
26
27
    /**
28
     * Create empty groups for direct Elimination Tree
29
     * @param $numFighters
30
     */
31
    public function pushEmptyGroupsToTree($numFighters)
32
    {
33
        // We calculate how much rounds we will have
34
        $numFightersEliminatory = $numFighters;
35
        $numRounds = intval(log($numFightersEliminatory, 2));
36
        $this->pushGroups($numRounds, $numFightersEliminatory, $shuffle = 1);
0 ignored issues
show
Documentation introduced by
$shuffle = 1 is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
37
    }
38
}
39