filter(function (array $consts) { return isset($consts['pcre']) && defined('ARRAY_FILTER_USE_KEY'); }) ->map(function (array $consts) { return array_filter($consts['pcre'], function ($msg) { return substr($msg, -6) === '_ERROR'; }, ARRAY_FILTER_USE_KEY); }) ->flatMap(function (array $errors) use ($code) { return Option::fromValue( array_search($code, $errors, true) ); }) ->getOrElse('PREG_ERROR'); } }