Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
DocFormater.php
Go to the documentation of this file.
1<?php
2
7
18 protected $types = [ "boolean","string","int","mixed","array" ];
19 protected $replacements = [ "types" => "<span style='font-weight:bold;color: green;'>$1</span>","variables" => "<span style='font-weight:bold;color: brown;'>$1</span>" ];
20
21 public function __construct() {
22 }
23
24 public function getReplacement($part) {
25 return $this->replacements [$part];
26 }
27
28 protected function getTypesRegex() {
29 $items = \array_map ( function ($item) {
30 return "(" . $item . ")";
31 }, $this->types );
32 return '^(' . \implode ( '|', $items ) . ').*?';
33 }
34
35 protected function getVariablesRegex() {
36 return '(\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)';
37 }
38
39 protected function _replaceAll($search, $replacement, $subject) {
40 return \preg_replace ( '@' . $search . '@i', $replacement, $subject );
41 }
42
43 public function replaceTypes($str) {
44 return $this->_replaceAll ( $this->getTypesRegex (), $this->replacements ["types"], $str );
45 }
46
47 public function replaceVariables($str) {
48 return $this->_replaceAll ( $this->getVariablesRegex (), $this->replacements ["variables"], $str );
49 }
50
51 public function replaceAll($str) {
52 $str = $this->replaceTypes ( $str );
53 return $this->replaceVariables ( $str );
54 }
55}
_replaceAll($search, $replacement, $subject)
Documentation parser.