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

OracleBlueprint   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 46
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setTablePrefix() 0 4 1
A timestampsTz() 0 6 1
A createIndexName() 0 7 1
1
<?php
2
3
namespace Yajra\Oci8\Schema;
4
5
use Illuminate\Database\Schema\Blueprint;
6
7
class OracleBlueprint extends Blueprint
8
{
9
    /**
10
     * Database prefix variable
11
     *
12
     * @var string
13
     */
14
    protected $prefix;
15
16
    /**
17
     * set table prefix settings
18
     *
19
     * @param string $prefix
20
     */
21
    public function setTablePrefix($prefix = '')
22
    {
23
        $this->prefix = $prefix;
24
    }
25
26
    /**
27
     * Add creation and update timestampTz columns to the table.
28
     *
29
     * @return void
30
     */
31
    public function timestampsTz()
32
    {
33
        $this->timestampTz('created_at');
34
35
        $this->timestampTz('updated_at');
36
    }
37
38
    /**
39
     * Create a default index name for the table.
40
     *
41
     * @param  string $type
42
     * @param  array $columns
43
     * @return string
44
     */
45
    protected function createIndexName($type, array $columns)
46
    {
47
        $index = strtolower($this->prefix . $this->table . '_' . implode('_', $columns) . '_' . $type);
48
49
        // max index name length is 30 chars
50
        return substr(str_replace(['-', '.'], '_', $index), 0, 30);
51
    }
52
}
53