Code Duplication    Length = 10-11 lines in 3 locations

Command/GenerateCommand.php 1 location

@@ 259-268 (lines=10) @@
256
                    $warning = 'Note: the generated migration is empty';
257
                }
258
259
                switch ($fileType) {
260
                    case 'yml':
261
                        $code = Yaml::dump($data, 5);
262
                        break;
263
                    case 'json':
264
                        $code = json_encode($data, JSON_PRETTY_PRINT);
265
                        break;
266
                    default:
267
                        throw new \Exception("The combination of migration type '$migrationType' is not supported with format '$fileType'");
268
                }
269
        }
270
271
        file_put_contents($path, $code);

Core/Executor/ReferenceExecutor.php 1 location

@@ 149-159 (lines=11) @@
146
        $data = $this->referenceResolver->listReferences();
147
148
        $ext = pathinfo($fileName, PATHINFO_EXTENSION);
149
        switch ($ext) {
150
            case 'json':
151
                $data = json_encode($data, JSON_PRETTY_PRINT);
152
                break;
153
            case 'yml':
154
            case 'yaml':
155
                $data = Yaml::dump($data);
156
                break;
157
            default:
158
                throw new \Exception("Invalid step definition: unsupported file extension '$ext' for saving references to");
159
        }
160
161
        file_put_contents($fileName, $data);
162

Core/Executor/MigrationDefinitionExecutor.php 1 location

@@ 98-108 (lines=11) @@
95
96
            $ext = pathinfo(basename($fileName), PATHINFO_EXTENSION);
97
98
            switch ($ext) {
99
                case 'yml':
100
                case 'yaml':
101
                    $code = Yaml::dump($result, 5);
102
                    break;
103
                case 'json':
104
                    $code = json_encode($result, JSON_PRETTY_PRINT);
105
                    break;
106
                default:
107
                    throw new \Exception("Can not save generated migration to a file of type '$ext'");
108
            }
109
110
            $dir = dirname($fileName);
111
            if (!is_dir($dir)) {