Code Duplication    Length = 18-19 lines in 3 locations

src/Commands/MigrationCommand.php 2 locations

@@ 43-61 (lines=19) @@
40
        $this->save($content, "./database/migrations/{$file}.php", "{$table} migration");
41
    }
42
43
    protected function getSchema()
44
    {
45
        $schema = $this->option('schema');
46
        if(! $schema){
47
            return $this->spaces(12) . "// Schema declaration";
48
        }
49
50
        $items = $schema;
51
        if( ! $this->option('parsed')){
52
            $items = $this->getArgumentParser('schema')->parse($schema);
53
        }
54
55
        $fields = [];
56
        foreach ($items as $item) {
57
            $fields[] = $this->getFieldDeclaration($item);
58
        }
59
60
        return implode(PHP_EOL, $fields);
61
    }
62
63
    protected function getAdditionals()
64
    {
@@ 91-109 (lines=19) @@
88
        return "            \$table" . implode('', $parts) . ';';
89
    }
90
91
    protected function getConstraints()
92
    {
93
        $keys = $this->option('keys');
94
        if(! $keys){
95
            return $this->spaces(12) . "// Constraints declaration";
96
        }
97
98
        $items = $keys;
99
        if(! $this->option('parsed')){
100
            $items = $this->getArgumentParser('foreign-keys')->parse($keys);
101
        }
102
103
        $constraints = [];
104
        foreach ($items as $item) {
105
            $constraints[] = $this->getConstraintDeclaration($item);
106
        }
107
108
        return implode(PHP_EOL, $constraints);
109
    }
110
111
    protected function getConstraintDeclaration($key)
112
    {

src/Commands/ModelCommand.php 1 location

@@ 102-119 (lines=18) @@
99
        return $relations;
100
    }
101
102
    protected function getRules()
103
    {
104
        $rules = $this->option('rules');
105
        if(! $rules){
106
            return "        // Validation rules";
107
        }
108
        $items = $rules;
109
        if(! $this->option('parsed')){
110
            $items = $this->getArgumentParser('rules')->parse($rules);
111
        }
112
        $rules = [];
113
        $template = $this->getTemplate('model/rule');
114
        foreach ($items as $item) {
115
            $rules[] = $template->with($item)->get();
116
        }
117
118
        return implode(PHP_EOL, $rules);
119
    }
120
121
    protected function getAdditional()
122
    {