Conditions | 4 |
Paths | 4 |
Total Lines | 27 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
22 | public function __invoke(Container $app) |
||
23 | { |
||
24 | if ($app["serializer.namingStrategy"] instanceof PropertyNamingStrategyInterface) { |
||
25 | $namingStrategy = $app["serializer.namingStrategy"]; |
||
26 | } else { |
||
27 | switch ($app["serializer.namingStrategy"]) { |
||
28 | case "IdenticalProperty": |
||
29 | $namingStrategy = new IdenticalPropertyNamingStrategy(); |
||
30 | break; |
||
31 | case "CamelCase": |
||
32 | $separator = $app["serializer.namingStrategy.separator"]; |
||
33 | $lowerCase = $app["serializer.namingStrategy.lowerCase"]; |
||
34 | $namingStrategy = new CamelCaseNamingStrategy($separator, $lowerCase); |
||
35 | break; |
||
36 | default: |
||
37 | throw new ServiceUnavailableHttpException( |
||
38 | null, |
||
39 | "Unknown property naming strategy '{$app["serializer.namingStrategy"]}'. " . |
||
40 | "Allowed values are 'IdenticalProperty' or 'CamelCase'" |
||
41 | ); |
||
42 | } |
||
43 | |||
44 | $namingStrategy = new SerializedNameAnnotationStrategy($namingStrategy); |
||
45 | } |
||
46 | |||
47 | return $namingStrategy; |
||
48 | } |
||
49 | } |