Example #1
0
 /**
  * Vote commemt
  *
  * @param \MongoId $commentId
  * @param string $ref
  * @param int $uid
  * @param int $value
  * @return int|null
  * @throws InvalidArgumentException
  */
 private static function vote(\MongoId $commentId, $ref, $uid, $value)
 {
     if (!is_string($ref)) {
         throw new InvalidArgumentException('ref', 'type_invalid');
     }
     if (!mb_check_encoding($ref, 'UTF-8')) {
         throw new InvalidArgumentException('ref', 'encoding_invalid');
     }
     if (!Validator::int()->validate($uid)) {
         throw new InvalidArgumentException('uid', 'type_invalid');
     }
     return VoteUtil::vote(Application::coll('Comment'), ['_id' => $commentId, 'ref' => $ref], $uid, $value);
 }