Hydrate a comment object into a CommentEntity object

@param stdClass $comment
@return CommentEntity
431858
public static function hydrate(stdClass $comment)
    {
        $hydrated = new CommentEntity();

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

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

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

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

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

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

        return $hydrated;
    }
163233
protected function getCommentDataProvider($commentClass)
    {
        $dataProvider = new ArrayDataProvider($this->dataProviderConfig);
        if (!isset($this->dataProviderConfig['allModels'])) {
            $dataProvider->allModels = $commentClass::getTree($this->entity, $this->entityId, $this->maxLevel);
        }

        return $dataProvider;
    }
764835
public function update(string $comment, array $params = [])
    {
        $path = $this->buildCommentsPath($comment);

        return $this->put($path, $params);
    }
834580
public function serialize(Comment $comment, array $options = [])
    {
        $user = $comment->getUser();

        $serialized = [
            'id' => $comment->getUuid(),
            'content' => $comment->getContent(),
            'status' => $comment->getStatus(),
            'creationDate' => $comment->getCreationDate() ? $comment->getCreationDate()->format('Y-m-d H:i:s') : null,
            'editionDate' => $comment->getEditionDate() ? $comment->getEditionDate()->format('Y-m-d H:i:s') : null,
            'user' => $user ? $this->userSerializer->serialize($user, [Options::SERIALIZE_MINIMAL]) : null,
        ];

        return $serialized;
    }
38519
public static function create($comment) {
    $block_comment = new LineCommentBlockNode();
    $comment = trim($comment);
    $lines = array_map('rtrim', explode("\n", $comment));
    foreach ($lines as $line) {
      $comment_node = new CommentNode(T_COMMENT, '// ' . $line . "\n");
      $block_comment->addChild($comment_node);
    }
    return $block_comment;
  }
1374612
protected function outputComment($comment)
	{
		if ($this->commentOptions instanceof \Closure) {
			$options = call_user_func($this->commentOptions, $comment);
		} else {
			$options = $this->commentOptions;
		}
		$options = ArrayHelper::merge($options, ['data-comment-id'=>$comment->id]);
		if ($this->useBootstrapClasses) Html::addCssClass($options, 'media');

		//render comment
		echo Html::beginTag('div', $options);

			//body
			$wrapperOptions = ['class'=>'comment-wrapper'];
			if ($this->useBootstrapClasses) Html::addCssClass($wrapperOptions, 'media-body');
			echo Html::beginTag('div', $wrapperOptions);

				//title
				if (!empty($comment->title)) {
					$titleOptions = ['class'=>'comment-title'];
					if ($this->useBootstrapClasses) Html::addCssClass($titleOptions, 'media-heading');
					$title = $this->encodeCommentTitle ? Html::encode($comment->title) : $comment->title;
					echo Html::tag($this->commentTitleTag, $title, $titleOptions);
				}

				//content
				$content = $this->encodeCommentContents ? Html::encode($comment->content) : $comment->content;
				echo Html::tag('div', $content, ['class'=>'comment-content']);

				//meta
				echo Html::beginTag('dl', ['class'=>'comment-meta']);
				echo Html::tag('dt', Yii::t('app', 'Created'));
				echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->created));
				if (!empty($comment->updated) && $comment->updated != $comment->created) {
					echo Html::tag('dt', Yii::t('app', 'Updated'));
					echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->updated));
				}
				if (!empty($comment->user_id)) {
					$author = $this->authorCallback === null ? $comment->created_by : call_user_func($this->authorCallback, $comment->created_by);
					echo Html::tag('dt', Yii::t('app', 'Author'));
					echo Html::tag('dd', $author);
				}
				echo Html::endTag('dl');

			echo Html::endTag('div');
		echo Html::endTag('div');
	}
1163182
public static function hydrate(stdClass $user)
    {
        $hydrated = new UserEntity();

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

        if (isset($user->email)) {
            $hydrated->setEmail($user->email);
        }

        if (isset($user->firstname)) {
            $hydrated->setFirstname($user->firstname);
        }

        if (isset($user->lastname)) {
            $hydrated->setLastname($user->lastname);
        }

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

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

        if (isset($user->roles)) {
            $hydrated->setRoles($user->roles);
        }

        if (isset($user->root)) {
            $hydrated->setRoot($user->root);
        }

        if (isset($user->whitelisted_ips)) {
            $hydrated->setWhitelistedIps($user->whitelisted_ips);
        }

        if (isset($user->last_login)) {
            $hydrated->setLastLogin(new DateTime($user->last_login));
        }

        if (isset($user->confirmation_token)) {
            $hydrated->setConfirmationToken($user->confirmation_token);
        }

        if (isset($user->reset_token)) {
            $hydrated->setResetToken($user->reset_token);
        }

        return $hydrated;
    }
