Replace is_object/is_array with switch on gettype

When checking multiple types, this is ~10% slower in the worst case, and ~30-33% faster for the average and best case.

/cc @nizsheanez

See #218