Skip to content

Commit e5fdce0

Browse files
committed
simplify function in post class
1 parent 26e22be commit e5fdce0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

classes/post/post.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -763,14 +763,13 @@ public function moodleoverflow_get_post_ratings(): object {
763763
$discussionid = $this->get_discussion()->get_id();
764764
$postratings = ratings::moodleoverflow_get_ratings_by_discussion($discussionid, $this->id);
765765

766-
$ratingsobject = new stdClass();
767-
$ratingsobject->upvotes = $postratings->upvotes;
768-
$ratingsobject->downvotes = $postratings->downvotes;
769-
$ratingsobject->votesdifference = $postratings->upvotes - $postratings->downvotes;
770-
$ratingsobject->markedhelpful = $postratings->ishelpful;
771-
$ratingsobject->markedsolution = $postratings->issolved;
772-
773-
return $ratingsobject;
766+
return (object) [
767+
'upvotes' => $postratings->upvotes,
768+
'downvotes' => $postratings->downvotes,
769+
'votesdifference' => $postratings->upvotes - $postratings->downvotes,
770+
'markedhelpful' => $postratings->ishelpful,
771+
'markedsolution' => $postratings->issolved,
772+
];
774773
}
775774

776775
/**

0 commit comments

Comments
 (0)