messageDir = $messageDir; } public function setLogger(LoggerInterface $logger) { if ($logger === null) { throw new \InvalidArgumentException('A logger must be passed to the authenticator!'); } $this->logger = $logger; } public function getLogger() { return $this->logger; } public function send($username, $recipient, $message, $passwordLocations) { $rcptDir = $this->messageDir . '/' . $recipient; if (file_exists($rcptDir) && (!is_writable($rcptDir) || !is_dir($rcptDir))) { throw new \RuntimeException('Message directory is not writable!'); } if (!file_exists($rcptDir)) { mkdir($rcptDir); } $messageFileName = date('YmdHis') . '-' . uniqid() . '.sms'; $fd = fopen($rcptDir . '/' . $messageFileName, 'w'); fwrite($fd, $message); fclose($fd); $this->logger->messageLog($username, $recipient, $message, $passwordLocations); return true; } }