I am trying to build the following code, but i cannot understand how to define the instance variable, because it is an object

```
function getInstance($productName)
{   

    switch ($Name) {
        case Name1:
            $instance = new Class1();
            break;
        case Name2:
            $instance = new Class2();
            break;
        case Name3:
            $instance = new Class3();
            break;

        default:
            break;
    }

    return $instance;
}

```