Completed
Push — develop ( 3b8e4a...656576 )
by Arjay
03:44 queued 02:00
created

OracleBuilder::drop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Yajra\Oci8\Schema;
4
5
use Closure;
6
use Illuminate\Database\Connection;
7
use Illuminate\Database\Schema\Builder;
8
9
class OracleBuilder extends Builder
10
{
11
    /**
12
     * @var \Yajra\Oci8\Schema\OracleAutoIncrementHelper
13
     */
14
    public $helper;
15
16
    /**
17
     * @param Connection $connection
18
     */
19
    public function __construct(Connection $connection)
20
    {
21
        $this->connection = $connection;
22
        $this->grammar    = $connection->getSchemaGrammar();
23
        $this->helper     = new OracleAutoIncrementHelper($connection);
24
    }
25
26
    /**
27
     * Create a new table on the schema.
28
     *
29
     * @param  string $table
30
     * @param  Closure $callback
31
     * @return \Illuminate\Database\Schema\Blueprint
32
     */
33
    public function create($table, Closure $callback)
34
    {
35
        $blueprint = $this->createBlueprint($table);
36
37
        $blueprint->create();
38
39
        $callback($blueprint);
40
41
        $this->build($blueprint);
42
43
        $this->helper->createAutoIncrementObjects($blueprint, $table);
44
    }
45
46
    /**
47
     * Create a new command set with a Closure.
48
     *
49
     * @param  string $table
50
     * @param  Closure $callback
51
     * @return \Illuminate\Database\Schema\Blueprint
52
     */
53
    protected function createBlueprint($table, Closure $callback = null)
54
    {
55
        $blueprint = new OracleBlueprint($table, $callback);
56
        $blueprint->setTablePrefix($this->connection->getTablePrefix());
57
58
        return $blueprint;
59
    }
60
61
    /**
62
     * Drop a table from the schema.
63
     *
64
     * @param  string $table
65
     * @return \Illuminate\Database\Schema\Blueprint
66
     */
67
    public function drop($table)
68
    {
69
        $this->helper->dropAutoIncrementObjects($table);
70
        parent::drop($table);
71
    }
72
73
    /**
74
     * Indicate that the table should be dropped if it exists.
75
     *
76
     * @return \Illuminate\Support\Fluent
77
     */
78
    public function dropIfExists($table)
79
    {
80
        $this->helper->dropAutoIncrementObjects($table);
81
        parent::dropIfExists($table);
82
    }
83
}
84