public static function hydrate(stdClass $activity)
    {
        $hydrated = new ActivityEntity();

        if (isset($activity->id)) {
            $hydrated->setId($activity->id);
        }

        if (isset($activity->type)) {
            $hydrated->setType($activity->type);
        }

        if (isset($activity->context)) {
            $hydrated->setContext(json_decode(json_encode($activity->context), true));
        }

        if (isset($activity->application)) {
            $hydrated->setApplication(ApplicationHydrator::hydrate($activity->application));
        }

        if (isset($activity->created_by)) {
            $hydrated->setCreatedBy(UserHydrator::hydrate($activity->created_by));
        }

        if (isset($activity->created_at)) {
            $hydrated->setCreatedAt(new DateTime($activity->created_at));
        }

        return $hydrated;
    }