Code Duplication    Length = 18-19 lines in 3 locations

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
    {

src/Commands/MigrationCommand.php 2 locations

@@ 58-76 (lines=19) @@
55
        }
56
    }
57
58
    protected function getSchema()
59
    {
60
        $schema = $this->option('schema');
61
        if(! $schema){
62
            return $this->spaces(12) . "// Schema declaration";
63
        }
64
65
        $items = $schema;
66
        if( ! $this->option('parsed')){
67
            $items = $this->getArgumentParser('schema')->parse($schema);
68
        }
69
70
        $fields = [];
71
        foreach ($items as $item) {
72
            $fields[] = $this->getFieldDeclaration($item);
73
        }
74
75
        return implode(PHP_EOL, $fields);
76
    }
77
78
    protected function getAdditionals()
79
    {
@@ 106-124 (lines=19) @@
103
        return "            \$table" . implode('', $parts) . ';';
104
    }
105
106
    protected function getConstraints()
107
    {
108
        $keys = $this->option('keys');
109
        if(! $keys){
110
            return $this->spaces(12) . "// Constraints declaration";
111
        }
112
113
        $items = $keys;
114
        if(! $this->option('parsed')){
115
            $items = $this->getArgumentParser('foreign-keys')->parse($keys);
116
        }
117
118
        $constraints = [];
119
        foreach ($items as $item) {
120
            $constraints[] = $this->getConstraintDeclaration($item);
121
        }
122
123
        return implode(PHP_EOL, $constraints);
124
    }
125
126
    protected function getConstraintDeclaration($key)
127
    {