22
33namespace Webfactor \Laravel \Generators \Contracts ;
44
5- abstract class MigrationFieldAbstract implements FieldTypeInterface
6- {
7- private $ name ;
5+ use Webfactor \ Laravel \ Generators \ Traits \ CrudColumn ;
6+ use Webfactor \ Laravel \ Generators \ Traits \ CrudField ;
7+ use Webfactor \ Laravel \ Generators \ Traits \ ValidationRule ;
88
9- private $ nullable = false ;
9+ abstract class MigrationFieldAbstract implements MigrationFieldTypeInterface
10+ {
11+ use CrudColumn, CrudField, ValidationRule;
1012
11- private $ unique = false ;
13+ private $ name ;
1214
13- private $ default = null ;
15+ private $ nullable ;
1416
15- private $ foreign = null ;
17+ private $ unique ;
1618
1719 public function __construct (string $ name , array $ options = [])
1820 {
1921 $ this ->name = $ name ;
2022
2123 foreach ($ options as $ option ) {
22- $ this ->fillObject ($ option );
24+ $ this ->parseOptions ($ option );
2325 }
2426 }
2527
26- private function fillObject (string $ param )
28+ private function parseOptions (string $ param )
2729 {
2830 if ($ param == 'nullable ' ) {
2931 return $ this ->nullable = true ;
@@ -33,10 +35,6 @@ private function fillObject(string $param)
3335 return $ this ->unique = true ;
3436 }
3537
36- if ($ param == 'foreign ' ) {
37- return $ this ->foreign = true ;
38- }
39-
4038 if (starts_with ($ param , 'default( ' )) {
4139 preg_match ('/\((.*)\)/ ' , $ param , $ match );
4240
@@ -52,22 +50,6 @@ public function getName()
5250 return $ this ->name ;
5351 }
5452
55- /**
56- * @return string
57- */
58- public function getType ()
59- {
60- return $ this ->type ;
61- }
62-
63- /**
64- * @return mixed
65- */
66- public function getDefault ()
67- {
68- return $ this ->default ;
69- }
70-
7153 /**
7254 * @return bool
7355 */
@@ -83,10 +65,4 @@ public function isUnique(): bool
8365 {
8466 return $ this ->unique ;
8567 }
86-
87- abstract public function getRule (): string ;
88-
89- abstract public function getColumn (): array ;
90-
91- abstract public function getField (): array ;
9268}
0 commit comments