Completed
Push — master ( ff3370...c7a062 )
by Beñat
38s queued 33s
created

LoadUserData::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\TaskManager\Infrastructure\Persistence\Doctrine\DataFixtures;
16
17
use Doctrine\Common\Persistence\ObjectManager;
18
use Kreta\SharedKernel\Infrastructure\Persistence\Doctrine\DataFixtures\AbstractFixture;
19
use Kreta\TaskManager\Application\Command\User\AddUserCommand;
20
21
class LoadUserData extends AbstractFixture
22
{
23
    protected function type() : string
24
    {
25
        return 'user';
26
    }
27
28
    public function getOrder() : int
29
    {
30
        return 1;
31
    }
32
33
    public function load(ObjectManager $manager) : void
34
    {
35
        $i = 0;
36
        while ($i < $this->amount()) {
37
            $this->commandBus()->handle(
38
                new AddUserCommand(
39
                    $this->getRandomUserByIndex($i)
40
                )
41
            );
42
            ++$i;
43
        }
44
    }
45
}
46