1032583
public static function hydrate(stdClass $type)
    {
        $hydrated = new TypeEntity();

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

        if (isset($type->tag)) {
            $hydrated->setTag($type->tag);
        }

        if (isset($type->description)) {
            $hydrated->setDescription($type->description);
        }

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

        if (isset($type->markup)) {
            $hydrated->setMarkup($type->markup);
        }

        if (isset($type->severity)) {
            $hydrated->setSeverity($type->severity);
        }

        if (isset($type->effort)) {
            $hydrated->setEffort($type->effort);
        }

        if (isset($type->second_order)) {
            $hydrated->setSecondOrder($type->second_order);
        }

        if (isset($type->cwe)) {
            $hydrated->setCwe($type->cwe);
        }

        if (isset($type->owasp2010)) {
            $hydrated->setOwasp2010($type->owasp2010);
        }

        if (isset($type->owasp2013)) {
            $hydrated->setOwasp2013($type->owasp2013);
        }

        if (isset($type->owasp2017)) {
            $hydrated->setOwasp2017($type->owasp2017);
        }

        if (isset($type->sans)) {
            $hydrated->setSans($type->sans);
        }

        if (isset($type->pcidss)) {
            $hydrated->setPcidss($type->pcidss);
        }

        if (isset($type->asvs301)) {
            $hydrated->setAsvs301($type->asvs301);
        }

        if (isset($type->asvs401)) {
            $hydrated->setAsvs401($type->asvs401);
        }

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

        if (isset($type->category)) {
            $hydrated->setCategory($type->category);
        }

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

        if (isset($type->resources)) {
            $hydrated->setResources(ResourceHydrator::hydrateCollection($type->resources));
        }

        if (isset($type->inactive)) {
            $hydrated->setInactive($type->inactive);
        }

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

        return $hydrated;
    }
870810
public function setComment(\Haven\CmsBundle\Entity\Comment $comment = null)
    {
        $this->comment = $comment;

        return $this;
    }
251162
public function edit(Comment $comment)
    {
        $this->authorize($comment);

        pageinfo([
            'title' => __('comments.edit_page'),
            'robots' => 'noindex,follow',
        ]);

        return $this->makeResponse('edit', compact('comment'));
    }
1146387
public static function hydrate(stdClass $language)
    {
        $hydrated = new LanguageEntity();

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

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

        if (isset($language->file_extensions)) {
            $hydrated->setFileExtensions($language->file_extensions);
        }

        if (isset($language->config_file_extensions)) {
            $hydrated->setConfigFileExtensions($language->config_file_extensions);
        }

        return $hydrated;
    }
64142
public function addComment($comment)
    {
        if (is_string($comment)) {
            $comment = AnHelperString::trim($comment);

            $comment = array(
                'author' => get_viewer() ,
                'body' => $comment,
                'component' => $this->component,
            );
        }

        $comment = $this->_mixer->comments->addNew($comment);

        if ($this->_mixer->isSubscribable() && !$this->_mixer->subscribed($comment->author)) {
            $this->_mixer->addSubscriber($comment->author);
        }

        return $comment;
    }
305510
public static function hydrate(stdClass $patch)
    {
        $hydrated = new PatchEntity();

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

        if (isset($patch->description)) {
            $hydrated->setDescription($patch->description);
        }

        if (isset($patch->examples) && is_array($patch->examples)) {
            $hydrated->setExamples($patch->examples);
        }

        if (isset($patch->type)) {
            $hydrated->setType(TypeHydrator::hydrate($patch->type));
        }

        if (isset($patch->language)) {
            $hydrated->setLanguage(LanguageHydrator::hydrate($patch->language));
        }

        if (isset($patch->parent)) {
            $hydrated->setParent(PatchHydrator::hydrate($patch->parent));
        }

        return $hydrated;
    }
1115686
public static function hydrate(stdClass $organization)
    {
        $hydrated = new OrgEntity();

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

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

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

        if (isset($organization->quotas) && is_array($organization->quotas)) {
            $hydrated->setQuotas(QuotaHydrator::hydrateCollection($organization->quotas));
        }

        if (isset($organization->trial_issue_types) && is_array($organization->trial_issue_types)) {
            $hydrated->setTrialIssueTypes(TypeHydrator::hydrateCollection($organization->trial_issue_types));
        }

        if (isset($organization->disabled)) {
            $hydrated->setDisabled($organization->disabled);
        }

        return $hydrated;
    }
1067563
public static function create($comment)
    {
        // If numeric, create the comment
        if (is_numeric($comment)) {
            // Retrieve the transient
            $transientKey = sprintf('WPMVC\Models\Comment(%d)', $comment);
            $storedData = get_transient($transientKey);
            // If the transient doesn't yet exist, query for it!
            if ($storedData === false) {
                // Retrieve the comment object
                $comment = get_comment(intval($comment));
                // Store the transient
                set_transient($transientKey, $comment, $this->transientTimeout);
            } else {
                $comment = $storedData;
            }
        } elseif (is_array($comment)) {
            // Convert array into object
            $comment = (object) $comment;
        }
        return new static($comment);
    }
556341
private function getDocDescription($comment)
    {
        $result = null;
        if (preg_match('/\*\s+([^@]*)\s+/s', $comment, $matches)) {
            $result = str_replace('*', "\n", trim(trim($matches[1], '*')));
        }

        return $result;
    }
854226
public static function hydrate(stdClass $taint)
    {
        $hydrated = new TaintEntity();

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

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

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

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

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

        return $hydrated;
    }