private static function calculateArrayDiff($expected, $actual, $strict)
    {
        if (count($expected) !== count($actual)) {
            throw new \LogicException(
                sprintf(
                    'Array element count mismatch. Found %s, expected %s.',
                    count($actual),
                    count($expected)
                ),
                self::ARRAY_COUNT_MISMATCH
            );
        }

        reset($actual);
        foreach ($expected as $key => $value) {
            if ($key !== key($actual)) {
                throw new \LogicException(
                    sprintf(
                        'Array key mismatch. Found %s, expected %s.',
                        key($actual),
                        $key
                    ),
                    self::ARRAY_KEY_MISMATCH
                );
            }

            try {
                self::calculateDiff($value, current($actual), $strict);
            } catch (\Exception $exception) {
                throw new \LogicException(
                    sprintf(
                        'Array value mismatch for key %s.',
                        key($actual)
                    ),
                    self::ARRAY_VALUE_MISMATCH,
                    $exception
                );
            }
            next($actual);
        }
    }