Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit 8218251

Browse files
authored
Merge pull request #45 from lextira/laravel-7.x
Laravel 7.x update
2 parents c310e00 + 586c1cc commit 8218251

12 files changed

+69
-28
lines changed

composer.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@
1717
"bin": ["lucid"],
1818
"minimum-stability": "stable",
1919
"require": {
20-
"symfony/console": "^4.1",
21-
"symfony/process": "^4.1",
22-
"symfony/finder": "^4.1",
23-
"symfony/filesystem": "^4.1",
24-
"phploc/phploc": "~4.0"
20+
"symfony/console": "^5.0",
21+
"symfony/process": "^5.0",
22+
"symfony/finder": "^5.0",
23+
"symfony/filesystem": "^5.0",
24+
"phploc/phploc": "^6.0"
25+
},
26+
"extra": {
27+
"laravel": {
28+
"providers": [
29+
"Lucid\\Console\\LucidServiceProvider"
30+
]
31+
}
2532
}
2633
}

src/Commands/ControllerMakeCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Lucid\Console\Finder;
1515
use Lucid\Console\Command;
1616
use Lucid\Console\Filesystem;
17+
use Lucid\Console\Str;
1718
use Symfony\Component\Console\Input\InputOption;
1819
use Lucid\Console\Generators\ControllerGenerator;
1920
use Symfony\Component\Console\Input\InputArgument;
@@ -110,7 +111,7 @@ protected function getOptions()
110111
*/
111112
protected function parseName($name)
112113
{
113-
return studly_case(preg_replace('/Controller(\.php)?$/', '', $name).'Controller');
114+
return Str::studly(preg_replace('/Controller(\.php)?$/', '', $name).'Controller');
114115
}
115116

