<?php

namespace Infinito\Attribut;

use Infinito\Exception\NoValidChoiceException;
use Infinito\DBAL\Types\ActionType;

/**
 * @author kevinfrantz
 */
trait ActionTypeAttribut
{
    /**
     * @see ActionType
     *
     * @var string
     */
    protected $actionType;

    /**
     * @param string $actionType
     */
    public function setActionType(string $actionType): void
    {
        if (!in_array($actionType, ActionType::getValues())) {
            throw new NoValidChoiceException('The type is not a valid action type.');
        }
        $this->actionType = $actionType;
    }

    /**
     * @return string
     */
    public function getActionType(): string
    {
        return $this->actionType;
    }
}
