/** * Tests isSpam() returns correct value * * @covers \Hubzero\Spam\Result::isSpam * @return void */ public function testIsSpam() { $result = new Result(true); $this->assertTrue($result->isSpam()); $result = new Result(false); $this->assertFalse($result->isSpam()); }
/** * 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; }