Completed
Push — master ( 603a9f...7527cc )
by Changwan
05:44
created

Migration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 40
ccs 0
cts 13
cp 0
rs 10
wmc 3
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A up() 0 4 1
A down() 0 4 1
migrate() 0 1 ?
rollback() 0 1 ?
1
<?php
2
namespace Wandu\Service\Eloquent;
3
4
use Illuminate\Database\Capsule\Manager;
5
use Illuminate\Database\Schema\Builder;
6
use Wandu\Database\Configuration;
7
use Wandu\Migrator\Contracts\Migration as MigrationContract;
8
9
abstract class Migration implements MigrationContract 
10
{
11
    /** @var \Illuminate\Database\Capsule\Manager */
12
    protected $manager;
13
 
14
    /** @var \Wandu\Database\Configuration */
15
    protected $config;
16
    
17
    public function __construct(Manager $manager, Configuration $config)
18
    {
19
        $this->manager = $manager;
20
        $this->config = $config;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function up()
27
    {
28
        $this->migrate($this->manager->getConnection($this->config->getConnection())->getSchemaBuilder());
0 ignored issues
show
Bug introduced by
The method getConnection() does not seem to exist on object<Wandu\Database\Configuration>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function down()
35
    {
36
        $this->rollback($this->manager->getConnection($this->config->getConnection())->getSchemaBuilder());
0 ignored issues
show
Bug introduced by
The method getConnection() does not seem to exist on object<Wandu\Database\Configuration>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
    }
38
39
    /**
40
     * @param \Illuminate\Database\Schema\Builder $schema
41
     */
42
    abstract public function migrate(Builder $schema);
43
44
    /**
45
     * @param \Illuminate\Database\Schema\Builder $schema
46
     */
47
    abstract public function rollback(Builder $schema);
48
}
49