File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -37,11 +37,7 @@ public function createMachineName($name)
37
37
$ machine_name = preg_replace (self ::REGEX_MACHINE_NAME_CHARS , '_ ' , strtolower ($ name ));
38
38
$ machine_name = trim ($ machine_name , '_ ' );
39
39
40
- if (strlen ($ machine_name ) > self ::MAX_MACHINE_NAME ) {
41
- $ machine_name = substr ($ machine_name , 0 , self ::MAX_MACHINE_NAME );
42
- }
43
-
44
- return $ machine_name ;
40
+ return $ this ->trimMachineNameToMaxLength ($ machine_name );
45
41
}
46
42
47
43
/**
@@ -57,6 +53,22 @@ public function camelCaseToMachineName($name)
57
53
$ machine_name = preg_replace (self ::REGEX_MACHINE_NAME_CHARS , '_ ' , strtolower ($ machine_name ));
58
54
$ machine_name = trim ($ machine_name , '_ ' );
59
55
56
+ return $ this ->trimMachineNameToMaxLength ($ machine_name );
57
+ }
58
+
59
+ /**
60
+ * Trim machine name if it exceed max number of symbols for machine names.
61
+ *
62
+ * @param string $machine_name
63
+ * Machine name.
64
+ *
65
+ * @return string
66
+ * Machine name.
67
+ */
68
+ public function trimMachineNameToMaxLength ($ machine_name ) {
69
+ if (strlen ($ machine_name ) > self ::MAX_MACHINE_NAME ) {
70
+ $ machine_name = substr ($ machine_name , 0 , self ::MAX_MACHINE_NAME );
71
+ }
60
72
return $ machine_name ;
61
73
}
62
74
You can’t perform that action at this time.
0 commit comments