<?php


namespace App\Model\Facades\Writers;


use App\Model\Entities\Image;
use App\Model\Exceptions\User\AnonymousUserException;
use App\Model\Services\ImageService;

class ImageWriter extends BaseWriter
{
    /** @var  ImageService */
    protected $imageService;

    public function inject(ImageService $imageService)
    {
        $this->imageService = $imageService;
    }

    /**
     * @param string $name
     * @param string $fileName
     * @return Image
     * @throws AnonymousUserException
     */
    public function createImage(string $name, string $fileName) : Image
    {
        return $this->imageService->createImage($this->getLoggedInUser(), $name, $fileName);
    }
}