SQLiteBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 48
ccs 16
cts 16
cp 1
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renameView() 0 16 1
A createView() 0 7 2
1
<?php
2
3
namespace Staudenmeir\LaravelMigrationViews\Schema\Builders;
4
5
use Illuminate\Database\Schema\SQLiteBuilder as Base;
6
use Illuminate\Support\Str;
7
8
class SQLiteBuilder extends Base
9
{
10
    use ManagesViews {
11
        createView as createViewParent;
12
    }
13
14
    /**
15
     * Create a new view on the schema.
16
     *
17
     * @param string $name
18
     * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|string $query
19
     * @param array|null $columns
20
     * @param bool $orReplace
21
     * @param bool $materialized
22
     * @return void
23 10
     */
24
    public function createView($name, $query, array $columns = null, $orReplace = false, bool $materialized = false)
0 ignored issues
show
Unused Code introduced by
The parameter $materialized is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

24
    public function createView($name, $query, array $columns = null, $orReplace = false, /** @scrutinizer ignore-unused */ bool $materialized = false)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25 10
    {
26 1
        if ($orReplace) {
27
            $this->dropViewIfExists($name);
28
        }
29 10
30
        $this->createViewParent($name, $query, $columns);
31
    }
32
33
    /**
34
     * Rename a view on the schema.
35
     *
36
     * @param string $from
37
     * @param string $to
38
     * @return void
39 1
     */
40
    public function renameView($from, $to)
41 1
    {
42 1
        $view = $this->connection->selectOne(
43 1
            "select * from sqlite_master where type = 'view' and name = ?",
44 1
            [$this->connection->getTablePrefix().$from]
45
        );
46 1
47
        $this->dropView($from);
48 1
49 1
        $query = Str::replaceFirst(
50 1
            $this->grammar->wrapTable($from),
51 1
            $this->grammar->wrapTable($to),
52 1
            $view->sql
53
        );
54 1
55
        $this->connection->statement($query);
56
    }
57
}
58