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() { |
||
32 | |||
33 | /** |
||
34 | * Turn a list of machine names into a upper-cased string. |
||
35 | * |
||
36 | * @return string |
||
37 | * A upper-cased concatenation of the input components. |
||
38 | */ |
||
39 | public static function upperCase() { |
||
43 | |||
44 | /** |
||
45 | * Turn a list of machine names into a property-cased string. |
||
46 | * |
||
47 | * @return string |
||
48 | * A camel-cased concatenation of the input components. |
||
49 | */ |
||
50 | public static function propCase() { |
||
54 | |||
55 | /** |
||
56 | * Wraps a type string in brackets declaring it as a list. |
||
57 | * |
||
58 | * @param string $type |
||
59 | * The type to declare as a list. |
||
60 | * |
||
61 | * @return string |
||
62 | * The decorated type string. |
||
63 | */ |
||
64 | public static function listType($type) { |
||
67 | |||
68 | /** |
||
69 | * Appends an exclamation mark to a type string declaring it as non-null. |
||
70 | * |
||
71 | * @param string $type |
||
72 | * The type to declare as non-null. |
||
73 | * |
||
74 | * @return string |
||
75 | * The decorated type string. |
||
76 | */ |
||
77 | public static function nonNullType($type) { |
||
80 | |||
81 | /** |
||
82 | * Decorates a type as non-null and/or as a list. |
||
83 | * |
||
84 | * @param string $type |
||
85 | * The type to declare as non-null. |
||
86 | * @param bool $list |
||
87 | * Whether to mark the type as a list. |
||
88 | * @param bool $required |
||
89 | * Whether to mark the type as required. |
||
90 | * |
||
91 | * @return string |
||
92 | * The decorated type. |
||
93 | */ |
||
94 | public static function decorateType($type, $list = FALSE, $required = FALSE) { |
||
105 | |||
106 | /** |
||
107 | * Parses a type definition from a string and properly decorates it. |
||
108 | * |
||
109 | * Converts type strings (e.g. [Foo!]) to their object representations. |
||
110 | * |
||
111 | * @param string $type |
||
112 | * The type string to parse. |
||
113 | * |
||
114 | * @return array |
||
115 | * The extracted type with the type decorators. |
||
116 | */ |
||
117 | public static function parseType($type) { |
||
140 | |||
141 | } |