| @@ 60-71 (lines=12) @@ | ||
| 57 | return $fields; |
|
| 58 | } |
|
| 59 | ||
| 60 | protected function getFieldsCode(array $fields) { |
|
| 61 | $code = ''; |
|
| 62 | foreach ($fields as $typeName => $field) { |
|
| 63 | $code .= sprintf("\t'%s' => %s::getSerializer()->getFields(),\n", $typeName, $field->getPhpName()); |
|
| 64 | } |
|
| 65 | ||
| 66 | if (strlen($code) > 0) { |
|
| 67 | $code = substr($code, 0, -2); |
|
| 68 | } |
|
| 69 | ||
| 70 | return sprintf("[\n%s\n]", $code); |
|
| 71 | } |
|
| 72 | ||
| 73 | } |
|
| 74 | ||
| @@ 201-212 (lines=12) @@ | ||
| 198 | * @param array $array |
|
| 199 | * @return string |
|
| 200 | */ |
|
| 201 | public function arrayToCode(array $array) { |
|
| 202 | $fields = ''; |
|
| 203 | foreach ($array as $item) { |
|
| 204 | $fields .= sprintf("'%s', ", $item); |
|
| 205 | } |
|
| 206 | ||
| 207 | if (strlen($fields) > 0) { |
|
| 208 | $fields = substr($fields, 0, -2); |
|
| 209 | } |
|
| 210 | ||
| 211 | return sprintf('[%s]', $fields); |
|
| 212 | } |
|
| 213 | ||
| 214 | public function mapToCode(array $array) { |
|
| 215 | $fields = ''; |
|
| @@ 214-225 (lines=12) @@ | ||
| 211 | return sprintf('[%s]', $fields); |
|
| 212 | } |
|
| 213 | ||
| 214 | public function mapToCode(array $array) { |
|
| 215 | $fields = ''; |
|
| 216 | foreach ($array as $k => $item) { |
|
| 217 | $fields .= sprintf("\t'%s' => %s,\n", $k, $this->arrayToCode($item)); |
|
| 218 | } |
|
| 219 | ||
| 220 | if (strlen($fields) > 0) { |
|
| 221 | $fields = substr($fields, 0, -2); |
|
| 222 | } |
|
| 223 | ||
| 224 | return sprintf("[\n%s\n]", $fields); |
|
| 225 | } |
|
| 226 | ||
| 227 | public function getFilename(AbstractPhpStruct $struct) { |
|
| 228 | $package = $this->packageService->getPackage(); |
|