protected function getIdentifierSource(array $contextProperties)
{
ksort($contextProperties);
$identifierSource = $this->contextImplementation;
foreach ($contextProperties as $propertyName => $propertyValue) {
if ($propertyName === 'dimensions') {
$stringParts = array();
foreach ($propertyValue as $dimensionName => $dimensionValues) {
$stringParts[] = $dimensionName . '=' . implode(',', $dimensionValues);
}
$stringValue = implode('&', $stringParts);
} elseif ($propertyName === 'targetDimensions') {
$stringParts = array();
foreach ($propertyValue as $dimensionName => $dimensionValue) {
$stringParts[] = $dimensionName . '=' . $dimensionValue;
}
$stringValue = implode('&', $stringParts);
} elseif ($propertyValue instanceof \DateTimeInterface) {
$stringValue = $propertyValue->getTimestamp();
} elseif ($propertyValue instanceof Site) {
$stringValue = $propertyValue->getNodeName();
} elseif ($propertyValue instanceof Domain) {
$stringValue = $propertyValue->getHostname();
} else {
$stringValue = (string) $propertyValue;
}
$identifierSource .= ':' . $stringValue;
}
return $identifierSource;
}