/** * Checks if a string is spam or not * * @param string|array $data * @return object */ public function check($data) { $failure = 0; $messages = array(); if (is_string($data)) { $data = array('text' => $data); } $data = $this->prepareData($data); foreach ($this->detectors as $id => $detector) { $spam = false; if ($detector->detect($data)) { $spam = true; if ($detector->message()) { $messages[] = $detector->message(); } $failure++; } $this->mark($id, $spam, $detector->message()); } $result = new Result($failure > 0, $messages); if ($this->logging) { $this->log($result->isSpam(), $data); } return $result; }
/** * Tests getMessages() returns the list of messages passed in the constructor * * @covers \Hubzero\Spam\Result::getMessages * @return void */ public function testGetMessages() { $messages = ['Message one', 'Message two']; $result = new Result(true, $messages); $this->assertEquals($messages, $result->getMessages()); }