public function analyze(MessageInterface $message) { if (mb_strpos($message->getBody(), 'spam') !== false) { $isSpam = true; $reason = 'spam word found'; } else { $isSpam = false; $reason = null; } $result = new Result($isSpam, $reason); return $result; }
/** * Convert message fields to request fields. * * @param MessageInterface $message * @return string[] */ protected function buildPostData(MessageInterface $message) { return array_filter(['ip' => $message->getIP(), 'agent' => $message->getUserAgent(), 'name' => $message->getName(), 'subject' => $message->getSubject(), 'link' => $message->getHomepage(), 'comment' => $message->getBody(), 'site' => $message->getOrigin()]); }
/** * Convert message fields to request fields. * * @param MessageInterface $message * @return string[] */ protected function buildGetData(MessageInterface $message) { return array_filter(['ip' => $message->getIP(), 'name' => $message->getName(), 'mail' => $message->getEmail()]); }