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

PlayOffTreeGen::getByeGroup()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 2
1
<?php
2
3
namespace Xoco70\KendoTournaments\TreeGen;
4
5
use Illuminate\Support\Collection;
6
use Xoco70\KendoTournaments\Models\Championship;
7
8
class PlayOffTreeGen extends TreeGen
9
{
10
    /**
11
     * Calculate the Byes need to fill the Championship Tree.
12
     * @param Championship $championship
13
     * @return Collection
14
     */
15
    protected function getByeGroup(Championship $championship, $fighters)
16
    {
17
        $groupSizeDefault = 3;
18
        $fighterCount = $fighters->count();
19
        $preliminaryGroupSize = $championship->settings != null
20
            ? $championship->settings->preliminaryGroupSize
21
            : $groupSizeDefault;
22
23
        $treeSize = $this->getTreeSize($fighterCount, $preliminaryGroupSize);
24
        $byeCount = $treeSize - $fighterCount;
25
26
        return $this->createNullsGroup($byeCount);
27
    }
28
29
30
    /**
31
     * Create empty groups for direct Elimination Tree
32
     * @param $numFighters
33
     */
34
    public function pushEmptyGroupsToTree($numFighters)
35
    {
36
        $numFightersEliminatory = $numFighters / $this->championship->getSettings()->preliminaryGroupSize * 2;
37
        // We calculate how much rounds we will have
38
        $numRounds = intval(log($numFightersEliminatory, 2));
39
        $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...
40
    }
41
}
42