Total Complexity | 8 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class StringToArrayParser extends AbstractStepTransformer |
||
6 | { |
||
7 | /** |
||
8 | * Steps that should be taken to transform the string from raw to end result. |
||
9 | * |
||
10 | * @return array |
||
11 | */ |
||
12 | protected static function getTransformerSteps() |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * Replace `string with "quotes" inside` with `"string with \"quotes\" inside"`. |
||
19 | * |
||
20 | * @param string $string |
||
21 | * |
||
22 | * @return string |
||
23 | */ |
||
24 | protected static function transformWrapInQuotes(string $content) { |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Replace `"string", "another"` with `["string", "another"]`. |
||
38 | * |
||
39 | * @param string $content |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | protected static function transformWrapInArrayBrackets(string $content) { |
||
44 | // Once again, if it's already wrapped we do nothing and |
||
45 | // assume it's correct. |
||
46 | if(starts_with($content, '[') && ends_with($content, ']')) { |
||
47 | return $content; |
||
48 | } |
||
49 | |||
50 | return "[$content]"; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Decode JSON string into PHP array. |
||
55 | * |
||
56 | * @param $content |
||
57 | * |
||
58 | * @return array|null |
||
59 | */ |
||
60 | protected static function transformDecode(string $content) { |
||
62 | } |
||
63 | } |
||
64 |