<?php declare( strict_types=1 );

/**
 * The file that defines the core plugin class
 *
 * A class definition that includes attributes and functions used across both the
 * public-facing side of the site and the admin area.
 *
 * @link       https://webequipe.com
 * @since      1.0.0
 *
 * @package    Webequipe_Spin_Win_Wheel
 * @subpackage Webequipe_Spin_Win_Wheel/includes
 */

namespace Webequipe\SpinWinWheel\Traits;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Error handler trait
 */
trait Form_Error
{

    /**
         * Holds the errors
         *
         * @var array
         */
    public $errors = [];

    /**
     * Check if the form has error
     *
     * @param string $key
     *
     * @return bool
     */
    public function has_error( $key )
    {
        return isset( $this->errors[ $key ] ) ? true : false;
    }

    /**
     * Get the error by key
     *
     * @param key $key
     *
     * @return string|false
     */
    public function get_error( $key )
    {
        if ( isset( $this->errors[ $key ] ) ) {
            return $this->errors[ $key ];
        }

        return false;
    }
}
