Skip to content

Commit 5d84d68

Browse files
authored
Merge pull request #32 from webfactor/segmentations
Segmentations for better reuse options
2 parents da32e19 + f2c526c commit 5d84d68

File tree

4 files changed

+49
-42
lines changed

4 files changed

+49
-42
lines changed

src/Commands/MakeEntity.php

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Webfactor\Laravel\Generators\Commands;
44

5-
use Illuminate\Console\Command;
5+
use Webfactor\Laravel\Generators\Contracts\CommandAbstract;
66
use Webfactor\Laravel\Generators\Contracts\ServiceInterface;
77
use Webfactor\Laravel\Generators\Schemas\Schema;
88
use Webfactor\Laravel\Generators\Services\AddToGitService;
99
use Webfactor\Laravel\Generators\Services\OpenIdeService;
1010

11-
class MakeEntity extends Command
11+
class MakeEntity extends CommandAbstract
1212
{
1313
/**
1414
* The name and signature of the console command.
@@ -24,35 +24,13 @@ class MakeEntity extends Command
2424
*/
2525
protected $description = 'Make Entity';
2626

27-
/**
28-
* Paths to files which should automatically be opened in IDE if the
29-
* option --ide is set (and IDE capable).
30-
*
31-
* @var array
32-
*/
33-
public $filesToBeOpened = [];
34-
35-
/**
36-
* The name of the entity being created.
37-
*
38-
* @var string
39-
*/
40-
public $entity;
41-
4227
/**
4328
* The Schema object.
4429
*
4530
* @var Schema
4631
*/
4732
public $schema;
4833

49-
/**
50-
* The naming schema object.
51-
*
52-
* @var array
53-
*/
54-
public $naming = [];
55-
5634
/**
5735
* Execute the console command.
5836
*
@@ -124,17 +102,4 @@ private function executeService(ServiceInterface $service)
124102
{
125103
$service->call();
126104
}
127-
128-
/**
129-
* Adds file to $filesToBeOpened stack.
130-
*
131-
* @param $file
132-
* @return void
133-
*/
134-
public function addFile(?\SplFileInfo $file): void
135-
{
136-
if ($file) {
137-
array_push($this->filesToBeOpened, $file);
138-
}
139-
}
140105
}

src/Contracts/CommandAbstract.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Webfactor\Laravel\Generators\Contracts;
4+
5+
use Illuminate\Console\Command;
6+
7+
abstract class CommandAbstract extends Command
8+
{
9+
/**
10+
* Paths to files which should automatically be opened in IDE if the
11+
* option --ide is set (and IDE capable).
12+
*
13+
* @var array
14+
*/
15+
public $filesToBeOpened = [];
16+
17+
/**
18+
* The name of the entity being created.
19+
*
20+
* @var string
21+
*/
22+
public $entity;
23+
24+
/**
25+
* The naming classes.
26+
*
27+
* @var array
28+
*/
29+
public $naming = [];
30+
31+
/**
32+
* Adds file to $filesToBeOpened stack.
33+
*
34+
* @param $file
35+
* @return void
36+
*/
37+
public function addFile(?\SplFileInfo $file): void
38+
{
39+
if ($file) {
40+
array_push($this->filesToBeOpened, $file);
41+
}
42+
}
43+
}

src/Contracts/ServiceAbstract.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Webfactor\Laravel\Generators\Contracts;
44

55
use Illuminate\Filesystem\Filesystem;
6-
use Webfactor\Laravel\Generators\Commands\MakeEntity;
76

87
abstract class ServiceAbstract
98
{
@@ -15,12 +14,14 @@ abstract class ServiceAbstract
1514

1615
protected $filesystem;
1716

18-
public function __construct(MakeEntity $command)
17+
public function __construct(CommandAbstract $command, ?NamingAbstract $naming = null)
1918
{
2019
$this->command = $command;
2120
$this->filesystem = new Filesystem();
2221

23-
if ($this->key) {
22+
$this->naming = $naming;
23+
24+
if (is_null($naming) && $this->key) {
2425
$this->naming = $this->command->naming[$this->key];
2526
}
2627
}

src/Services/SidebarService.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Webfactor\Laravel\Generators\Services;
44

5-
use Illuminate\Filesystem\Filesystem;
6-
use Webfactor\Laravel\Generators\Commands\MakeEntity;
75
use Webfactor\Laravel\Generators\Contracts\ServiceAbstract;
86
use Webfactor\Laravel\Generators\Contracts\ServiceInterface;
97

0 commit comments

Comments
 (0)