Passed
Push — master ( c00df7...7d9cfb )
by Nico
47:51 queued 23:47
created

OpenedAdventDoorRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 10
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 5 1
A prototype() 0 3 1
A getOpenedDoorsCountOfToday() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Repository;
6
7
use Doctrine\ORM\EntityRepository;
8
use Stu\Orm\Entity\OpenedAdventDoor;
9
use Stu\Orm\Entity\OpenedAdventDoorInterface;
10
use Stu\Orm\Entity\UserInterface;
11
12
/**
13
 * @extends EntityRepository<OpenedAdventDoor>
14
 */
15
final class OpenedAdventDoorRepository extends EntityRepository implements OpenedAdventDoorRepositoryInterface
16
{
17
    public function prototype(): OpenedAdventDoorInterface
18
    {
19
        return new OpenedAdventDoor();
20
    }
21
22
    public function save(OpenedAdventDoorInterface $openedadventdoor): void
23
    {
24
        $em = $this->getEntityManager();
25
26
        $em->persist($openedadventdoor);
27
    }
28
29
    public function getOpenedDoorsCountOfToday(UserInterface $user): int
30
    {
31
        return count($this->findBy([
32
            'user_id' => $user->getId(),
33
            'day' => (int)date("j"),
34
            'year' => (int)date("Y"),
35
        ]));
36
    }
37
}
38