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

LoadUserData   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A type() 0 4 1
A getOrder() 0 4 1
A load() 0 12 2
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