/** * @see \str\split() split */ public static function split($string_, $lengthChunks_ = 1) { return \str\split($string_, $lengthChunks_); }
protected function compilePattern() { $available = ['l' => function () { return $this->__level; }, 'L' => function () { return self::$m_mapLevelToOutput[$this->__level]; }, 'd' => function () { return microtime(true); }, 'D' => function () { $microtime = (string) microtime(true); return date($this->patternDate, $microtime) . substr($microtime, strpos($microtime, '.')); }, 'b' => function () { return memory_get_usage(true); }, 'B' => function () { return \io\convertToMB(memory_get_usage(true)) . ' MB'; }, 'm' => function () { return $this->__message; }, 'n' => function () { return $this->__namespace; }]; $clientIp = Runtime::getClientAddress(); if (!($clientIpLong = ip2long($clientIp))) { $clientIpLong = 0; } $requestUri = '/'; if (isset($_SERVER['REQUEST_URI'])) { $requestUri = $_SERVER['REQUEST_URI']; } else { if (isset($argv) && 0 < $argc) { $requestUri = http_build_query($argv); } } $this->m_patternCompiled = \str\replace($this->pattern, ['%h', '%c', '%C', '%r'], [$this->host, $clientIpLong, $clientIp, $requestUri]); $chars = \str\split($this->pattern, 1); $count = count($chars); $placeholders = ''; $callbacks = []; for ($idx = 0; $idx < $count; $idx++) { if ('%' == $chars[$idx] && ++$idx < $count) { $placeholder = $chars[$idx]; if (isset($available[$placeholder])) { $placeholders .= $placeholder; $callbacks["%{$placeholder}"] = $available[$placeholder]; } } } $this->m_patternPlaceholder = "/(%[{$placeholders}])+/"; $this->m_patternCallbacks = $callbacks; }