GetAttemptCountForDoor.php 789 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

namespace Source\UseCases\Attempts\GetAttemptCountForDoor;

use Carbon\Carbon;
use Source\Gateways\Attempts\AttemptsRepository;

class GetAttemptCountForDoor implements GetAttemptCountForDoorUseCase
{
    /**
     * @var \Source\Gateways\Attempts\AttemptsRepository
     */
    protected AttemptsRepository $attempts;

    public function __construct(AttemptsRepository $attempts)
    {
        $this->attempts = $attempts;
    }

    /**
     * @inheritDoc
     */
    public function count(string $doorId, string $begin, string $end, Presenter $presenter): void
    {
        $count = $this->attempts->getCountForDoorBetween($doorId, new Carbon($begin), new Carbon($end));

        $responseModel = new ResponseModel($count);

        $presenter->present($responseModel);
    }
}