Skip to content

Commit

Permalink
Merge pull request #31 from Distilleries/scrutinizer-patch-1
Browse files Browse the repository at this point in the history
Scrutinizer Auto-Fixes
  • Loading branch information
mfrancois authored Feb 20, 2019
2 parents ad686cd + b09e087 commit badfdab
Show file tree
Hide file tree
Showing 47 changed files with 124 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,6 @@ protected function getNameInput()
*/
protected function getStub()
{
return __DIR__ . '/Lib/stubs/' . $this->getTemplate() . '.stub';
return __DIR__.'/Lib/stubs/'.$this->getTemplate().'.stub';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public function getClassModel($model)
$model = last($model);
$model = preg_replace('/\.php/i', '', $model);

return '\\' . $model;
return '\\'.$model;

}

Expand All @@ -20,7 +20,7 @@ public function getTrait($states)
{
$state = preg_replace('/Contracts/i', 'States', $state);
$state = preg_replace('/Contract/i', 'Trait', $state);
$result .= 'use ' . $state . ';' . "\n";
$result .= 'use '.$state.';'."\n";
}

return $result;
Expand All @@ -29,7 +29,7 @@ public function getTrait($states)

public function getImplementation($states)
{
$result = 'implements ' . join(', ', $states);
$result = 'implements '.join(', ', $states);

return $result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ protected function mapWebRoutes()
\Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
], function($router) {

require __DIR__ . '/../routes/web.php';
require __DIR__.'/../routes/web.php';
});
}

