本文整理汇总了PHP中SplStack::next方法的典型用法代码示例。如果您正苦于以下问题:PHP SplStack::next方法的具体用法?PHP SplStack::next怎么用?PHP SplStack::next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplStack
的用法示例。
在下文中一共展示了SplStack::next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log
/**
* Logs with an arbitrary level.
*
* @param string $level
* @param string|array $message a textual message, encoded JSON or array to encode into JSON
* @param array $context context regarding the message, if this is included it will
* added to the message as json or included in the json payload
* @throws \InvalidArgumentException
* @return null
*/
public function log($level, $message, array $context = array())
{
$this->connectIfNotConnected();
if (is_array($message)) {
$message = json_encode($message);
}
if (!is_string($message)) {
throw new \InvalidArgumentException('the message argument needs to be a string or an array');
} else {
$isJson = $this->isJSON($message);
if ($isJson) {
$json = json_decode($message, true);
if ("" != $this->_hostname) {
$json["hostname"] = $this->_hostname;
}
$json["level"] = $level;
if (count($context) > 0) {
$json["context"] = $context;
}
$message = json_encode($json);
} else {
$message = strtoupper($level) . " - " . $message;
if ("" != $this->_hostname) {
$message = "hostname={$this->_hostname} - " . $message;
if (count($context) > 0) {
$message .= " - " . json_encode($context);
}
}
}
$this->_writer_stack->rewind();
while ($this->_writer_stack->valid()) {
/** @var LogEntriesWriter $writer */
$writer = $this->_writer_stack->current();
$message = $writer->log($message, $isJson);
$this->_writer_stack->next();
}
$this->writeToSocket($this->substituteNewline($message) . PHP_EOL);
}
}
示例2: valid
/**
* Skip null elements while validated the current one.
*
* @return bool
*/
public function valid()
{
while (true === parent::valid() && null === $this->current() && null === parent::next()) {
}
return parent::valid();
}