protected function clearUndefinedOptions(array $options, $allowUndefinedOptions)
    {
        if (! $allowUndefinedOptions) {

            return $options;
        }

        /* Find out undefined options by computing the difference between given and defined options. */
        $undefinedOptions = array_diff(
            array_keys($options),
            $this->getDefinedOptions()
        );

        /* Remove undefined options by computing the difference between given and undefined options. */

        return array_diff_key(
            $options,
            array_flip($undefinedOptions)
        );
    }