Completed
Push — master ( 7eae42...8f150d )
by Thiago
10:26
created

User::findAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace User\Repository;
5
6
use Doctrine\ORM\EntityRepository;
7
use User\Entity\User as UserModel;
8
9
/**
10
 * User Repository
11
 *
12
 * @author Thiago Paes <[email protected]>
13
 */
14
final class User extends EntityRepository implements UserInterface
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    public function findById(int $id): UserModel
20
    {
21
        $user = $this->findOneBy(
22
            [
23
                'id' => $id,
24
                'active' => true
25
            ]
26
        );
27
28
        if (null === $user) {
29
            $user = new UserModel();
30
        }
31
32
        return $user;
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function findAll(): array
39
    {
40
        $users = $this->findBy(
41
            [
42
                'active' => true
43
            ]
44
        );
45
46
        return $users;
47
    }
48
}
49