public static function getFor($type, $onlyOr = false)
{
if (is_array($type)) {
$messagesFor = f\partial(a\map, ['\\nspl\\args\\_p\\ErrorMessage', 'getFor']);
if ($onlyOr) {
return implode(' or ', $messagesFor($type));
} else {
$isOr = function ($t) {
return isset(Checker::$isOr[$t]) || class_exists($t) || interface_exists($t);
};
list($orTypes, $andTypes) = a\partition($isOr, $type);
return implode(' and ', array_filter([implode(' or ', $messagesFor($orTypes)), implode(' and ', $messagesFor($andTypes))]));
}
}
if ($type instanceof Constraint) {
return $type->__toString();
}
$default = class_exists($type) || interface_exists($type) ? $type : implode(' ', array_map('strtolower', preg_split('/(?=[A-Z])/', a\last(explode('\\', $type)))));
return a\value(self::$messages, $type, 'be ' . $default);
}