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

OpenedAdventDoorRepository::save()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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