1<?php
2
3namespace SimpleValidator\Validators;
4
5class InArray extends Base
6{
7    protected $array;
8
9    public function __construct($field, array $array, $error_message)
10    {
11        parent::__construct($field, $error_message);
12        $this->array = $array;
13    }
14
15    public function execute(array $data)
16    {
17        if ($this->isFieldNotEmpty($data)) {
18            return in_array($data[$this->field], $this->array);
19        }
20
21        return true;
22    }
23}
24