Hydrate a activity object into a ActivityEntity object

@param stdClass $activity
@return ActivityEntity
340412
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;
    }
321458
public static function hydrate(stdClass $scan)
    {
        $hydrated = new ScanEntity();

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

        if (isset($scan->version)) {
            $hydrated->setVersion($scan->version);
        }

        if (isset($scan->path)) {
            $hydrated->setPath($scan->path);
        }

        if (isset($scan->started_at)) {
            $hydrated->setStartedAt(new DateTime($scan->started_at));
        }

        if (isset($scan->finished_at)) {
            $hydrated->setFinishedAt(new DateTime($scan->finished_at));
        }

        if (isset($scan->phase)) {
            $hydrated->setPhase($scan->phase);
        }

        if (isset($scan->percent)) {
            $hydrated->setPercent($scan->percent);
        }

        if (isset($scan->loc)) {
            $hydrated->setLoc($scan->loc);
        }

        if (isset($scan->code_stored)) {
            $hydrated->setCodeStored($scan->code_stored);
        }

        if (isset($scan->upload_removed)) {
            $hydrated->setUploadRemoved($scan->upload_removed);
        }

        if (isset($scan->full_code_compared)) {
            $hydrated->setFullCodeCompared($scan->full_code_compared);
        }

        if (isset($scan->history_inherited)) {
            $hydrated->setHistoryInherited($scan->history_inherited);
        }

        if (isset($scan->source_type)) {
            $hydrated->setSourceType($scan->source_type);
        }

        if (isset($scan->php)) {
            $hydrated->setPhp(PhpHydrator::hydrate($scan->php));
        }

        if (isset($scan->java)) {
            $hydrated->setJava(JavaHydrator::hydrate($scan->java));
        }

        if (isset($scan->upload)) {
            $hydrated->setUpload(UploadHydrator::hydrate($scan->upload));
        }

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

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

        if (isset($scan->profile)) {
            $hydrated->setProfile(ProfileHydrator::hydrate($scan->profile));
        }

        if (isset($scan->issue_types) && is_array($scan->issue_types)) {
            $hydrated->setIssueTypes(IssueTypeHydrator::hydrateCollection($scan->issue_types));
        }

        if (isset($scan->parent)) {
            $hydrated->setParent(self::hydrate($scan->parent));
        }

        if (isset($scan->severity_distributions)) {
            $hydrated->setSeverityDistributions((array)$scan->severity_distributions);
        }

        if (isset($scan->analysis_depth)) {
            $hydrated->setAnalysisDepth($scan->analysis_depth);
        }

        if (isset($scan->tags)) {
            $hydrated->setTags($scan->tags);
        }

        if (isset($scan->max_issues_per_type)) {
            $hydrated->setMaxIssuesPerType($scan->max_issues_per_type);
        }

        if (isset($scan->comment)) {
            $hydrated->setComment($scan->comment);
        }

        if (isset($scan->source)) {
            $hydrated->setSource($scan->source);
        }

        if (isset($scan->libraries) && is_array($scan->libraries)) {
            $hydrated->setLibraries(LibraryHydrator::hydrateCollection($scan->libraries));
        }

        if (isset($scan->processes) && is_array($scan->processes)) {
            $hydrated->setProcesses(ProcessHydrator::hydrateCollection($scan->processes));
        }

        if (isset($scan->languages) && is_array($scan->languages)) {
            $hydrated->setLanguages(LanguageHydrator::hydrateCollection($scan->languages));
        }

        if (isset($scan->comparison)) {
            $hydrated->setComparison(ComparisonHydrator::hydrate($scan->comparison));
        }
        return $hydrated;
    }
1142594
public static function hydrate(stdClass $setting)
    {
        $hydrated = new SettingEntity();

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

        if (isset($setting->issue_types)) {
            $hydrated->setIssueTypes($setting->issue_types);
        }

        if (isset($setting->code_stored)) {
            $hydrated->setCodeStored($setting->code_stored);
        }

        if (isset($setting->upload_removed)) {
            $hydrated->setUploadRemoved($setting->upload_removed);
        }

        if (isset($setting->full_code_compared)) {
            $hydrated->setFullCodeCompared($setting->full_code_compared);
        }

        if (isset($setting->history_inherited)) {
            $hydrated->setHistoryInherited($setting->history_inherited);
        }

        if (isset($setting->analysis_depth)) {
            $hydrated->setAnalysisDepth($setting->analysis_depth);
        }

        if (isset($setting->max_issues_per_type)) {
            $hydrated->setMaxIssuesPerType($setting->max_issues_per_type);
        }

        if (isset($setting->php)) {
            $hydrated->setPhp(PhpHydrator::hydrate($setting->php));
        }

        if (isset($setting->java)) {
            $hydrated->setJava(JavaHydrator::hydrate($setting->java));
        }

        return $hydrated;
    }
