LoadTrainerData::createEntity()   B
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 25
Code Lines 19

Duplication

Lines 3
Ratio 12 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 3
loc 25
ccs 0
cts 23
cp 0
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 19
nc 4
nop 1
crap 12
1
<?php
2
3
namespace OSS\CoreBundle\DataFixtures\ORM;
4
5
use Doctrine\Common\DataFixtures\FixtureInterface;
6
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
use OSS\CoreBundle\Entity\Trainer;
8
9
class LoadTrainerData extends AbstractTeamMemberFixture implements FixtureInterface, OrderedFixtureInterface
10
{
11
    /**
12
     * @param int $teamIndex
13
     *
14
     * @return Trainer
15
     */
16
    protected function createEntity($teamIndex)
17
    {
18
        $factor = array();
19
        for ($i = 0; $i < 10; $i++) {
20
            $factor[$i] = 0;
21
        }
22 View Code Duplication
        for ($i = 1; $i <= 100; $i++) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
23
            $factor[rand(0, 9)]++;
24
        }
25
26
        $trainer = new Trainer();
27
        $trainer->setTrainingFactorTackling($factor[0]);
28
        $trainer->setTrainingFactorPassing($factor[1]);
29
        $trainer->setTrainingFactorShooting($factor[2]);
30
        $trainer->setTrainingFactorHeading($factor[3]);
31
        $trainer->setTrainingFactorSpeed($factor[4]);
32
        $trainer->setTrainingFactorCrossing($factor[5]);
33
        $trainer->setTrainingFactorTechnics($factor[6]);
34
        $trainer->setTrainingFactorIntelligence($factor[7]);
35
        $trainer->setTrainingFactorSafety($factor[8]);
36
        $trainer->setTrainingFactorDribbling($factor[9]);
37
        $trainer->setSkill(max(1, min(100, round(rand(1, 100) / $teamIndex * 5))));
38
39
        return $trainer;
40
    }
41
42
    /**
43
     * @return int
44
     */
45
    public function getOrder()
46
    {
47
        return 5;
48
    }
49
}
50