protected function parseToArray($object) : array { if (!is_array($object)) { $attributes = method_exists($object, 'getAttributes') ? $object->getAttributes() : get_object_vars($object); return $attributes; } return $object; }