/** * Produces a new message. * * @param string $type The type of message * @param mixed $message The message * * @return void * * @codeCoverageIgnore */ public function produce($type, $message) { $fp = @stream_socket_client(sprintf('tcp://%s:%d', $this->hostname, $this->port), $errno, $errstr, 30); if (!$fp) { throw new \RuntimeException(sprintf('%s (%s)', $errstr, $errno)); } fwrite($fp, Json::encode(array('type' => $type, 'message' => $message))); fclose($fp); }
/** * @param mixed $item * * @return mixed */ public function convert($item) { return Json::encode($item, $this->options); }
/** * Finish the writer. */ public function finish() { file_put_contents($this->filename, Json::encode($this->data)); }
/** * Finish the writer. */ public function finish() { $this->json = Json::encode($this->data); }