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

Comment::setComments()   B

Complexity

Conditions 6
Paths 18

Size

Total Lines 26
Code Lines 9

Duplication

Lines 14
Ratio 53.85 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 14
loc 26
rs 8.439
cc 6
eloc 9
nc 18
nop 1
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