File tree Expand file tree Collapse file tree 10 files changed +36
-54
lines changed Expand file tree Collapse file tree 10 files changed +36
-54
lines changed Original file line number Diff line number Diff line change 3
3
namespace Blueprint ;
4
4
5
5
6
+ use Blueprint \Contracts \Generator ;
7
+ use Blueprint \Contracts \Lexer ;
6
8
use Symfony \Component \Yaml \Yaml ;
7
9
8
10
class Blueprint
@@ -38,12 +40,12 @@ public function generate(array $tree)
38
40
}
39
41
}
40
42
41
- public function registerLexer ($ lexer )
43
+ public function registerLexer (Lexer $ lexer )
42
44
{
43
45
$ this ->lexers [] = $ lexer ;
44
46
}
45
47
46
- public function registerGenerator ($ generator )
48
+ public function registerGenerator (Generator $ generator )
47
49
{
48
50
$ this ->generators [] = $ generator ;
49
51
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Blueprint \Contracts ;
4
+
5
+ interface Generator
6
+ {
7
+ public function output (array $ tree ): void ;
8
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Blueprint \Contracts ;
4
+
5
+ interface Lexer
6
+ {
7
+ public function analyze (array $ tokens ): array ;
8
+ }
Original file line number Diff line number Diff line change 2
2
3
3
namespace Blueprint \Generators ;
4
4
5
+ use Blueprint \Contracts \Generator ;
5
6
use Blueprint \Model ;
6
7
7
- class FactoryGenerator
8
+ class FactoryGenerator implements Generator
8
9
{
9
- public function output (array $ tree )
10
+ public function output (array $ tree ): void
10
11
{
11
12
// TODO: what if changing an existing model
12
13
$ stub = file_get_contents ('stubs/factory.stub ' );
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2
2
3
3
namespace Blueprint \Generators ;
4
4
5
+ use Blueprint \Contracts \Generator ;
5
6
use Blueprint \Model ;
6
7
use Illuminate \Support \Str ;
7
8
8
- class MigrationGenerator
9
+ class MigrationGenerator implements Generator
9
10
{
10
- public function output (array $ tree )
11
+ public function output (array $ tree ): void
11
12
{
12
13
// TODO: what if changing an existing model
13
14
$ stub = file_get_contents ('stubs/migration.stub ' );
Original file line number Diff line number Diff line change 3
3
namespace Blueprint \Generators ;
4
4
5
5
use Blueprint \Column ;
6
+ use Blueprint \Contracts \Generator ;
6
7
use Blueprint \Model ;
7
8
8
- class ModelGenerator
9
+ class ModelGenerator implements Generator
9
10
{
10
- public function output (array $ tree )
11
+ public function output (array $ tree ): void
11
12
{
12
13
// TODO: what if changing an existing model
13
14
$ stub = file_get_contents ('stubs/model/class.stub ' );
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
-
4
3
namespace Blueprint \Lexers ;
5
4
6
-
7
5
use Blueprint \Column ;
8
- use Blueprint \Factories \ ModelFactory ;
6
+ use Blueprint \Contracts \ Lexer ;
9
7
use Blueprint \Model ;
10
8
11
- class ModelLexer
9
+ class ModelLexer implements Lexer
12
10
{
13
11
private static $ dataTypes = [
14
12
'bigIncrements ' ,
@@ -83,7 +81,7 @@ class ModelLexer
83
81
'always '
84
82
];
85
83
86
- public function analyze (array $ tokens )
84
+ public function analyze (array $ tokens ): array
87
85
{
88
86
$ registry = [
89
87
'models ' => []
Original file line number Diff line number Diff line change 3
3
namespace Tests \Feature ;
4
4
5
5
use Blueprint \Blueprint ;
6
+ use Blueprint \Contracts \Generator ;
7
+ use Blueprint \Contracts \Lexer ;
6
8
use Symfony \Component \Yaml \Exception \ParseException ;
7
9
use Tests \TestCase ;
8
10
@@ -151,7 +153,7 @@ public function analyze_return_default_tree_for_empty_tokens()
151
153
*/
152
154
public function analyze_uses_register_lexers_to_analyze_tokens ()
153
155
{
154
- $ lexer = \Mockery::mock ();
156
+ $ lexer = \Mockery::mock (Lexer::class );
155
157
$ tokens = ['tokens ' => ['are ' , 'here ' ]];
156
158
$ lexer ->expects ('analyze ' )
157
159
->with ($ tokens )
@@ -171,7 +173,7 @@ public function analyze_uses_register_lexers_to_analyze_tokens()
171
173
*/
172
174
public function generate_uses_register_generators_to_generate_code ()
173
175
{
174
- $ generator = \Mockery::mock ();
176
+ $ generator = \Mockery::mock (Generator::class );
175
177
$ tree = ['branch ' => ['code ' , 'attributes ' ]];
176
178
$ generator ->expects ('output ' )
177
179
->with ($ tree );
You can’t perform that action at this time.
0 commit comments