Skip to content

Commit 9f3f5ff

Browse files
author
Daniel Morse
committed
feat: add logic to convert snake or camel to kebab case
1 parent 32e7e86 commit 9f3f5ff

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/core-php/src/Utils.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,16 @@ public static function buildPropsArray($items, $schema) {
147147
if (array_key_exists($key, $schema["properties"]) && $key != "attributes"){
148148
// Check the schema "type", skip over any that contain the value "array" or "object"
149149
if (array_key_exists("type", $schema["properties"][$key]) && self::isAllowedSchemaType($schema["properties"][$key]["type"])){
150-
// if (strpos($key, '_')) {
151-
// $ch = CaseHelperFactory::make(CaseHelperFactory::INPUT_TYPE_SNAKE_CASE);
152-
// } else {
153-
// $ch = CaseHelperFactory::make(CaseHelperFactory::INPUT_TYPE_CAMEL_CASE);
154-
// }
155-
156-
// $props[$ch->toKebabCase($key)] = $value;
157-
$props[$key] = $value;
150+
if (strpos($key, '-')) {
151+
$props[$key] = $value;
152+
} else {
153+
if (strpos($key, '_')) {
154+
$ch = CaseHelperFactory::make(CaseHelperFactory::INPUT_TYPE_SNAKE_CASE);
155+
} else {
156+
$ch = CaseHelperFactory::make(CaseHelperFactory::INPUT_TYPE_CAMEL_CASE);
157+
}
158+
$props[$ch->toKebabCase($key)] = $value;
159+
}
158160
}
159161
}
160162
}

0 commit comments

Comments
 (0)