1070749
public static function hydrate(stdClass $ignore)
    {
        $hydrated = new IgnoredLocationEntity();

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

        if (isset($ignore->path)) {
            $hydrated->setPath($ignore->path);
        }

        if (isset($ignore->match)) {
            $hydrated->setMatch($ignore->match);
        }

        if (isset($ignore->exclude)) {
            $hydrated->setExclude($ignore->exclude);
        }

        return $hydrated;
    }
56972
public function hydrate(array $data, $object)
    {
        parent::hydrate($data, $object);
        if (isset($data['certname'])) {
            $object->setName($data['certname']);
        }
        if (isset($data['facts-timestamp'])) {
            $object->setReportedAt(new \DateTime($data['facts-timestamp']));
        }
        if (isset($data['facts-environment'])) {
            $object->setEnvironment($data['facts-environment']);
        }
        return $object;
    }
1277324
public static function hydrate(stdClass $ldap)
    {
        $hydrated = new LdapEntity();

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

        if (isset($ldap->enabled)) {
            $hydrated->setEnabled($ldap->enabled);
        }

        if (isset($ldap->search_dn)) {
            $hydrated->setSearchDn($ldap->search_dn);
        }

        if (isset($ldap->search_password)) {
            $hydrated->setSearchPassword($ldap->search_password);
        }

        if (isset($ldap->search_query)) {
            $hydrated->setSearchQuery($ldap->search_query);
        }

        if (isset($ldap->base_dn)) {
            $hydrated->setBaseDn($ldap->base_dn);
        }

        if (isset($ldap->email_key)) {
            $hydrated->setEmailKey($ldap->email_key);
        }

        if (isset($ldap->user_dn)) {
            $hydrated->setUserDn($ldap->user_dn);
        }

        if (isset($ldap->host)) {
            $hydrated->setHost($ldap->host);
        }

        if (isset($ldap->port)) {
            $hydrated->setPort($ldap->port);
        }

        if (isset($ldap->encryption)) {
            $hydrated->setEncryption($ldap->encryption);
        }

        if (isset($ldap->protocol_version)) {
            $hydrated->setProtocolVersion($ldap->protocol_version);
        }

        if (isset($ldap->expired_accounts)) {
            $hydrated->setExpiredAccounts($ldap->expired_accounts);
        }

        if (isset($ldap->last_sync_at)) {
            $hydrated->setLastSyncAt(new DateTime($ldap->last_sync_at));
        }

        return $hydrated;
    }
696894
public static function hydrate(stdClass $customFunction)
    {
        $hydrated = new CustomFunctionEntity();

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

        if (isset($customFunction->start_line)) {
            $hydrated->setStartLine($customFunction->start_line);
        }

        if (isset($customFunction->end_line)) {
            $hydrated->setEndLine($customFunction->end_line);
        }

        if (isset($customFunction->start_column)) {
            $hydrated->setStartColumn($customFunction->start_column);
        }

        if (isset($customFunction->end_column)) {
            $hydrated->setEndColumn($customFunction->end_column);
        }

        if (isset($customFunction->name)) {
            $hydrated->setName($customFunction->name);
        }

        if (isset($customFunction->file)) {
            $hydrated->setFile(FileHydrator::hydrate($customFunction->file));
        }

        if (isset($customFunction->class)) {
            $hydrated->setClass(CustomClassHydrator::hydrate($customFunction->class));
        }

        if (isset($customFunction->parameters)) {
            $hydrated->setParameters($customFunction->parameters);
        }

        return $hydrated;
    }
724755
private function hydrate(array $file)
    {
        $entity = new FileEntity();
        $entity->setType($file['type'])
               ->setName($file['name'])
               ->setTmpName($file['tmp_name'])
               ->setSize($file['size'])
               ->setError($file['error']);

        return $entity;
    }
1222373
public function hydrate(array $data, $object)
    {
        if (isset($data['timestamp'])) {
            $object->setCreatedAt(new \DateTime($data['timestamp']));
        }
        if (isset($data['resource-title'])) {
            $object->setTitle($data['resource-title']);
        }
        if (isset($data['resource-type'])) {
            $object->setType($data['resource-type']);
        }
        if (isset($data['message'])) {
            $object->setMessage($data['message']);
        }
        if (isset($data['containing-class'])) {
            $object->setClassName($data['containing-class']);
        }
        if (isset($data['certname'])) {
            $object->setNodeName($data['certname']);
        }
        if (isset($data['status'])) {
            $object->setStatus($data['status']);
        }
        return $object;
    }
