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

Migration::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
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