private function initObjectWithCheck(string $class, string $expected, array $params = [])
    {
        $reflectionClass = new \ReflectionClass($class);
        $instance = $reflectionClass->newInstanceArgs($params);
        if (!$instance instanceof $expected) {
            throw new \InvalidArgumentException(
                "Provided service class missmatch: given $class, expected $expected."
            );
        }
        return $instance;
    }