1 | <?php |
||
20 | class TextHelper extends Base |
||
21 | { |
||
22 | /** |
||
23 | * HTML escaping. |
||
24 | * |
||
25 | * @param string $value Value to escape |
||
26 | * |
||
27 | * @return string |
||
28 | */ |
||
29 | public function e($value) |
||
33 | |||
34 | /** |
||
35 | * Markdown transformation. |
||
36 | * |
||
37 | * @param string $text |
||
38 | * @param bool $isPublicLink |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | public function markdown($text, $isPublicLink = false) |
||
49 | |||
50 | /** |
||
51 | * Escape Markdown text that need to be stored in HTML attribute. |
||
52 | * |
||
53 | * @param string $text |
||
54 | * |
||
55 | * @return mixed |
||
56 | */ |
||
57 | public function markdownAttribute($text) |
||
61 | |||
62 | /** |
||
63 | * Format a file size. |
||
64 | * |
||
65 | * @param int $size Size in bytes |
||
66 | * @param int $precision Precision |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function bytes($size, $precision = 2) |
||
77 | |||
78 | /** |
||
79 | * Get the number of bytes from PHP size. |
||
80 | * |
||
81 | * @param int $val PHP size (example: 2M) |
||
82 | * |
||
83 | * @return int |
||
84 | */ |
||
85 | public function phpToBytes($val) |
||
101 | |||
102 | /** |
||
103 | * Return true if needle is contained in the haystack. |
||
104 | * |
||
105 | * @param string $haystack Haystack |
||
106 | * @param string $needle Needle |
||
107 | * |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function contains($haystack, $needle) |
||
114 | |||
115 | /** |
||
116 | * Return a value from a dictionary. |
||
117 | * |
||
118 | * @param mixed $id Key |
||
119 | * @param array $listing Dictionary |
||
120 | * @param string $default_value Value displayed when the key doesn't exists |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | public function in($id, array $listing, $default_value = '?') |
||
132 | } |
||
133 |