1 | <?php |
||
5 | class StringHelper { |
||
6 | |||
7 | /** |
||
8 | * Turn a list of machine names into a camel-cased string. |
||
9 | * |
||
10 | * @return string |
||
11 | * A camel-cased concatenation of the input components. |
||
12 | * |
||
13 | * @throws \InvalidArgumentException |
||
14 | * If the provided input does can't be converted to a specification compliant |
||
15 | * string representation for field or type names. |
||
16 | */ |
||
17 | public static function camelCase() { |
||
36 | |||
37 | /** |
||
38 | * Turn a list of machine names into a upper-cased string. |
||
39 | * |
||
40 | * @return string |
||
41 | * A upper-cased concatenation of the input components. |
||
42 | */ |
||
43 | public static function upperCase() { |
||
47 | |||
48 | /** |
||
49 | * Turn a list of machine names into a property-cased string. |
||
50 | * |
||
51 | * @return string |
||
52 | * A camel-cased concatenation of the input components. |
||
53 | */ |
||
54 | public static function propCase() { |
||
58 | |||
59 | /** |
||
60 | * Wraps a type string in brackets declaring it as a list. |
||
61 | * |
||
62 | * @param string $type |
||
63 | * The type to declare as a list. |
||
64 | * |
||
65 | * @return string |
||
66 | * The decorated type string. |
||
67 | */ |
||
68 | public static function listType($type) { |
||
71 | |||
72 | /** |
||
73 | * Appends an exclamation mark to a type string declaring it as non-null. |
||
74 | * |
||
75 | * @param string $type |
||
76 | * The type to declare as non-null. |
||
77 | * |
||
78 | * @return string |
||
79 | * The decorated type string. |
||
80 | */ |
||
81 | public static function nonNullType($type) { |
||
84 | |||
85 | /** |
||
86 | * Decorates a type as non-null and/or as a list. |
||
87 | * |
||
88 | * @param string $type |
||
89 | * The type to declare as non-null. |
||
90 | * @param bool $list |
||
91 | * Whether to mark the type as a list. |
||
92 | * @param bool $required |
||
93 | * Whether to mark the type as required. |
||
94 | * |
||
95 | * @return string |
||
96 | * The decorated type. |
||
97 | */ |
||
98 | public static function decorateType($type, $list = FALSE, $required = FALSE) { |
||
109 | |||
110 | /** |
||
111 | * Parses a type definition from a string and properly decorates it. |
||
112 | * |
||
113 | * Converts type strings (e.g. [Foo!]) to their object representations. |
||
114 | * |
||
115 | * @param string $type |
||
116 | * The type string to parse. |
||
117 | * |
||
118 | * @return array |
||
119 | * The extracted type with the type decorators. |
||
120 | */ |
||
121 | public static function parseType($type) { |
||
144 | |||
145 | } |