Completed
Pull Request — 4.0 (#124)
by
unknown
02:42
created

Comment   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 29.79 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B setComments() 14 26 6

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 Yajra\Oci8\Schema;
4
5
use Illuminate\Database\Connection;
6
7
class Comment
8
{
9
    /**
10
     * @var \Illuminate\Database\Connection
11
     */
12
    protected $connection;
13
14
    /**
15
     * @param Connection $connection
16
     */
17
    public function __construct(Connection $connection)
18
    {
19
        $this->connection = $connection;
20
    }
21
22
    /**
23
     * Set table and column comments.
24
     *
25
     * @param  \Yajra\Oci8\Schema\OracleBlueprint $blueprint
26
     */
27
    public function setComments(OracleBlueprint $blueprint)
28
    {
29
        // Comment set by $table->comment('comment');
30
        if ($blueprint->commentTable != null)
31
        {
32
            $this->connection->statement(sprintf('comment on table %s is \'%s\'', $blueprint->getTable(), $blueprint->commentTable));
33
        }
34
35
        // Comments set by $table->string('column')->comment('comment');
36 View Code Duplication
        foreach ($blueprint->getColumns() as $column)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
        {
38
            if (isset($column['comment']))
39
            {
40
                $this->connection->statement(sprintf('comment on column %s.%s is \'%s\'', $blueprint->getTable(), $column['name'], $column['comment']));
41
            }
42
        }
43
44
        // Comments set by $table->commentColumn('column', 'comment');
45 View Code Duplication
        foreach ($blueprint->commentColumn as $column)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
        {
47
            if (isset($column['comment']))
48
            {
49
                $this->connection->statement(sprintf('comment on column %s.%s is \'%s\'', $blueprint->getTable(), $column['name'], $column['comment']));
50
            }
51
        }
52
    }
53
}
54