File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
src/com/magento/idea/magento2plugin/util Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change 22 * Copyright © Magento, Inc. All rights reserved.
33 * See COPYING.txt for license details.
44 */
5+
56package com .magento .idea .magento2plugin .util ;
67
8+ import java .util .regex .Matcher ;
9+ import java .util .regex .Pattern ;
10+
711public class CamelCaseToHyphen {
812 private static CamelCaseToHyphen INSTANCE = null ;
13+
14+ /**
15+ * getInstance.
16+ * @return CamelCaseToHyphen
17+ */
918 public static CamelCaseToHyphen getInstance () {
10- if (null == INSTANCE ) INSTANCE = new CamelCaseToHyphen ();
19+ if (null == INSTANCE ) {
20+ INSTANCE = new CamelCaseToHyphen ();
21+ }
1122 return INSTANCE ;
1223 }
1324
25+ /**
26+ * convert.
27+ * @param string the origin string.
28+ * @return string
29+ */
1430 public String convert (String string ) {
15- return string .toLowerCase ();
31+ String regex = "(?=[A-Z][a-z])" ;
32+ String subst = "-" ;
33+ Pattern pattern = Pattern .compile (regex );
34+ Matcher matcher = pattern .matcher (string );
35+ String result = matcher .replaceAll (subst ).toLowerCase ();
36+ if (result .charAt (0 ) == '-' ) {
37+ return result .substring (1 );
38+ }
39+ return result ;
1640 }
1741}
You can’t perform that action at this time.
0 commit comments