Process atx-style heading
@return string
@param $type string
@param $str string
489843
protected function _atx($type,$str) {
		$level=strlen($type);
		return '<h'.$level.' id="'.Web::instance()->slug($str).'">'.
			$this->scan($str).'</h'.$level.'>'."\n\n";
	}
735089
public static function title(string $str, string $encoding = null) : string
    {
        return mb_convert_case($str, MB_CASE_TITLE, $encoding ?: utils\Str::encoding($str));
    }
240047
protected function cleanType(?string $type): ?string
    {
        if (!$type || in_array(strtolower($type), ['null', 'mixed']) || strpos($type, '|')) {
            return null;
        }
        $lowerType = strtolower($type);
        if (in_array(ltrim($lowerType, '?'), [
            'array', 'int', 'integer', 'bool', 'boolean', 'float', 'double', 
            'real', 'string', 'object', 'unset', 'callback'
        ])) {
            return $lowerType;
        }
        return '\\' . ltrim($type, '\\');
    }
554316
protected function _img($str) {
		return preg_replace_callback(
			'/!(?:\[(.+?)\])?\h*\(<?(.*?)>?(?:\h*"(.*?)"\h*)?\)/',
			function($expr) {
				return '<img src="'.$expr[2].'"'.
					(empty($expr[1])?
						'':
						(' alt="'.$this->esc($expr[1]).'"')).
					(empty($expr[3])?
						'':
						(' title="'.$this->esc($expr[3]).'"')).' />';
			},
			$str
		);
	}
1367075
private function header2Array($str)
    {
        if (is_array($str)) return $str;
        
        $result = [];
        $array = explode("\n", trim(str_replace("\r\n", "\n", $str), "\n"));
        foreach($array as $i => $line) {
            if ($i === 0) {
                $result['Http-Status'] = $line; // "HTTP/1.1 200 OK"
            } else {
                $header = explode(':', $line, 2);
                if (!$header[0]) continue;
                
                if (isset($header[1])) {
                    $result[trim($header[0])] = trim($header[1]);
                } else {
                    $result[] = trim($header[0]);
                }
            }
        }
        return $result;
    }
1276303
function addr_append($type, $addr) {
      $addr_str = "";
      $addr_str .= sprintf("%s: %s <%s>", $type, $addr[0][1], $addr[0][0]);
      if(count($addr) > 1)
      {
         for($i = 1; $i < count($addr); $i++)
         {
            $addr_str .= sprintf(", %s <%s>", $addr[$i][1], $addr[$i][0]);
         }
         $addr_str .= "\r\n";
      }
      else
         $addr_str .= "\r\n";

      return($addr_str);
   }
485553
private static function _parseHttpSocketHeader($str) {
    $slice = explode("\r\n", $str);
    $headers = array();

    foreach ($slice as $v) {
      if (false !== strpos($v, "HTTP")) {
        list(, $headers["http_code"]) = explode(" ", $v);
        $headers["status"] = $v;
      } else {
        $item = explode(":", $v);
        $headers[$item[0]] = isset($item[1]) ? $item[1] : '';
      }
    }

    return $headers;
  }
507683
public function makeExceptionHeader(StyleType $type): ?Style
    {
        if (!$type->isExceptionHeader()) {
            return null;
        }

        return Style::make()
            ->setBgColor(Color::RED())
            ->setFgColor(Color::WHITE())
            ->bold()
            ->margin(2)
            ->padding(2)
            ->align(Align::CENTER());
    }
526492
private function parseHeaders($str) {

		if(false === is_string($str)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($str)), E_USER_ERROR);
		}
		
		$headers = [];
		$status  = [];

		foreach(explode("\n", $str) as $header) {
			
			if(preg_match('/(:)/is', $header)) {
				list($key, $value) = preg_split('/(:)/is', $header, 2);
			}
			else {
				$key = $header;
			}

			if(trim($key) !== '') {

				if(preg_match('/(https?\/[0-9]\.[0-9])/i', $key, $http)) {

					$status['code'] = null;

					if(preg_match('/([0-9]+)/', ltrim($key, $http[0]), $code)) {
						$status['code'] = $code[0];
					}

					$status['protocol'] = $http[0];
					$status['status'] 	= trim($key);
					$status['text'] 	= trim(ltrim(trim(ltrim($key, $status['protocol'])), $status['code']));
					
				}
				else {
					$headers[strtolower($key)] = trim($value);
				}
			}
		}

		return ['headers' => $headers, 'status' => $status];
	}
917399
public static function toNs($p_str, $p_type)
    {
        $ns    = '';
        $parts = explode('::', $p_str);
        if (count($parts) != 2) {
            return false;
        }
        $start = str_replace('.', '\\', $parts[0]);
        return '\\' . $start . '\\' . self::toCamelCase($p_type, true) . '\\' . $parts[2];
    }
763919
public function print(
        string $str,
        string $contentType = null
    ): ResponseInterface
    {
        $body = Factory::streamFromFile('php://temp', 'wb+');
        $body->write($str);
        $body->rewind();

        if ($contentType) {
            $this->header->set('Content-Type', $contentType);
        }

        return $this->setStatus(200)->response($body);
    }
1161991
public function preProcessString($str)
    {
        $str = str_replace("<?php", "", $str);
        $str = str_replace("<?", "", $str);
        $str = str_replace("?>", "", $str);
        $str = str_replace("'", "\x22", $str);

        $str = trim($str);

        return $str;
    }
1371299
public static function format($str)
    {
        preg_match('/<[A-Za-z0-9]+?>/', $str, $matches);

        foreach ($matches as $match) {
            $keyword = str_replace(array('<', '>'), '', $match);

            $format = static::$collection->get(strtolower($keyword));

            if (!empty($format)) {
                $foreground = (!isset($format['foreground']) ? '' : "\33[".$format['foreground']."m");
                $background = (!isset($format['background']) ? '' : "\33[".$format['background']."m");

                $str = str_replace(
                    array('<'.$keyword.'>', '</'.$keyword.'>'),
                    array($foreground.$background, "\33[0m"),
                    $str
                );
            }
        }

        return $str;
    }
61160
public static function phone($str, $country='', $types=array()) {
		ref\format::phone($str, $country, $types);
		return $str;
	}
294724
protected function outputConv(string $str): string
    {
        if ($str === '') {
            return '';
        }

        return \iconv('UTF-32', $this->encoding, static::$utf32Header . $str);
    }
18480
public function processEscaped($value, $type = CorePDO::PARAM_STR)
    {
        if (!in_array($type, [CorePDO::PARAM_STR, CorePDO::PARAM_LOB])) {
            return $this->process($value, $type);
        }

        return $this->stringEscaped($value);
    }
908462
public function success($str = 'Success', $sub_header = null)
    {
        // by using this hook you can overwrite default behavior of this method
        if ($this->hookHasCallbacks('displaySuccess')) {
            return $this->hook('displaySuccess', [$str, $sub_header]);
        }

        /* below code works, but pollutes output with bad id=xx
        $success = new Message([$str, 'id'=>false, 'type'=>'success', 'icon'=>'check']);
        $success->app = $this->app;
        $success->init();
        $success->text->addParagraph($sub_header);
         */
        $success = $this->app->loadTemplate($this->successTemplate);
        $success['header'] = $str;

        if ($sub_header) {
            $success['message'] = $sub_header;
        } else {
            $success->del('p');
        }

        $js = $this->js()
            ->html($success->render());

        return $js;
    }