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

Commit

Permalink
Merge pull request #45 from lextira/laravel-7.x
Browse files Browse the repository at this point in the history
Laravel 7.x update
  • Loading branch information
Mulkave authored Apr 2, 2020
2 parents c310e00 + 586c1cc commit 8218251
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 28 deletions.
17 changes: 12 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@
"bin": ["lucid"],
"minimum-stability": "stable",
"require": {
"symfony/console": "^4.1",
"symfony/process": "^4.1",
"symfony/finder": "^4.1",
"symfony/filesystem": "^4.1",
"phploc/phploc": "~4.0"
"symfony/console": "^5.0",
"symfony/process": "^5.0",
"symfony/finder": "^5.0",
"symfony/filesystem": "^5.0",
"phploc/phploc": "^6.0"
},
"extra": {
"laravel": {
"providers": [
"Lucid\\Console\\LucidServiceProvider"
]
}
}
}
3 changes: 2 additions & 1 deletion src/Commands/ControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Lucid\Console\Finder;
use Lucid\Console\Command;
use Lucid\Console\Filesystem;
use Lucid\Console\Str;
use Symfony\Component\Console\Input\InputOption;
use Lucid\Console\Generators\ControllerGenerator;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -110,7 +111,7 @@ protected function getOptions()
*/
protected function parseName($name)
{
return studly_case(preg_replace('/Controller(\.php)?$/', '', $name).'Controller');
return Str::studly(preg_replace('/Controller(\.php)?$/', '', $name).'Controller');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/FeatureMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FeatureMakeCommand extends SymfonyCommand
public function handle()
{
try {
$service = studly_case($this->argument('service'));
$service = Str::studly($this->argument('service'));
$title = $this->parseName($this->argument('feature'));

$generator = new FeatureGenerator();
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/JobDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class JobDeleteCommand extends SymfonyCommand
public function handle()
{
try {
$domain = studly_case($this->argument('domain'));
$domain = Str::studly($this->argument('domain'));
$title = $this->parseName($this->argument('job'));

if (!$this->exists($job = $this->findJobPath($domain, $title))) {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/JobMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function handle()
{
$generator = new JobGenerator();

$domain = studly_case($this->argument('domain'));
$domain = Str::studly($this->argument('domain'));
$title = $this->parseName($this->argument('job'));
$isQueueable = $this->option('queue');
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/OperationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function handle()
{
$generator = new OperationGenerator();

$service = studly_case($this->argument('service'));
$service = Str::studly($this->argument('service'));
$title = $this->parseName($this->argument('operation'));
$isQueueable = $this->option('queue');
try {
Expand Down
4 changes: 3 additions & 1 deletion src/Components/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Lucid\Console\Components;

use Lucid\Console\Str;

/**
* @author Abed Halawi <[email protected]>
*/
Expand All @@ -20,7 +22,7 @@ public function __construct($name, $realPath, $relativePath)
{
$this->setAttributes([
'name' => $name,
'slug' => snake_case($name),
'slug' => Str::snake($name),
'realPath' => $realPath,
'relativePath' => $relativePath,
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/JobGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private function generateTestFile($job, $domain)

$content = str_replace(
['{{namespace}}', '{{testclass}}', '{{job}}', '{{job_namespace}}'],
[$namespace, $testClass, snake_case($job), $jobNamespace],
[$namespace, $testClass, Str::snake($job), $jobNamespace],
$content
);

Expand Down
2 changes: 1 addition & 1 deletion src/Generators/ServiceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ServiceGenerator extends Generator
public function generate($name)
{
$name = Str::service($name);
$slug = snake_case($name);
$slug = Str::snake($name);
$path = $this->findServicePath($name);

if ($this->exists($path)) {
Expand Down
10 changes: 10 additions & 0 deletions src/Http/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Lucid\Console\Http;

use Lucid\Console\Finder;

class Controller
{
use Finder;
}
8 changes: 2 additions & 6 deletions src/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Lucid\Console;

use Route;
use Illuminate\Support\Facades\Route;
use Lucid\Console\Http\Controller;

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

Expand Down Expand Up @@ -88,8 +89,3 @@
});

});

class Controller
{
use Finder;
}
43 changes: 34 additions & 9 deletions src/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,36 @@

namespace Lucid\Console;

use Illuminate\Support\Str as LaravelStr;

/**
* @author Abed Halawi <[email protected]>
*/
class Str
{
/**
* Convert a value to studly caps case.
*
* @param string $value
* @return string
*/
public static function studly($value)
{
return LaravelStr::studly($value);
}

/**
* Convert a string to snake case.
*
* @param string $value
* @param string $delimiter
* @return string
*/
public static function snake($value, $delimiter = '_')
{
return LaravelStr::snake($value, $delimiter);
}

/**
* Determine the real name of the given name,
* excluding the given pattern.
Expand Down Expand Up @@ -47,7 +72,7 @@ public static function realName($name, $pattern = '//')
*/
public static function feature($name)
{
return studly_case(preg_replace('/Feature(\.php)?$/', '', $name).'Feature');
return self::studly(preg_replace('/Feature(\.php)?$/', '', $name).'Feature');
}

/**
Expand All @@ -63,7 +88,7 @@ public static function feature($name)
*/
public static function job($name)
{
return studly_case(preg_replace('/Job(\.php)?$/', '', $name).'Job');
return self::studly(preg_replace('/Job(\.php)?$/', '', $name).'Job');
}

/**
Expand All @@ -79,7 +104,7 @@ public static function job($name)
*/
public static function operation($name)
{
return studly_case(preg_replace('/Operation(\.php)?$/', '', $name).'Operation');
return self::studly(preg_replace('/Operation(\.php)?$/', '', $name).'Operation');
}

/**
Expand All @@ -93,7 +118,7 @@ public static function operation($name)
*/
public static function domain($name)
{
return studly_case($name);
return self::studly($name);
}

/**
Expand All @@ -105,7 +130,7 @@ public static function domain($name)
*/
public static function service($name)
{
return studly_case($name);
return self::studly($name);
}

/**
Expand All @@ -117,7 +142,7 @@ public static function service($name)
*/
public static function controller($name)
{
return studly_case(preg_replace('/Controller(\.php)?$/', '', $name).'Controller');
return self::studly(preg_replace('/Controller(\.php)?$/', '', $name).'Controller');
}

/**
Expand All @@ -131,7 +156,7 @@ public static function controller($name)
*/
public static function model($name)
{
return studly_case($name);
return self::studly($name);
}

/**
Expand All @@ -142,7 +167,7 @@ public static function model($name)
*/
public static function policy($name)
{
return studly_case(preg_replace('/Policy(\.php)?$/', '', $name) . 'Policy');
return self::studly(preg_replace('/Policy(\.php)?$/', '', $name) . 'Policy');
}

/**
Expand All @@ -153,6 +178,6 @@ public static function policy($name)
*/
public static function request($name)
{
return studly_case(preg_replace('/Request(\.php)?$/', '', $name) . 'Request');
return self::studly(preg_replace('/Request(\.php)?$/', '', $name) . 'Request');
}
}

0 comments on commit 8218251

Please sign in to comment.