mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-16 16:37:47 +00:00
chore: phpstan fixes, rector
This commit is contained in:
parent
d19a079b8a
commit
b097b0a7d7
7 changed files with 15 additions and 17 deletions
|
|
@ -73,7 +73,7 @@ class StringMarkup extends FiltersProvider
|
||||||
// Default module_size is 11
|
// Default module_size is 11
|
||||||
// Size calculation: (21 modules for QR code + 4 modules margin on each side * 2) * module_size
|
// Size calculation: (21 modules for QR code + 4 modules margin on each side * 2) * module_size
|
||||||
// = (21 + 8) * module_size = 29 * module_size
|
// = (21 + 8) * module_size = 29 * module_size
|
||||||
$moduleSize = $moduleSize ?? 11;
|
$moduleSize ??= 11;
|
||||||
$size = 29 * $moduleSize;
|
$size = 29 * $moduleSize;
|
||||||
|
|
||||||
$qrCode = QrCode::format('svg')
|
$qrCode = QrCode::format('svg')
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,8 @@ class Plugin extends Model
|
||||||
// resolve and clean URLs
|
// resolve and clean URLs
|
||||||
$resolvedPollingUrls = $this->resolveLiquidVariables($this->polling_url);
|
$resolvedPollingUrls = $this->resolveLiquidVariables($this->polling_url);
|
||||||
$urls = array_values(array_filter( // array_values ensures 0, 1, 2...
|
$urls = array_values(array_filter( // array_values ensures 0, 1, 2...
|
||||||
array_map('trim', explode("\n", $resolvedPollingUrls)),
|
array_map(trim(...), explode("\n", $resolvedPollingUrls)),
|
||||||
fn ($url): bool => filled($url)
|
filled(...)
|
||||||
));
|
));
|
||||||
|
|
||||||
$combinedResponse = [];
|
$combinedResponse = [];
|
||||||
|
|
@ -624,7 +624,7 @@ class Plugin extends Model
|
||||||
// File doesn't exist, remove the view reference
|
// File doesn't exist, remove the view reference
|
||||||
$attributes['render_markup_view'] = null;
|
$attributes['render_markup_view'] = null;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception) {
|
||||||
// If file reading fails, remove the view reference
|
// If file reading fails, remove the view reference
|
||||||
$attributes['render_markup_view'] = null;
|
$attributes['render_markup_view'] = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,9 @@ class ImageGenerationService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get image generation settings from DeviceModel or Device (for legacy devices)
|
// Get image generation settings from DeviceModel or Device (for legacy devices)
|
||||||
$imageSettings = $deviceModel
|
$imageSettings = $deviceModel instanceof DeviceModel
|
||||||
? self::getImageSettingsFromModel($deviceModel)
|
? self::getImageSettingsFromModel($deviceModel)
|
||||||
: ($device ? self::getImageSettings($device) : self::getImageSettingsFromModel(null));
|
: ($device instanceof Device ? self::getImageSettings($device) : self::getImageSettingsFromModel(null));
|
||||||
|
|
||||||
$fileExtension = $imageSettings['mime_type'] === 'image/bmp' ? 'bmp' : 'png';
|
$fileExtension = $imageSettings['mime_type'] === 'image/bmp' ? 'bmp' : 'png';
|
||||||
$outputPath = Storage::disk('public')->path('/images/generated/'.$uuid.'.'.$fileExtension);
|
$outputPath = Storage::disk('public')->path('/images/generated/'.$uuid.'.'.$fileExtension);
|
||||||
|
|
@ -78,7 +78,7 @@ class ImageGenerationService
|
||||||
$browserStage->html($markup);
|
$browserStage->html($markup);
|
||||||
|
|
||||||
// Set timezone from user or fall back to app timezone
|
// Set timezone from user or fall back to app timezone
|
||||||
$timezone = $user?->timezone ?? config('app.timezone');
|
$timezone = $user->timezone ?? config('app.timezone');
|
||||||
$browserStage->timezone($timezone);
|
$browserStage->timezone($timezone);
|
||||||
|
|
||||||
if (config('app.puppeteer_window_size_strategy') === 'v2') {
|
if (config('app.puppeteer_window_size_strategy') === 'v2') {
|
||||||
|
|
@ -186,7 +186,7 @@ class ImageGenerationService
|
||||||
*/
|
*/
|
||||||
private static function getImageSettingsFromModel(?DeviceModel $deviceModel): array
|
private static function getImageSettingsFromModel(?DeviceModel $deviceModel): array
|
||||||
{
|
{
|
||||||
if ($deviceModel) {
|
if ($deviceModel instanceof DeviceModel) {
|
||||||
return [
|
return [
|
||||||
'width' => $deviceModel->width,
|
'width' => $deviceModel->width,
|
||||||
'height' => $deviceModel->height,
|
'height' => $deviceModel->height,
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@ class PluginImportService
|
||||||
foreach ($settings['custom_fields'] as $field) {
|
foreach ($settings['custom_fields'] as $field) {
|
||||||
if (isset($field['field_type']) && $field['field_type'] === 'multi_string') {
|
if (isset($field['field_type']) && $field['field_type'] === 'multi_string') {
|
||||||
|
|
||||||
if (isset($field['default']) && str_contains($field['default'], ',')) {
|
if (isset($field['default']) && str_contains((string) $field['default'], ',')) {
|
||||||
throw new Exception("Validation Error: The default value for multistring fields like `{$field['keyname']}` cannot contain commas.");
|
throw new Exception("Validation Error: The default value for multistring fields like `{$field['keyname']}` cannot contain commas.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($field['placeholder']) && str_contains($field['placeholder'], ',')) {
|
if (isset($field['placeholder']) && str_contains((string) $field['placeholder'], ',')) {
|
||||||
throw new Exception("Validation Error: The placeholder value for multistring fields like `{$field['keyname']}` cannot contain commas.");
|
throw new Exception("Validation Error: The placeholder value for multistring fields like `{$field['keyname']}` cannot contain commas.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,7 +159,7 @@ class PluginImportService
|
||||||
: null,
|
: null,
|
||||||
'polling_body' => $settings['polling_body'] ?? null,
|
'polling_body' => $settings['polling_body'] ?? null,
|
||||||
'markup_language' => $markupLanguage,
|
'markup_language' => $markupLanguage,
|
||||||
'render_markup' => $fullLiquid,
|
'render_markup' => $fullLiquid ?? null,
|
||||||
'configuration_template' => $configurationTemplate,
|
'configuration_template' => $configurationTemplate,
|
||||||
'data_payload' => json_decode($settings['static_data'] ?? '{}', true),
|
'data_payload' => json_decode($settings['static_data'] ?? '{}', true),
|
||||||
]);
|
]);
|
||||||
|
|
@ -321,7 +321,7 @@ class PluginImportService
|
||||||
: null,
|
: null,
|
||||||
'polling_body' => $settings['polling_body'] ?? null,
|
'polling_body' => $settings['polling_body'] ?? null,
|
||||||
'markup_language' => $markupLanguage,
|
'markup_language' => $markupLanguage,
|
||||||
'render_markup' => $fullLiquid,
|
'render_markup' => $fullLiquid ?? null,
|
||||||
'configuration_template' => $configurationTemplate,
|
'configuration_template' => $configurationTemplate,
|
||||||
'data_payload' => json_decode($settings['static_data'] ?? '{}', true),
|
'data_payload' => json_decode($settings['static_data'] ?? '{}', true),
|
||||||
'preferred_renderer' => $preferredRenderer,
|
'preferred_renderer' => $preferredRenderer,
|
||||||
|
|
|
||||||
|
|
@ -156,9 +156,7 @@ test('can delete a device palette', function (): void {
|
||||||
->call('deleteDevicePalette', $palette->id);
|
->call('deleteDevicePalette', $palette->id);
|
||||||
|
|
||||||
expect(DevicePalette::find($palette->id))->toBeNull();
|
expect(DevicePalette::find($palette->id))->toBeNull();
|
||||||
$component->assertSet('devicePalettes', function ($palettes) use ($palette) {
|
$component->assertSet('devicePalettes', fn ($palettes) => $palettes->where('id', $palette->id)->isEmpty());
|
||||||
return $palettes->where('id', $palette->id)->isEmpty();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can duplicate a device palette', function (): void {
|
test('can duplicate a device palette', function (): void {
|
||||||
|
|
@ -467,7 +467,7 @@ YAML;
|
||||||
$zipFile = UploadedFile::fake()->createWithContent('invalid-default.zip', $zipContent);
|
$zipFile = UploadedFile::fake()->createWithContent('invalid-default.zip', $zipContent);
|
||||||
$pluginImportService = new PluginImportService();
|
$pluginImportService = new PluginImportService();
|
||||||
|
|
||||||
expect(fn () => $pluginImportService->importFromZip($zipFile, $user))
|
expect(fn (): Plugin => $pluginImportService->importFromZip($zipFile, $user))
|
||||||
->toThrow(Exception::class, 'Validation Error: The default value for multistring fields like `api_key` cannot contain commas.');
|
->toThrow(Exception::class, 'Validation Error: The default value for multistring fields like `api_key` cannot contain commas.');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -497,7 +497,7 @@ YAML;
|
||||||
$zipFile = UploadedFile::fake()->createWithContent('invalid-placeholder.zip', $zipContent);
|
$zipFile = UploadedFile::fake()->createWithContent('invalid-placeholder.zip', $zipContent);
|
||||||
$pluginImportService = new PluginImportService();
|
$pluginImportService = new PluginImportService();
|
||||||
|
|
||||||
expect(fn () => $pluginImportService->importFromZip($zipFile, $user))
|
expect(fn (): Plugin => $pluginImportService->importFromZip($zipFile, $user))
|
||||||
->toThrow(Exception::class, 'Validation Error: The placeholder value for multistring fields like `api_key` cannot contain commas.');
|
->toThrow(Exception::class, 'Validation Error: The placeholder value for multistring fields like `api_key` cannot contain commas.');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue