Test Setup Failed
Push — master ( d6fde7...1e848b )
by Php Easy Api
04:20
created

Schema::pull()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Migratio;
4
5
use Migratio\Resource\SqlDefinitor;
6
use Migratio\Contract\SchemaContract;
7
use Migratio\Resource\PullManager\Pulling;
8
use Migratio\Resource\PushManager\Pushing;
9
use Migratio\Resource\StubManager\Stubber;
10
11
class Schema extends SchemaHelper implements SchemaContract
12
{
13
    /**
14
     * @var array $params
15
     */
16
    public $params = array();
17
18
    /**
19
     * @var $config
0 ignored issues
show
Documentation Bug introduced by
The doc comment $config at position 0 could not be parsed: Unknown type name '$config' at position 0 in $config.
Loading history...
20
     */
21
    protected $config;
22
23
    /**
24
     * @var $connection
0 ignored issues
show
Documentation Bug introduced by
The doc comment $connection at position 0 could not be parsed: Unknown type name '$connection' at position 0 in $connection.
Loading history...
25
     */
26
    protected $connection;
27
28
    /**
29
     * @var $driver
0 ignored issues
show
Documentation Bug introduced by
The doc comment $driver at position 0 could not be parsed: Unknown type name '$driver' at position 0 in $driver.
Loading history...
30
     */
31
    protected $driver;
32
33
    /**
34
     * @var $grammarPath
0 ignored issues
show
Documentation Bug introduced by
The doc comment $grammarPath at position 0 could not be parsed: Unknown type name '$grammarPath' at position 0 in $grammarPath.
Loading history...
35
     */
36
    protected $grammarPath = 'Migratio\GrammarStructure';
37
38
    /**
39
     * Schema constructor.
40
     * @param null $config
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $config is correct as it would always require null to be passed?
Loading history...
41
     */
42
    public function __construct($config=null)
43
    {
44
        $this->config           = $config;
45
        $this->driver           = $this->config['database']['driver'];
46
        $this->grammarPath      = $this->grammarPath.'\\'.ucfirst($this->driver);
47
        $this->connection       = (new SqlDefinitor($this->config))->getConnection();
48
    }
49
50
    /**
51
     * @return Pulling|mixed
52
     */
53
    public function pull()
54
    {
55
        $pulling = new Pulling($this);
56
57
        return $pulling->get();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pulling->get() targeting Migratio\Resource\PullManager\Pulling::get() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
58
    }
59
60
    /**
61
     * @return Pushing|mixed
62
     */
63
    public function push()
64
    {
65
        $pushing = new Pushing($this);
66
67
        return $pushing->handle();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pushing->handle() targeting Migratio\Resource\PushManager\Pushing::handle() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
68
    }
69
70
    /**
71
     * @return mixed|void
72
     */
73
    public function stub(...$params)
74
    {
75
        $stubber = new Stubber($this);
76
77
        return $stubber->get($params[0]);
78
    }
79
}