GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( fedd90...73245c )
by w3l
01:37
created

Strings::textareaDecode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 3
c 1
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace w3l\Holt45;
3
trait Strings {
4
5
	/**
6
	 * Obfuscate string (url-safe and somewhat hard to guess).
7
	 *
8
	 * @param string $input The text that should be obfuscated
9
	 * @return string Obfuscated string
10
	 */
11
	public static function obfuscateString($input) {
12
		return bin2hex(base64_encode(strrev($input)));
13
	}
14
15
	/**
16
	 * Deobfuscate string
17
	 *
18
	 * @param string $input Obfuscated string
19
	 * @return string Deobfuscated string
20
	 */
21
	public static function deobfuscateString($input) {
22
		return strrev(base64_decode(hex2bin($input)));
23
	}
24
	
25
	/**
26
	 * Convert <textarea> to [textarea].
27
	 *
28
	 * @param string $html
29
	 * @return string
30
	 */
31
	public static function textareaEncode($html) {
32
		return preg_replace("/<textarea(.*?)>(.*?)<\/textarea>/is", "[textarea$1]$2[/textarea]", $html);
33
	}
34
	
35
	/**
36
	 * Convert [textarea] to <textarea>.
37
	 *
38
	 * @param string $html
39
	 * @return string
40
	 */
41
	public static function textareaDecode($html) {
42
		return preg_replace("/\[textarea(.*?)\](.*?)\[\/textarea\]/is", "<textarea$1>$2</textarea>", $html);
43
	}
44
45
	/**
46
	* To replace "Hallo [@var] world" with $value.
47
	*
48
	* @example replace_string($string, array("val1" => "foo", "val2" => "bar"))
49
	*
50
	* @param string $langString String containing placeholder.
51
	* @param array $dynamicContent key->value array.
52
	* @return string String with placeholder replaced.
53
	*/
54
	public static function replaceString($langString, $dynamicContent = array()) {
55
56
		foreach ($dynamicContent as $k => $v) {
57
			$langString = str_replace("[@".$k."]", $v, $langString);
58
		}
59
		return $langString;
60
	}
61
62
}
63