Expand All @@ -75,8 +75,8 @@ protected function mapApiRoutes()
'middleware' => 'api',
'namespace' => $this->namespace,
'prefix' => 'api',
], function ($router) {
require __DIR__ . '/../routes/api.php';
], function($router) {
require __DIR__.'/../routes/api.php';
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ExpendableRoutingServiceProvider extends RoutingServiceProvider
*/
protected function registerRouter()
{
$this->app->singleton('router',function ($app) {
$this->app->singleton('router', function($app) {
return new Router($app['events'], $app);
});
}
Expand Down
18 changes: 9 additions & 9 deletions src/Distilleries/Expendable/ExpendableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ class ExpendableServiceProvider extends ServiceProvider
public function boot()
{

$this->loadViewsFrom(__DIR__ . '/../../views', 'expendable');
$this->loadTranslationsFrom(__DIR__ . '/../../lang', 'expendable');
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations/');
$this->loadViewsFrom(__DIR__.'/../../views', 'expendable');
$this->loadTranslationsFrom(__DIR__.'/../../lang', 'expendable');
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations/');


$this->publishes([
__DIR__ . '/../../config/config.php' => config_path('expendable.php'),
__DIR__ . '/../../database/seeds/' => base_path('/database/seeds'),
__DIR__.'/../../config/config.php' => config_path('expendable.php'),
__DIR__.'/../../database/seeds/' => base_path('/database/seeds'),
]);


$this->publishes([
__DIR__ . '/../../views' => base_path('resources/views/vendor/expendable'),
__DIR__.'/../../views' => base_path('resources/views/vendor/expendable'),
], 'views');
$this->mergeConfigFrom(
__DIR__ . '/../../config/config.php', 'expendable'
__DIR__.'/../../config/config.php', 'expendable'
);

$autoLoaderListener = new \Distilleries\Expendable\Register\ListenerAutoLoader(config('expendable.listener'));
Expand Down Expand Up @@ -77,13 +77,13 @@ public function register()
protected function registerCommands()
{
$file = app('files');
$files = $file->allFiles(__DIR__ . '/Console/');
$files = $file->allFiles(__DIR__.'/Console/');

foreach ($files as $file)
{
if (strpos($file->getPathName(), 'Lib') === false)
{
$this->commands('Distilleries\Expendable\Console\\' . preg_replace('/\.php/i', '', $file->getFilename()));
$this->commands('Distilleries\Expendable\Console\\'.preg_replace('/\.php/i', '', $file->getFilename()));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Distilleries/Expendable/Fondation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function registerBaseServiceProviders()
*/
public function storagePath()
{
$path = env('STORAGE_PATH', $this->basePath . DIRECTORY_SEPARATOR . 'storage');
$path = env('STORAGE_PATH', $this->basePath.DIRECTORY_SEPARATOR.'storage');

return $this->storagePath ?: $path;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Distilleries/Expendable/Helpers/StaticLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function mailActions($id = null)

foreach ($dataActions as $action)
{
$dataResult[$action] = trans('expendable::mail.' . $action);
$dataResult[$action] = trans('expendable::mail.'.$action);
}

return self::getLabel($dataResult, $id);
Expand Down
8 changes: 6 additions & 2 deletions src/Distilleries/Expendable/Helpers/UserUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public static function isBackendRole()
{
$user = Auth::user();

if (empty($user)) return false;
if (empty($user)) {
return false;
}

return !empty(Auth::user()->role) && (Auth::user()->role->initials == '@sa' || Auth::user()->role->initials == '@a');
}
Expand All @@ -27,7 +29,9 @@ public static function isFrontendRole()
{
$user = Auth::user();

if (empty($user)) return false;
if (empty($user)) {
return false;
}

return !empty(Auth::user()->role) && in_array(Auth::user()->role->initials, self::frontendInitialRole());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function initStaticPart()
$this->layoutManager->initStaticPart(function($layoutManager)
{

$menu_top = $layoutManager->getView()->make('expendable::admin.menu.top',[
$menu_top = $layoutManager->getView()->make('expendable::admin.menu.top', [
'languages'=>Language::all()
]);
$menu_left = $layoutManager->getView()->make('expendable::admin.menu.left');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function display(Exception $exception, $code)


$this->layoutManager->add([
'class_layout'=>$class . '-full-page',
'class_layout'=>$class.'-full-page',
'content'=>$content,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function putDestroy(Request $request)
$data = $this->model->where($this->model->getKeyName(), $request->get('id'))->get()->last();
$data->delete();

return redirect()->to(action('\\' . get_class($this) . '@getIndex'));
return redirect()->to(action('\\'.get_class($this).'@getIndex'));
}

// ------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(Kernel $artisan, ComponentForm $form, LayoutManagerC

public function getIndex()
{
return redirect()->to(action('\\' . get_class($this) . '@getEdit'));
return redirect()->to(action('\\'.get_class($this).'@getEdit'));
}


Expand Down Expand Up @@ -70,9 +70,9 @@ public function postEdit(Request $request)
}

$libelle = $request->get('libelle');
$libelle_form = $libelle . 'Form';
$libelle_datatable = $libelle . 'Datatable';
$libelle_controller = $libelle . 'Controller';
$libelle_form = $libelle.'Form';
$libelle_datatable = $libelle.'Datatable';
$libelle_controller = $libelle.'Controller';
$model = $request->get('models');
$states = $request->get('state');

Expand All @@ -82,14 +82,14 @@ public function postEdit(Request $request)
{
$this->artisan->call('datatable:make', [
'--fields' => $request->get('colon_datatable'),
'name' => 'Http/Datatables/' . $libelle_datatable
'name' => 'Http/Datatables/'.$libelle_datatable
]);
} else if (strpos($state, 'FormStateContract') !== false)
{

$this->artisan->call('make:form', [
'--fields' => $request->get('fields_form'),
'name' => 'Http/Forms/' . $libelle_form
'name' => 'Http/Forms/'.$libelle_form
]);
}
}
Expand All @@ -99,7 +99,7 @@ public function postEdit(Request $request)
'--model' => $model,
'--datatable' => $libelle_datatable,
'--form' => $libelle_form,
'name' => 'Http/Controllers/Backend/' . $libelle_controller
'name' => 'Http/Controllers/Backend/'.$libelle_controller
]);

return redirect()->back()->with(Message::MESSAGE, [trans('expendable::success.generated')]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(LanguageDatatable $datatable, LanguageForm $form, La

public function getChangeLang($locale = null)
{
session()->put('language',$locale);
session()->put('language', $locale);
app()->setLocale($locale);
return redirect()->back();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(Guard $auth, LayoutManagerContract $layoutManager)
{
parent::__construct($layoutManager);

$this->auth = $auth;
$this->auth = $auth;

}

Expand All @@ -40,7 +40,7 @@ public function __construct(Guard $auth, LayoutManagerContract $layoutManager)

public function getLoginRedirect()
{
return redirect()->action('\\' . self::class . '@getIndex');
return redirect()->action('\\'.self::class.'@getIndex');
}

public function getIndex()
Expand Down Expand Up @@ -203,15 +203,15 @@ public function postReset(Request $request)
}

$response = $this->broker()->reset(
$this->credentials($request), function ($user, $password) {
$this->credentials($request), function($user, $password) {
$this->resetPassword($user, $password);
});

// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
return $response == Password::PASSWORD_RESET
? redirect()->to(action('\\' . get_class($this) . '@getIndex'))
? redirect()->to(action('\\'.get_class($this).'@getIndex'))
: redirect()->back()->with('error', trans($response));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(PermissionForm $form, Permission $model, LayoutManag

public function getIndex()
{
return redirect()->to(action('\\' . get_class($this) . '@getEdit'));
return redirect()->to(action('\\'.get_class($this).'@getEdit'));
}

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -58,7 +58,7 @@ public function postEdit(Request $request)
}


return redirect()->to(action('\\' . get_class($this) . '@getIndex'));
return redirect()->to(action('\\'.get_class($this).'@getIndex'));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function postSearchWithRole(Request $request)
}


public function postUnLock(Request $request){
public function postUnLock(Request $request) {

$model = $this->model->findOrFail($request->get('id'));
$model->nb_of_try = 0;
Expand All @@ -63,7 +63,7 @@ public function postUnLock(Request $request){
}


public function postLock(Request $request){
public function postLock(Request $request) {

$model = $this->model->findOrFail($request->get('id'));
$model->nb_of_try = config('expendable.auth.nb_of_try');
Expand Down
6 changes: 3 additions & 3 deletions src/Distilleries/Expendable/Http/Datatables/BaseDatatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ abstract class BaseDatatable extends EloquentDatatable {
// ------------------------------------------------------------------------------------------------
public function addTranslationAction($template = 'expendable::admin.form.components.datatable.translations', $route = '')
{
$this->add('translation', function ($model) use ($template, $route) {
$this->add('translation', function($model) use ($template, $route) {

$languages = Language::withoutCurrentLanguage()->get();
$translations = Translation::byElement($model)->pluck('id_element','iso')->toArray();
$translations = Translation::byElement($model)->pluck('id_element', 'iso')->toArray();
return view($template, array(
'languages' => $languages,
'translations' => $translations,
'data' => $model->toArray(),
'route' => !empty($route) ? $route . '@' : $this->getControllerNameForAction() . '@'
'route' => !empty($route) ? $route.'@' : $this->getControllerNameForAction().'@'
))->render();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ protected function getChoiceModels()
{
$allModels = [
[
'path' => app_path() . DIRECTORY_SEPARATOR,
'path' => app_path().DIRECTORY_SEPARATOR,
'namespace' => '{{app}}',
],
[
'path' => app_path() . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR,
'path' => app_path().DIRECTORY_SEPARATOR.'Models'.DIRECTORY_SEPARATOR,
'namespace' => '{{app}}Models\\',
],
[
'path' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR,
'path' => __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Models'.DIRECTORY_SEPARATOR,
'namespace' => 'Distilleries\\Expendable\\Models\\',
],
];
Expand All @@ -67,7 +67,7 @@ protected function getChoiceModels()
foreach ($models as $model) {
$choice = explode('/', $model);
$model = preg_replace('/.php/i', '', last($choice));
$choices[$config['namespace'] . $model] = $model;
$choices[$config['namespace'].$model] = $model;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function buildForm()
protected function getUpdateRules()
{
$key = \Request::get($this->model->getKeyName());
static::$rules['iso'] = 'required|unique:languages,iso,' . $key;
static::$rules['iso'] = 'required|unique:languages,iso,'.$key;

return parent::getUpdateRules();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Distilleries/Expendable/Http/Forms/Role/RoleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function buildForm()

protected function getUpdateRules()
{
$key = \Request::get($this->model->getKeyName());
static::$rules_update['initials'] = 'required|unique:roles,initials,' . $key;
$key = \Request::get($this->model->getKeyName());
static::$rules_update['initials'] = 'required|unique:roles,initials,'.$key;

return parent::getUpdateRules();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Distilleries/Expendable/Http/Forms/User/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function buildForm()
protected function getUpdateRules()
{
$key = \Request::get($this->model->getKeyName());
static::$rules_update['email'] = 'required|email|unique:users,email,' . $key;
static::$rules_update['email'] = 'required|email|unique:users,email,'.$key;

return parent::getUpdateRules();
}
Expand Down
Loading

0 comments on commit badfdab

Please sign in to comment.