/** * 更换phrase */ public function refresh($phrase_size = 0) { if ($phrase_size) { $this->phrase_size = $phrase_size; } $phrase = Word::randString($this->phrase_size); $this->builder->setPhrase($phrase); return $this; }
public function speak($format = '%F %T') { $format = str_replace('%v', '{%w}', $format); $result = strftime($format, $this->getTimestamp()); if (strpos($format, '{%w}') !== false) { static $weekdays = ['0' => '日', '1' => '一', '2' => '二', '3' => '三', '4' => '四', '5' => '五', '6' => '六']; $result = Word::replaceWith($result, $weekdays, '{', '}'); } return $result; }
/** * 大写金额 */ public function toCapital() { if ($this->currency->getCode() !== 'CNY') { return; } $result = Word::spell($this->integral, true); $result .= '圆'; $percent = intval($this->millesimal / 10); if ($percent > 0) { $dime = intval($percent / 10); $result .= Word::num2char($dime, true) . '角'; if ($cent = intval($percent % 10)) { $result .= Word::num2char($caps, true) . '分'; } } else { $result .= '整'; } return $result; }
public static function generateSalt() { return Word::randHash(self::$salt_size); }
public function randString($length = 6) { $string = Word::randString($length); $this->app->writeln($string); }
function refresh() { $AB = Word::randString($this->phrase_size); $this->builder->setPhrase($AB); return $this; }
public static function format($message, array $context = []) { $content = is_null($message) ? '' : (string) $message; return Word::replaceWith($content, $context, '{', '}'); }