@@ -183,19 +183,7 @@ public function __construct($type, $options = [])
183183 */
184184 public function getSQLDefinition ()
185185 {
186- $ type = $ this ->getType ();
187- $ definition = strtoupper ($ type );
188- if (!in_array ($ definition , self ::TYPES_WITHOUT_LENGTH )) {
189- $ length = $ this ->getLength () ?: $ this ->getDefaultLength ();
190- // length is set, use it
191- if ($ length !== null && $ length !== '' ) {
192- if (in_array ($ definition , self ::TYPES_WITH_SIMPLE_LENGTH )) {
193- $ definition .= sprintf (' (%s) ' , $ length );
194- } elseif (array_key_exists ($ definition , self ::COMPLEX_LENGTH_DICT )) {
195- $ definition = $ this ->buildComplexLength ($ type , $ length );
196- }
197- }
198- }
186+ $ definition = $ this ->buildDefinitionString ();
199187
200188 if ($ this ->getDefault () !== null ) {
201189 $ definition .= ' DEFAULT ' . $ this ->getDefault ();
@@ -208,16 +196,29 @@ public function getSQLDefinition()
208196 }
209197
210198 /**
211- * builds SQL definition for types which don't just append the length behind the type name
212- *
213- * @param string $type
214- * @param string|int|null $lengthString
199+ * generates type with length
200+ * most of the types just append it, but some of them are complex and some have no length...
201+ * used here and in i/e lib
215202 * @return string
216203 */
217- private function buildComplexLength ( $ type , $ lengthString )
204+ public function buildDefinitionString ( )
218205 {
219- $ parts = explode (', ' , (string ) $ lengthString );
220- return sprintf (self ::COMPLEX_LENGTH_DICT [$ type ], ...$ parts );
206+ $ type = $ this ->getType ();
207+ $ definition = strtoupper ($ type );
208+ if (!in_array ($ definition , self ::TYPES_WITHOUT_LENGTH )) {
209+ $ length = $ this ->getLength () ?: $ this ->getDefaultLength ();
210+ // length is set, use it
211+ if ($ length !== null && $ length !== '' ) {
212+ if (in_array ($ definition , self ::TYPES_WITH_SIMPLE_LENGTH )) {
213+ $ definition .= sprintf (' (%s) ' , $ length );
214+ } elseif (array_key_exists ($ definition , self ::COMPLEX_LENGTH_DICT )) {
215+ $ parts = explode (', ' , (string ) $ length );
216+ $ definition = sprintf (self ::COMPLEX_LENGTH_DICT [$ type ], ...$ parts );
217+ }
218+ }
219+ }
220+
221+ return $ definition ;
221222 }
222223
223224 /**
0 commit comments