TranslationPresenter.php 1.01 KB
Newer Older
Jacob Priddy's avatar
Jacob Priddy committed
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
32
33
34
35
36
37
38
<?php

namespace Source\UseCases\Token\Authenticate;

use App\User;
use Source\UseCases\BasePresenter;

class TranslationPresenter extends BasePresenter implements Presenter {
    protected ?User $viewModel = null;

    /** @inheritDoc */
    public function present(ResponseModel $responseModel): void {
        $user = $responseModel->getUser();

        if (!$user) {
            return;
        }

        $dbUser = new User();

        $dbUser->id = $user->getId();
        $dbUser->email = $user->getEmail();
        $dbUser->first_name = $user->getFirstName();
        $dbUser->last_name = $user->getLastName();
        $dbUser->display_name = $user->getDisplayName();
        $dbUser->emplid = $user->getEmplid();
        $dbUser->created_at = $user->getCreatedAt();
        $dbUser->expires_at = $user->getExpiresAt();
        $dbUser->updated_at = $user->getUpdatedAt();

        $this->viewModel = $dbUser;
    }

    /** @inheritDoc */
    public function getViewModel(): ?User {
        return $this->viewModel;
    }
}