<?php

namespace App\Classes\Modules\Remarks\Processors;


use App\Classes\General\Interfaces\Remarkable;
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
use App\Classes\Modules\Remarks\Services\CreatesRemark;
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;

class CreateRemarkProcessor
{

    /** @var CreatesRemark */
    private $createsRemark;

    /** @var CanCreateRemark */
    private $canCreateRemark;

    /**
     * CreateRemarkProcessor constructor.
     * @param CreatesRemark $createsRemark
     * @param CanCreateRemark $canCreateRemark
     */
    public function __construct(CreatesRemark $createsRemark, CanCreateRemark $canCreateRemark)
    {
        $this->createsRemark = $createsRemark;
        $this->canCreateRemark = $canCreateRemark;
    }


    /**
     * @param Remarkable $remarkable
     * @param RemarkObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\AccessForbiddenException
     * @throws \App\Classes\Exceptions\MalformedRequestException
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    public function execute(Remarkable $remarkable, RemarkObject $object){

        $this->canCreateRemark->passes($object);
        return $this->createsRemark->execute($remarkable, $object);

    }

}