@@ -2,13 +2,13 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace HnrAzevedo\Datamanager; |
4 | 4 | |
5 | -trait SynchronizeTrait{ |
|
5 | +trait SynchronizeTrait { |
|
6 | 6 | use CrudTrait; |
7 | 7 | |
8 | 8 | protected ?string $table = null; |
9 | 9 | protected ?string $primary = null; |
10 | 10 | protected bool $full = false; |
11 | - protected static ?array $describe = null; |
|
11 | + protected static ? array $describe = null; |
|
12 | 12 | |
13 | 13 | protected function synchronize(string $table, ?string $primary = null) |
14 | 14 | { |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | { |
44 | 44 | $type = $value; |
45 | 45 | |
46 | - if(strpos($value,'(')){ |
|
47 | - $type = (in_array( substr($value, 0, strpos($value,'(')) , ['varchar','char','text'])) ? 'string' : $type; |
|
48 | - $type = (in_array( substr($value, 0, strpos($value,'(')) , ['tinyint','mediumint','smallint','bigtint','int'])) ? 'int' : $type; |
|
49 | - $type = (in_array( substr($value, 0, strpos($value,'(')) , ['decimal','float','double','real'])) ? 'float' : $type; |
|
46 | + if (strpos($value, '(')) { |
|
47 | + $type = (in_array(substr($value, 0, strpos($value, '(')), ['varchar', 'char', 'text'])) ? 'string' : $type; |
|
48 | + $type = (in_array(substr($value, 0, strpos($value, '(')), ['tinyint', 'mediumint', 'smallint', 'bigtint', 'int'])) ? 'int' : $type; |
|
49 | + $type = (in_array(substr($value, 0, strpos($value, '(')), ['decimal', 'float', 'double', 'real'])) ? 'float' : $type; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $this->mountTable_Maxlength($field, $type, $value); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | |
56 | 56 | protected function mountTable_Maxlength(string $field, string $type, $default = null) |
57 | 57 | { |
58 | - $maxlength = (in_array( $type , ['string','float','int'])) ? substr($default,(strpos($default,'(')+1),-1) : 0; |
|
59 | - $maxlength = (in_array( $type , ['date'])) ? 10 : $maxlength; |
|
60 | - $maxlength = (in_array( $type , ['datetime'])) ? 19 : $maxlength; |
|
61 | - $maxlength = (in_array( $type , ['boolean'])) ? 1 : $maxlength; |
|
58 | + $maxlength = (in_array($type, ['string', 'float', 'int'])) ? substr($default, (strpos($default, '(') + 1), -1) : 0; |
|
59 | + $maxlength = (in_array($type, ['date'])) ? 10 : $maxlength; |
|
60 | + $maxlength = (in_array($type, ['datetime'])) ? 19 : $maxlength; |
|
61 | + $maxlength = (in_array($type, ['boolean'])) ? 1 : $maxlength; |
|
62 | 62 | $this->$field = ['maxlength' => $maxlength]; |
63 | 63 | } |
64 | 64 |