private function isMaxDepthReached(array $attributesMetadata, $class, $attribute, array &$context)
{
if (!isset($context[static::ENABLE_MAX_DEPTH]) || !isset($attributesMetadata[$attribute]) || null === ($maxDepth = $attributesMetadata[$attribute]->getMaxDepth())) {
return false;
}
$key = sprintf(static::DEPTH_KEY_PATTERN, $class, $attribute);
if (!isset($context[$key])) {
$context[$key] = 1;
return false;
}
if ($context[$key] === $maxDepth) {
return true;
}
++$context[$key];
return false;
}