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

PlayOffTreeGen   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 34
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getByeGroup() 0 13 2
A pushEmptyGroupsToTree() 0 7 1
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