From 6a6f63fa15bce484ae9b063f98168fd859ec6c91 Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Sun, 5 Jan 2025 12:57:50 +0600 Subject: [PATCH] duster --- app/DAL/Studies/WorklistFactory.php | 2 +- app/Http/Controllers/HashidActionControllerBase.php | 4 ++-- app/Http/Controllers/HashidControllerBase.php | 4 ++-- app/Http/Controllers/Staff/StudyViewerController.php | 3 ++- app/Models/CustomPersonalAccessToken.php | 2 +- app/Models/Study.php | 2 +- app/Services/InputMatcher.php | 4 +++- app/Services/Pacs/Sync/StudiesSync.php | 3 ++- 8 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/DAL/Studies/WorklistFactory.php b/app/DAL/Studies/WorklistFactory.php index 42aa29e..9a8f2a7 100644 --- a/app/DAL/Studies/WorklistFactory.php +++ b/app/DAL/Studies/WorklistFactory.php @@ -22,7 +22,7 @@ public static function getLister(): IUserStudyLister UserRole::Technician => new TechnicianWorklist, UserRole::Radiologist => new RadiologistWorklist, UserRole::ReferringDoctor => new ReferrerWorklist, - default => throw new Exception("Unknown user role: $role"), + default => throw new Exception("Unknown user role: {$role}"), }; } } diff --git a/app/Http/Controllers/HashidActionControllerBase.php b/app/Http/Controllers/HashidActionControllerBase.php index 44cff63..82c10a3 100644 --- a/app/Http/Controllers/HashidActionControllerBase.php +++ b/app/Http/Controllers/HashidActionControllerBase.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers; -use function Sentry\captureException; - use Throwable; +use function Sentry\captureException; + abstract class HashidActionControllerBase extends Controller { protected ?int $key = null; diff --git a/app/Http/Controllers/HashidControllerBase.php b/app/Http/Controllers/HashidControllerBase.php index 0adecdb..29e5bae 100644 --- a/app/Http/Controllers/HashidControllerBase.php +++ b/app/Http/Controllers/HashidControllerBase.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers; -use function Sentry\captureException as gobble; - use Throwable; +use function Sentry\captureException as gobble; + abstract class HashidControllerBase extends Controller { protected ?int $key = null; diff --git a/app/Http/Controllers/Staff/StudyViewerController.php b/app/Http/Controllers/Staff/StudyViewerController.php index 5cd6051..0532b28 100644 --- a/app/Http/Controllers/Staff/StudyViewerController.php +++ b/app/Http/Controllers/Staff/StudyViewerController.php @@ -4,6 +4,7 @@ use App\Http\Controllers\HashidControllerBase; use App\Models\Study; +use Closure; use Illuminate\Support\Str; class StudyViewerController extends HashidControllerBase @@ -18,7 +19,7 @@ public function ohif() return $this->loadViewer(fn (Study $study) => $study->getOhifLink()); } - private function loadViewer(\Closure $callback) + private function loadViewer(Closure $callback) { $this->decodeKeys(); $study = Study::findOrFail($this->key); diff --git a/app/Models/CustomPersonalAccessToken.php b/app/Models/CustomPersonalAccessToken.php index 47edc66..5073e1a 100644 --- a/app/Models/CustomPersonalAccessToken.php +++ b/app/Models/CustomPersonalAccessToken.php @@ -12,7 +12,7 @@ class CustomPersonalAccessToken extends PersonalAccessToken { public static function findToken($token) { - $token = Cache::remember("PersonalAccessToken::$token", 600, + $token = Cache::remember("PersonalAccessToken::{$token}", 600, function () use ($token) { return parent::findToken($token) ?? '_null_'; }); diff --git a/app/Models/Study.php b/app/Models/Study.php index 2d49178..5381112 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -219,7 +219,7 @@ public function sanitizedStudyDescription(): string 'with' => 'w/', ]; foreach ($lut as $search => $replace) { - $name = preg_replace("/\b$search\b/i", $replace, $name); + $name = preg_replace("/\b{$search}\b/i", $replace, $name); } return $name; diff --git a/app/Services/InputMatcher.php b/app/Services/InputMatcher.php index d66fb9d..42af362 100644 --- a/app/Services/InputMatcher.php +++ b/app/Services/InputMatcher.php @@ -4,6 +4,8 @@ use App\Models\Enums\NameMatchModes; +use function strlen; + final class InputMatcher { public static function match(string $input, string $pattern, NameMatchModes $mode): bool @@ -11,7 +13,7 @@ public static function match(string $input, string $pattern, NameMatchModes $mod return match ($mode) { NameMatchModes::Exact => strcasecmp($input, $pattern) === 0, NameMatchModes::Contains => stripos($input, $pattern) !== false, - NameMatchModes::StartsWith => strncasecmp($input, $pattern, \strlen($pattern)) === 0, + NameMatchModes::StartsWith => strncasecmp($input, $pattern, strlen($pattern)) === 0, NameMatchModes::EndsWith => str_ends_with(strtolower($input), strtolower($pattern)), NameMatchModes::Regex => preg_match($pattern, $input) === 1, }; diff --git a/app/Services/Pacs/Sync/StudiesSync.php b/app/Services/Pacs/Sync/StudiesSync.php index c29167c..1fe6d05 100644 --- a/app/Services/Pacs/Sync/StudiesSync.php +++ b/app/Services/Pacs/Sync/StudiesSync.php @@ -7,6 +7,7 @@ use App\Services\Pacs\InstituteMapper; use App\Services\Pacs\OrthancRestClient; use Carbon\Carbon; +use Exception; use Illuminate\Pipeline\Pipeline; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; @@ -137,7 +138,7 @@ public function transformData(mixed $orthanc_src): array if (filled($dob)) { try { $study['patient_birthdate'] = Carbon::parse($dob); - } catch (\Exception) { + } catch (Exception) { Log::error('Failed to parse PatientMainDicomTags.PatientBirthDate: {dob}', ['dob' => $dob]); } }