TranslationPresenter.php 1.19 KB
Newer Older
1
2
<?php

3
namespace Source\UseCases\Door\Authenticate;
4
5
6
7

use App\Door;
use Source\UseCases\BasePresenter;

Jacob Priddy's avatar
Jacob Priddy committed
8
9
class TranslationPresenter extends BasePresenter implements Presenter
{
10
11
12
    protected ?Door $viewModel = null;

    /** @inheritDoc */
Jacob Priddy's avatar
Jacob Priddy committed
13
14
    public function present(ResponseModel $responseModel): void
    {
15
16
17
18
19
20
21
        $door = $responseModel->getDoor();

        if (!$door) {
            return;
        }

        $this->viewModel = new Door();
22
23
24
25
26
27
28
29
30
        $this->viewModel->setAttribute('id', $door->getId());
        $this->viewModel->setAttribute('name', $door->getName());
        $this->viewModel->setAttribute('location', $door->getLocation());
        $this->viewModel->setAttribute('created_at', $door->getCreatedAt());
        $this->viewModel->setAttribute('updated_at', $door->getUpdatedAt());
        $this->viewModel->setAttribute('public', $door->isPublic());
        $this->viewModel->setAttribute('notes', $door->getNotes());
        $this->viewModel->setAttribute('api_token', $door->getToken()->getHash());
        $this->viewModel->setAttribute('last_seen_at', $door->getLastSeenAt());
31
32
33
    }

    /** @inheritDoc */
Jacob Priddy's avatar
Jacob Priddy committed
34
35
    public function getViewModel(): ?Door
    {
36
37
38
        return $this->viewModel;
    }
}