894981
public function addActivity(\CampaignChain\CoreBundle\Entity\Activity $activities)
    {
        $this->activities[] = $activities;

        return $this;
    }
871931
public static function hydrate(stdClass $license)
    {
        $hydrated = new LicenseEntity();

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

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

        if (isset($license->valid_until)) {
            $hydrated->setValidUntil(new DateTime($license->valid_until));
        }

        if (isset($license->quota_distributed)) {
            $hydrated->setQuotaDistributed($license->quota_distributed);
        }

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

        if (isset($license->parent)) {
            $hydrated->setParent(self::hydrate($license->parent));
        }

        if (isset($license->child)) {
            $hydrated->setChild(self::hydrate($license->child));
        }

        if (isset($license->organization)) {
            $hydrated->setOrganization(OrgHydrator::hydrate($license->organization));
        }

        return $hydrated;
    }
11311
public function hydrate(array $data, $object)
    {
        if (!isset($data['album'])) {
            return $object;
        }

        $hydrators = new AggregateHydrator();
        $hydrators->add(new AlbumHydrator());
        $hydrators->add(new ImageCollectionAwareHydrator());

        $object->setAlbum($hydrators->hydrate($data['album'], new Album()));

        return $object;
    }
318714
public function hydrate(array &$data, $object)
    {
        foreach ($data as $property => $value) {
            $this->hydrateProperty($property, $value, $object);
        }
        
        return $object;
    }
1310456
public static function hydrate(stdClass $review)
    {
        $hydrated = new ReviewEntity();

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

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

        if (isset($review->type)) {
            $hydrated->setType(ReviewTypeHydrator::hydrate($review->type));
        }

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

        if (isset($review->source)) {
            $hydrated->setSource($review->source);
        }

        if (isset($review->issue)) {
            $hydrated->setIssue(IssueHydrator::hydrate($review->issue));
        }

        return $hydrated;
    }
1100966
public static function hydrate(stdClass $acl)
    {
        $hydrated = new AclEntity();

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

        if (isset($acl->owner_user)) {
            $hydrated->setOwnerUser(UserHydrator::hydrate($acl->owner_user));
        }

        if (isset($acl->owner_team)) {
            $hydrated->setOwnerTeam(TeamHydrator::hydrate($acl->owner_team));
        }

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

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

        if (isset($acl->view)) {
            $hydrated->setView($acl->view);
        }

        if (isset($acl->delete)) {
            $hydrated->setDelete($acl->delete);
        }

        if (isset($acl->create)) {
            $hydrated->setCreate($acl->create);
        }

        if (isset($acl->edit)) {
            $hydrated->setEdit($acl->edit);
        }

        if (isset($acl->scan)) {
            $hydrated->setScan($acl->scan);
        }

        if (isset($acl->manage)) {
            $hydrated->setManage($acl->manage);
        }

        if (isset($acl->immutable)) {
            $hydrated->setImmutable($acl->immutable);
        }

        return $hydrated;
    }
472160
public static function hydrate(stdClass $application)
    {
        $hydrated = new ApplicationEntity();

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

        if (isset($application->name)) {
            $hydrated->setName($application->name);
        }

        if (isset($application->current_scan)) {
            $hydrated->setCurrentScan($application->current_scan);
        }

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

        if (isset($application->charged_quota)) {
            $hydrated->setChargedQuota(QuotaHydrator::hydrate($application->charged_quota));
        }

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

        if (isset($application->organization)) {
            $hydrated->setOrganization(OrgHydrator::hydrate($application->organization));
        }

        if (isset($application->auto_renew)) {
            $hydrated->setAutoRenew($application->auto_renew);
        }

        return $hydrated;
    }
1321527
public static function hydrate(stdClass $process)
    {
        $hydrated = new ProcessEntity();

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

        if (isset($process->pid)) {
            $hydrated->setPid($process->pid);
        }

        if (isset($process->version)) {
            $hydrated->setVersion($process->version);
        }

        if (isset($process->name)) {
            $hydrated->setName($process->name);
        }

        if (isset($process->started_at)) {
            $hydrated->setStartedAt(new DateTime($process->started_at));
        }

        if (isset($process->finished_at)) {
            $hydrated->setFinishedAt(new DateTime($process->finished_at));
        }

        if (isset($process->finished)) {
            $hydrated->setFinished($process->finished);
        }

        if (isset($process->memory)) {
            $hydrated->setMemory($process->memory);
        }

        if (isset($process->phase)) {
            $hydrated->setPhase($process->phase);
        }

        if (isset($process->percent)) {
            $hydrated->setPercent($process->percent);
        }

        if (isset($process->weight)) {
            $hydrated->setWeight($process->weight);
        }

        return $hydrated;
    }