116117
/**

src/Commands/FeatureMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class FeatureMakeCommand extends SymfonyCommand
5757
public function handle()
5858
{
5959
try {
60-
$service = studly_case($this->argument('service'));
60+
$service = Str::studly($this->argument('service'));
6161
$title = $this->parseName($this->argument('feature'));
6262

6363
$generator = new FeatureGenerator();

src/Commands/JobDeleteCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class JobDeleteCommand extends SymfonyCommand
5656
public function handle()
5757
{
5858
try {
59-
$domain = studly_case($this->argument('domain'));
59+
$domain = Str::studly($this->argument('domain'));
6060
$title = $this->parseName($this->argument('job'));
6161

6262
if (!$this->exists($job = $this->findJobPath($domain, $title))) {

src/Commands/JobMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function handle()
5959
{
6060
$generator = new JobGenerator();
6161

62-
$domain = studly_case($this->argument('domain'));
62+
$domain = Str::studly($this->argument('domain'));
6363
$title = $this->parseName($this->argument('job'));
6464
$isQueueable = $this->option('queue');
6565
try {

src/Commands/OperationMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function handle()
5959
{
6060
$generator = new OperationGenerator();
6161

62-
$service = studly_case($this->argument('service'));
62+
$service = Str::studly($this->argument('service'));
6363
$title = $this->parseName($this->argument('operation'));
6464
$isQueueable = $this->option('queue');
6565
try {

src/Components/Service.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Lucid\Console\Components;
1313

14+
use Lucid\Console\Str;
15+
1416
/**
1517
* @author Abed Halawi <[email protected]>
1618
*/
@@ -20,7 +22,7 @@ public function __construct($name, $realPath, $relativePath)
2022
{
2123
$this->setAttributes([
2224
'name' => $name,
23-
'slug' => snake_case($name),
25+
'slug' => Str::snake($name),
2426
'realPath' => $realPath,
2527
'relativePath' => $relativePath,
2628
]);

src/Generators/JobGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private function generateTestFile($job, $domain)
7676

7777
$content = str_replace(
7878
['{{namespace}}', '{{testclass}}', '{{job}}', '{{job_namespace}}'],
79-
[$namespace, $testClass, snake_case($job), $jobNamespace],
79+
[$namespace, $testClass, Str::snake($job), $jobNamespace],
8080
$content
8181
);
8282

src/Generators/ServiceGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ServiceGenerator extends Generator
4949
public function generate($name)
5050
{
5151
$name = Str::service($name);
52-
$slug = snake_case($name);
52+
$slug = Str::snake($name);
5353
$path = $this->findServicePath($name);
5454

5555
if ($this->exists($path)) {

src/Http/Controller.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Lucid\Console\Http;
4+
5+
use Lucid\Console\Finder;
6+
7+
class Controller
8+
{
9+
use Finder;
10+
}

src/Http/routes.php

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

33
namespace Lucid\Console;
44

5-
use Route;
5+
use Illuminate\Support\Facades\Route;
6+
use Lucid\Console\Http\Controller;
67

78
Route::group(['prefix' => 'lucid'], function () {
89

@@ -88,8 +89,3 @@
8889
});
8990

9091
});
91-
92-
class Controller
93-
{
94-
use Finder;
95-
}

src/Str.php

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,36 @@
1111

1212
namespace Lucid\Console;
1313

14+
use Illuminate\Support\Str as LaravelStr;
15+
1416
/**
1517
* @author Abed Halawi <[email protected]>
1618
*/
1719
class Str
1820
{
21+
/**
22+
* Convert a value to studly caps case.
23+
*
24+
* @param string $value
25+
* @return string
26+
*/
27+
public static function studly($value)
28+
{
29+
return LaravelStr::studly($value);
30+
}
31+
32+
/**
33+
* Convert a string to snake case.
34+
*
35+
* @param string $value
36+
* @param string $delimiter
37+
* @return string
38+
*/
39+
public static function snake($value, $delimiter = '_')
40+
{
41+
return LaravelStr::snake($value, $delimiter);
42+
}
43+
1944
/**
2045
* Determine the real name of the given name,
2146
* excluding the given pattern.
@@ -47,7 +72,7 @@ public static function realName($name, $pattern = '//')
4772
*/
4873
public static function feature($name)
4974
{
50-
return studly_case(preg_replace('/Feature(\.php)?$/', '', $name).'Feature');
75+
return self::studly(preg_replace('/Feature(\.php)?$/', '', $name).'Feature');
5176
}
5277

5378
/**
@@ -63,7 +88,7 @@ public static function feature($name)
6388
*/
6489
public static function job($name)
6590
{
66-
return studly_case(preg_replace('/Job(\.php)?$/', '', $name).'Job');
91+
return self::studly(preg_replace('/Job(\.php)?$/', '', $name).'Job');
6792
}
6893

6994
/**
@@ -79,7 +104,7 @@ public static function job($name)
79104
*/
80105
public static function operation($name)
81106
{
82-
return studly_case(preg_replace('/Operation(\.php)?$/', '', $name).'Operation');
107+
return self::studly(preg_replace('/Operation(\.php)?$/', '', $name).'Operation');
83108
}
84109

85110
/**
@@ -93,7 +118,7 @@ public static function operation($name)
93118
*/
94119
public static function domain($name)
95120
{
96-
return studly_case($name);
121+
return self::studly($name);
97122
}
98123

99124
/**
@@ -105,7 +130,7 @@ public static function domain($name)
105130
*/
106131
public static function service($name)
107132
{
108-
return studly_case($name);
133+
return self::studly($name);
109134
}
110135

111136
/**
@@ -117,7 +142,7 @@ public static function service($name)
117142
*/
118143
public static function controller($name)
119144
{
120-
return studly_case(preg_replace('/Controller(\.php)?$/', '', $name).'Controller');
145+
return self::studly(preg_replace('/Controller(\.php)?$/', '', $name).'Controller');
121146
}
122147

123148
/**
@@ -131,7 +156,7 @@ public static function controller($name)
131156
*/
132157
public static function model($name)
133158
{
134-
return studly_case($name);
159+
return self::studly($name);
135160
}
136161

137162
/**
@@ -142,7 +167,7 @@ public static function model($name)
142167
*/
143168
public static function policy($name)
144169
{
145-
return studly_case(preg_replace('/Policy(\.php)?$/', '', $name) . 'Policy');
170+
return self::studly(preg_replace('/Policy(\.php)?$/', '', $name) . 'Policy');
146171
}
147172

148173
/**
@@ -153,6 +178,6 @@ public static function policy($name)
153178
*/
154179
public static function request($name)
155180
{
156-
return studly_case(preg_replace('/Request(\.php)?$/', '', $name) . 'Request');
181+
return self::studly(preg_replace('/Request(\.php)?$/', '', $name) . 'Request');
157182
}
158183
}

0 commit comments

Comments
 (0)