. * */ namespace Vvveb\System\Traits; trait Spam { //these must be empty, they are hidden in html and only bots will fill them //todo: add dynamic field name protected $spamFields = [ 'firstname-empty', 'lastname-empty', 'subject-empty', 'contact-form', ]; function checkIfSpam(&$message) { return $message; } function isSpam(&$message) { $spam = false; foreach ($this->spamFields as $field) { if (isset($message[$field]) && ! empty($message[$field])) { return $spam = true; } } return $spam; } function removeSpamCatchFields(&$message) { foreach ($this->spamFields as $field) { if (isset($message[$field])) { unset($message[$field]); } } return $message; } }