<?php

namespace App\Classes\Modules\Accounts\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Accounts\Services\InvalidatesAuthenticationToken;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class LogoutUserLogic extends AbstractControllerLogic
{

    protected function notification():array {
        return [
            'title' => 'Logout',
            'message' => 'You have successfully logged out of your account'
        ];
    }

    /** @var InvalidatesAuthenticationToken */
    private $invalidatesAuthenticationToken;

    /**
     * LogoutUserLogic constructor.
     * @param InvalidatesAuthenticationToken $invalidatesAuthenticationToken
     */
    public function __construct(InvalidatesAuthenticationToken $invalidatesAuthenticationToken)
    {
        $this->invalidatesAuthenticationToken = $invalidatesAuthenticationToken;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     */
    protected function logic(Request $request): JsonResponse {

        $this->invalidatesAuthenticationToken->execute();

        return $this->response();
    }

}