1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the syntaxhighligter-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\SyntaxHighlighterBundle\Encoder; |
13
|
|
|
|
14
|
|
|
use WBW\Library\Core\Utility\StringUtility; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* SyntaxHighlighter encoder. |
18
|
|
|
* |
19
|
|
|
* @author webeweb <https://github.com/webeweb/> |
20
|
|
|
* @package WBW\Bundle\SyntaxHighlighterBundle\Encoder |
21
|
|
|
* @final |
22
|
|
|
*/ |
23
|
|
|
final class SyntaxHighlighterEncoder { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Convert a array value. |
27
|
|
|
* |
28
|
|
|
* @param array $value The array value. |
29
|
|
|
* @param array $output The output array. |
30
|
|
|
* @param string $prefix The prefix. |
31
|
|
|
* @param string $suffix The suffix. |
32
|
|
|
*/ |
33
|
|
|
public static function arrayToString(array $value, array &$output, $prefix, $suffix) { |
34
|
|
|
if (null !== $value) { |
|
|
|
|
35
|
|
|
$output[] = $prefix . "[" . implode(", ", $value) . "]" . $suffix; |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Convert a boolean value. |
41
|
|
|
* |
42
|
|
|
* @param boolean $value The boolean value. |
43
|
|
|
* @param array $output The output array. |
44
|
|
|
* @param string $prefix The prefix. |
45
|
|
|
* @param string $suffix The suffix. |
46
|
|
|
*/ |
47
|
|
|
public static function booleanToString($value, array &$output, $prefix, $suffix) { |
48
|
|
|
if (null !== $value) { |
|
|
|
|
49
|
|
|
$output[] = $prefix . StringUtility::parseBoolean($value) . $suffix; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Convert a string value. |
55
|
|
|
* |
56
|
|
|
* @param string $value The string value. |
57
|
|
|
* @param array $output The output array. |
58
|
|
|
* @param string $prefix The prefix. |
59
|
|
|
* @param string $suffix The suffix. |
60
|
|
|
*/ |
61
|
|
|
public static function stringToString($value, array &$output, $prefix, $suffix) { |
62
|
|
|
if (null !== $value) { |
|
|
|
|
63
|
|
|
$output[] = $prefix . $value . $suffix; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
} |
68
|
|
|
|