Why using `switch` there ? Better use an if, with throwing an exception first if type is not supported.
And nitpick: please use `use` statement to import `InvalidArgumentException`.