private function isIdentical($val1, $val2) : bool
{
if (gettype($val1) !== gettype($val2)) {
return false;
}
if (is_object($val1)) {
return $val1 == $val2;
}
if (is_scalar($val1) || null === $val1) {
return $val1 === $val2;
}
if (false === is_array($val1)) {
throw InvalidArgumentExceptionFactory::createForUnsupportedTypeForIdenticalValuesCheck($val1);
}
foreach ($val1 as $key => $item) {
if (is_string($key)) {
if (false === $this->isIdentical($item, $val2[$key])) {
return false;
}
continue;
}
if (false === $this->arrayHasValue($item, $val2)) {
return false;
}
}
return true;
}