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

SchemaFacade   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 107
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getSchema() 0 3 1
A getInstance() 0 6 2
A push() 0 7 1
A setConfig() 0 5 1
A tables() 0 5 1
A stub() 0 5 1
A pull() 0 7 1
1
<?php
2
3
namespace Migratio;
4
5
use Migratio\Schema;
6
use Migratio\Contract\SchemaFacadeContract;
7
use Migratio\GrammarStructure\Mysql\Wizard\Wizard;
8
9
class SchemaFacade {
10
11
    /**
12
     * @var $instance
0 ignored issues
show
Documentation Bug introduced by
The doc comment $instance at position 0 could not be parsed: Unknown type name '$instance' at position 0 in $instance.
Loading history...
13
     */
14
    protected static $instance;
15
16
    /**
17
     * @var $schema
0 ignored issues
show
Documentation Bug introduced by
The doc comment $schema at position 0 could not be parsed: Unknown type name '$schema' at position 0 in $schema.
Loading history...
18
     */
19
    protected $schema;
20
21
    /**
22
     * @var array
23
     */
24
    protected static $config=array();
25
26
    /**
27
     * @var array $tables
28
     */
29
    protected static $tables=array();
30
31
    /**
32
     * SchemaFacade constructor.
33
     */
34
    public function __construct($config=array())
35
    {
36
        if(count($config)){
37
            $this->schema=new Schema($config);
38
        }
39
    }
40
41
    /**
42
     * @param array $params
43
     * @return SchemaFacadeContract
44
     */
45
    public static function setConfig($params=array())
46
    {
47
        self::$config=$params;
48
49
        return new static();
0 ignored issues
show
Bug Best Practice introduced by
The expression return new static() returns the type Migratio\SchemaFacade which is incompatible with the documented return type Migratio\Contract\SchemaFacadeContract.
Loading history...
50
    }
51
52
    /**
53
     * @param array $tables
54
     * @return SchemaFacadeContract
55
     */
56
    public static function tables($tables=array())
57
    {
58
        self::$tables=$tables;
59
60
        return new static();
0 ignored issues
show
Bug Best Practice introduced by
The expression return new static() returns the type Migratio\SchemaFacade which is incompatible with the documented return type Migratio\Contract\SchemaFacadeContract.
Loading history...
61
    }
62
63
    /**
64
     * @param $appName
65
     * @return SchemaFacade
66
     */
67
    public static function getInstance()
68
    {
69
        if(is_null(self::$instance)){
70
            self::$instance=new self(self::$config);
71
        }
72
        return self::$instance;
73
    }
74
75
    /**
76
     * @param $appName
77
     * @return \Resta\Migration\Src\Schema
0 ignored issues
show
Bug introduced by
The type Resta\Migration\Src\Schema was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
78
     */
79
    protected static function getSchema()
80
    {
81
        return self::getInstance()->schema;
82
    }
83
84
    /**
85
     * @return string
86
     */
87
    public static function pull()
88
    {
89
        $schema = self::getSchema();
90
91
        $schema->params['tables']=self::$tables;
92
93
        return $schema->pull();
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public static function push()
100
    {
101
        $schema = self::getSchema();
102
103
        $schema->params['tables']=self::$tables;
104
105
        return $schema->push();
106
    }
107
108
    /**
109
     * @return mixed
110
     */
111
    public function stub()
112
    {
113
        $schema = self::getSchema();
114
115
        return $schema->stub(func_get_args());
116
    }
117
118
}