value format. * * @var array */ protected $required_keys = []; /** * ArrayWithRequiredKeys constructor. * * @param array $data */ public function __construct( array $data ) { $this->validate_keys( $data ); $this->data = $data; } /** * Validate that we have all of the keys that we require. * * @param array $data Array of provided data. * * @throws InvalidArray When any of the required keys are missing. */ protected function validate_keys( array $data ) { $missing = array_diff_key( $this->required_keys, $data ); if ( ! empty( $missing ) ) { throw InvalidArray::missing_keys( static::class, array_keys( $missing ) ); } } }