We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 055d0b9 commit 0334d28Copy full SHA for 0334d28
1 file changed
src/Utility/StringHelper.php
@@ -64,4 +64,29 @@ public static function nonNullType($type) {
64
return "$type!";
65
}
66
67
+ /**
68
+ * Decorates a type as non-null and/or as a list.
69
+ *
70
+ * @param string $type
71
+ * The type to declare as non-null.
72
+ * @param bool $list
73
+ * Whether to mark the type as a list.
74
+ * @param bool $required
75
+ * Whether to mark the type as required.
76
77
+ * @return string
78
+ * The decorated type.
79
+ */
80
+ public static function decorateType($type, $list = FALSE, $required = FALSE) {
81
+ if (!empty($list)) {
82
+ $type = static::listType($type);
83
+ }
84
+
85
+ if (!empty($required)) {
86
+ $type = static::nonNullType($type);
87
88
89
+ return $type;
90
91
92
0 commit comments