From 2e5711bfa8e36939ce87c63751194837826136ec Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:04:50 +0100 Subject: [PATCH] Apply fixes from StyleCI (#1041) [ci skip] [skip ci] Co-authored-by: StyleCI Bot --- app/admin/dashboardwidgets/Statistics.php | 4 ++-- app/admin/traits/HasChartDatasets.php | 1 - app/admin/widgets/DashboardContainer.php | 24 +++++++++++------------ app/system/classes/ComponentManager.php | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/admin/dashboardwidgets/Statistics.php b/app/admin/dashboardwidgets/Statistics.php index bb04817be4..fc57130f70 100644 --- a/app/admin/dashboardwidgets/Statistics.php +++ b/app/admin/dashboardwidgets/Statistics.php @@ -115,11 +115,11 @@ protected function getValue(string $cardCode): string protected function getValueForDefaultCard(string $cardCode, $start, $end) { - $contextMethod = 'getTotal' . studly_case($cardCode) . 'Sum'; + $contextMethod = 'getTotal'.studly_case($cardCode).'Sum'; throw_unless($this->methodExists($contextMethod), new SystemException(sprintf( 'The card [%s] does must have a defined method in [%s]', - $cardCode, get_class($this) . '::' . $contextMethod + $cardCode, get_class($this).'::'.$contextMethod ))); $count = $this->$contextMethod(function ($query) use ($start, $end) { diff --git a/app/admin/traits/HasChartDatasets.php b/app/admin/traits/HasChartDatasets.php index ea66aa1cd0..ecb1452923 100644 --- a/app/admin/traits/HasChartDatasets.php +++ b/app/admin/traits/HasChartDatasets.php @@ -5,7 +5,6 @@ use Carbon\Carbon; use DateInterval; use DatePeriod; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; trait HasChartDatasets diff --git a/app/admin/widgets/DashboardContainer.php b/app/admin/widgets/DashboardContainer.php index 6aeaa796de..c2827ddece 100644 --- a/app/admin/widgets/DashboardContainer.php +++ b/app/admin/widgets/DashboardContainer.php @@ -134,7 +134,7 @@ public function onRenderWidgets() $this->vars['widgets'] = $this->dashboardWidgets; - return ['#' . $this->getId('container') => $this->makePartial('dashboardcontainer/widget_container')]; + return ['#'.$this->getId('container') => $this->makePartial('dashboardcontainer/widget_container')]; } public function onLoadAddPopup() @@ -142,7 +142,7 @@ public function onLoadAddPopup() $this->vars['gridColumns'] = $this->getWidgetPropertyWidthOptions(); $this->vars['widgets'] = collect(Widgets::instance()->listDashboardWidgets())->pluck('label', 'code'); - return ['#' . $this->getId('new-widget-modal-content') => $this->makePartial('new_widget_popup')]; + return ['#'.$this->getId('new-widget-modal-content') => $this->makePartial('new_widget_popup')]; } public function onLoadUpdatePopup() @@ -156,7 +156,7 @@ public function onLoadUpdatePopup() $this->vars['widget'] = $widget = $this->findWidgetByAlias($widgetAlias); $this->vars['widgetForm'] = $this->getFormWidget($widgetAlias, $widget); - return ['#' . $widgetAlias . '-modal-content' => $this->makePartial('widget_form')]; + return ['#'.$widgetAlias.'-modal-content' => $this->makePartial('widget_form')]; } public function onAddWidget() @@ -177,11 +177,11 @@ public function onAddWidget() new ApplicationException(lang('admin::lang.dashboard.alert_invalid_widget')) ); - $widgetAlias = $widgetCode . '_' . str_random(5); + $widgetAlias = $widgetCode.'_'.str_random(5); $this->addWidget($widgetAlias, $widget, array_get($validated, 'size')); return [ - '@#' . $this->getId('container-list') => $this->makePartial('widget_item', [ + '@#'.$this->getId('container-list') => $this->makePartial('widget_item', [ 'widget' => $widget, 'widgetAlias' => $widgetAlias, ]), @@ -200,7 +200,7 @@ public function onResetWidgets() flash()->success(lang('admin::lang.dashboard.alert_reset_layout_success')); - return ['#' . $this->getId('container-list') => $this->makePartial('widget_list')]; + return ['#'.$this->getId('container-list') => $this->makePartial('widget_list')]; } public function onSetAsDefault() @@ -227,7 +227,7 @@ public function onUpdateWidget() [$rules, $attributes] = $widget->getPropertyRules(); - $validated = $this->validate(request()->post($alias . '_fields'), array_merge([ + $validated = $this->validate(request()->post($alias.'_fields'), array_merge([ 'width' => ['numeric'], ], $rules), $attributes); @@ -409,8 +409,8 @@ protected function getFormWidget($alias, $widget) $formConfig['model'] = User_preferences_model::onUser(); $formConfig['data'] = $this->getWidgetPropertyValues($widget); $formConfig['previewMode'] = $this->previewMode; - $formConfig['alias'] = $this->alias . studly_case('Form_' . $alias); - $formConfig['arrayName'] = $alias . '_fields'; + $formConfig['alias'] = $this->alias.studly_case('Form_'.$alias); + $formConfig['arrayName'] = $alias.'_fields'; $formWidget = $this->makeWidget('Admin\Widgets\Form', $formConfig); $formWidget->bindToController(); @@ -570,12 +570,12 @@ protected function saveWidgetProperties($alias, $properties) protected function getUserPreferencesKey() { - return 'admin_dashboardwidgets_' . $this->context; + return 'admin_dashboardwidgets_'.$this->context; } protected function getSystemParametersKey() { - return 'admin_dashboardwidgets_default_' . $this->context; + return 'admin_dashboardwidgets_default_'.$this->context; } protected function getUniqueAlias($widgets) @@ -583,7 +583,7 @@ protected function getUniqueAlias($widgets) $num = count($widgets); do { $num++; - $alias = 'dashboard_container_' . $this->context . '_' . $num; + $alias = 'dashboard_container_'.$this->context.'_'.$num; } while (array_key_exists($alias, $widgets)); return $alias; diff --git a/app/system/classes/ComponentManager.php b/app/system/classes/ComponentManager.php index 987da2a3dd..5aa383b8bb 100644 --- a/app/system/classes/ComponentManager.php +++ b/app/system/classes/ComponentManager.php @@ -279,7 +279,7 @@ public function convertCodeToPath($alias) return $alias; } - return $alias . '/components/' . ucfirst($alias); + return $alias.'/components/'.ucfirst($alias); } // @@ -326,7 +326,7 @@ public function getComponentPropertyConfig($component, $addAliasProperty = true) ]; if (!in_array($propertyType, ['text', 'number']) && !array_key_exists('options', $params)) { - $methodName = 'get' . studly_case($name) . 'Options'; + $methodName = 'get'.studly_case($name).'Options'; $property['options'] = [get_class($component), $methodName]; }