CreateReleasesTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 20.41 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 10
loc 49
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B up() 10 32 1
A down() 0 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace CosmicRadioTV\Podcast\updates;
4
5
use DB;
6
use Illuminate\Database\Schema\Blueprint;
7
use October\Rain\Database\Updates\Migration;
8
use Schema;
9
10
class CreateReleasesTable extends Migration {
11
12
    /**
13
     * Migration
14
     */
15
    public function up()
16
    {
17
        DB::transaction(function() {
18 View Code Duplication
            Schema::create('cosmicradiotv_podcast_release_types', function (Blueprint $table) {
19
                $table->engine = 'InnoDB';
20
                $table->increments('id');
21
                $table->string('name');
22
                $table->string('slug');
23
                $table->string('type');
24
                $table->string('filetype');
25
26
                $table->unique('slug');
27
            });
28
29
            Schema::create('cosmicradiotv_podcast_releases', function (Blueprint $table) {
30
                $table->engine = 'InnoDB';
31
                $table->increments('id');
32
                $table->unsignedInteger('episode_id');
33
                $table->unsignedInteger('release_type_id');
34
                $table->text('url');
35
                $table->bigInteger('size');
36
                $table->timestamps();
37
38
                $table->foreign('episode_id')->references('id')->on('cosmicradiotv_podcast_episodes')
39
                      ->onUpdate('cascade');
40
                $table->foreign('release_type_id')->references('id')->on('cosmicradiotv_podcast_release_types')
41
                      ->onUpdate('cascade');
42
43
            });
44
        });
45
46
    }
47
48
    /**
49
     * Rollback
50
     */
51
    public function down()
52
    {
53
        DB::transaction(function () {
54
            Schema::drop('cosmicradiotv_podcast_releases');
55
            Schema::drop('cosmicradiotv_podcast_release_types');
56
        });
57
    }
58
}