Skip to content

Commit 25d9a2a

Browse files
committed
Merge branch 'main' of github.com:BinarCode/laravel-restify-boost
2 parents 44505c6 + 296bdec commit 25d9a2a

File tree

2 files changed

+140
-137
lines changed

2 files changed

+140
-137
lines changed

src/Mcp/Tools/DebugApplicationTool.php

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Generator;
88
use Illuminate\Support\Facades\Artisan;
99
use Illuminate\Support\Facades\Cache;
10-
use Illuminate\Support\Facades\Config;
1110
use Illuminate\Support\Facades\DB;
1211
use Illuminate\Support\Facades\File;
1312
use Illuminate\Support\Facades\Route;
@@ -108,7 +107,7 @@ public function handle(array $arguments): ToolResult|Generator
108107
return $this->generateDebugReport($report, $detailedOutput);
109108

110109
} catch (Throwable $e) {
111-
return ToolResult::error('Debug analysis failed: ' . $e->getMessage());
110+
return ToolResult::error('Debug analysis failed: '.$e->getMessage());
112111
}
113112
}
114113

@@ -129,7 +128,7 @@ protected function performHealthCheck(): array
129128
'status' => version_compare($phpVersion, '8.1.0', '>=') ? 'success' : 'warning',
130129
'value' => $phpVersion,
131130
'message' => version_compare($phpVersion, '8.1.0', '>=') ? 'PHP version compatible' : 'PHP version may be outdated',
132-
];
131+
];
133132

134133
// Environment check
135134
$environment = app()->environment();
@@ -162,7 +161,7 @@ protected function performHealthCheck(): array
162161
$checks['cache'] = [
163162
'status' => 'error',
164163
'value' => 'error',
165-
'message' => 'Cache error: ' . $e->getMessage(),
164+
'message' => 'Cache error: '.$e->getMessage(),
166165
];
167166
}
168167

@@ -199,7 +198,7 @@ protected function analyzeConfiguration(): array
199198
'connection' => [
200199
'status' => 'info',
201200
'value' => config('database.default'),
202-
'message' => 'Default database connection: ' . config('database.default'),
201+
'message' => 'Default database connection: '.config('database.default'),
203202
],
204203
];
205204

@@ -256,7 +255,7 @@ protected function checkDatabaseHealth(): array
256255
} catch (Throwable $e) {
257256
$checks['migrations'] = [
258257
'status' => 'warning',
259-
'message' => 'Could not check migration status: ' . $e->getMessage(),
258+
'message' => 'Could not check migration status: '.$e->getMessage(),
260259
];
261260
}
262261

@@ -282,14 +281,14 @@ protected function checkDatabaseHealth(): array
282281

283282
$checks['query_performance'] = [
284283
'status' => $queryTime < 0.1 ? 'success' : 'warning',
285-
'value' => round($queryTime * 1000, 2) . 'ms',
284+
'value' => round($queryTime * 1000, 2).'ms',
286285
'message' => $queryTime < 0.1 ? 'Good query performance' : 'Slow query performance',
287286
];
288287

289288
} catch (Throwable $e) {
290289
$checks['connection'] = [
291290
'status' => 'error',
292-
'message' => 'Database connection failed: ' . $e->getMessage(),
291+
'message' => 'Database connection failed: '.$e->getMessage(),
293292
];
294293
}
295294

@@ -352,12 +351,12 @@ protected function findRepositories(): array
352351
];
353352

354353
foreach ($searchPaths as $searchPath) {
355-
if (!File::isDirectory($searchPath)) {
354+
if (! File::isDirectory($searchPath)) {
356355
continue;
357356
}
358357

359358
try {
360-
$finder = new Finder();
359+
$finder = new Finder;
361360
$finder->files()
362361
->in($searchPath)
363362
->name('*Repository.php')
@@ -500,8 +499,8 @@ protected function collectIssues(array &$report): void
500499

501500
$report['issues'] = $issues;
502501
$report['summary']['total_issues'] = count($issues);
503-
$report['summary']['critical_issues'] = count(array_filter($issues, fn($issue) => $issue['severity'] === 'error'));
504-
$report['summary']['warnings'] = count(array_filter($issues, fn($issue) => $issue['severity'] === 'warning'));
502+
$report['summary']['critical_issues'] = count(array_filter($issues, fn ($issue) => $issue['severity'] === 'error'));
503+
$report['summary']['warnings'] = count(array_filter($issues, fn ($issue) => $issue['severity'] === 'warning'));
505504
}
506505

507506
protected function extractIssuesFromSection(array $data, string $section, array &$issues): void
@@ -555,7 +554,7 @@ protected function attemptAutoFix(array $issue): ?array
555554
try {
556555
Artisan::call('vendor:publish', [
557556
'--provider' => 'Binaryk\\LaravelRestify\\LaravelRestifyServiceProvider',
558-
'--tag' => 'config'
557+
'--tag' => 'config',
559558
]);
560559

561560
return [
@@ -566,7 +565,7 @@ protected function attemptAutoFix(array $issue): ?array
566565
} catch (Throwable $e) {
567566
return [
568567
'issue' => $issue['message'],
569-
'fix' => 'Failed to publish config: ' . $e->getMessage(),
568+
'fix' => 'Failed to publish config: '.$e->getMessage(),
570569
'status' => 'error',
571570
];
572571
}
@@ -619,7 +618,7 @@ protected function generateSuggestions(array $report): array
619618

620619
protected function exportReport(array $report): void
621620
{
622-
$reportPath = storage_path('logs/debug-report-' . date('Y-m-d-H-i-s') . '.md');
621+
$reportPath = storage_path('logs/debug-report-'.date('Y-m-d-H-i-s').'.md');
623622
$reportContent = $this->generateMarkdownReport($report);
624623

625624
File::put($reportPath, $reportContent);
@@ -628,19 +627,19 @@ protected function exportReport(array $report): void
628627
protected function generateMarkdownReport(array $report): string
629628
{
630629
$content = "# Laravel Restify Debug Report\n\n";
631-
$content .= "**Generated:** " . date('Y-m-d H:i:s') . "\n\n";
630+
$content .= '**Generated:** '.date('Y-m-d H:i:s')."\n\n";
632631

633632
// Summary
634633
if (isset($report['summary'])) {
635634
$content .= "## Summary\n\n";
636635
foreach ($report['summary'] as $key => $value) {
637-
$content .= "- **" . ucwords(str_replace('_', ' ', $key)) . ":** $value\n";
636+
$content .= '- **'.ucwords(str_replace('_', ' ', $key)).":** $value\n";
638637
}
639638
$content .= "\n";
640639
}
641640

642641
// Issues
643-
if (!empty($report['issues'])) {
642+
if (! empty($report['issues'])) {
644643
$content .= "## Issues Found\n\n";
645644
foreach ($report['issues'] as $issue) {
646645
$emoji = $issue['severity'] === 'error' ? '' : '⚠️';
@@ -654,7 +653,7 @@ protected function generateMarkdownReport(array $report): string
654653
}
655654

656655
// Suggestions
657-
if (!empty($report['suggestions'])) {
656+
if (! empty($report['suggestions'])) {
658657
$content .= "## Suggestions\n\n";
659658
foreach ($report['suggestions'] as $suggestion) {
660659
$priority = strtoupper($suggestion['priority']);
@@ -686,17 +685,17 @@ protected function generateDebugReport(array $report, bool $detailed): ToolResul
686685
if (isset($report['summary'])) {
687686
$response .= "## Summary\n\n";
688687
foreach ($report['summary'] as $key => $value) {
689-
$response .= "- **" . ucwords(str_replace('_', ' ', $key)) . ":** $value\n";
688+
$response .= '- **'.ucwords(str_replace('_', ' ', $key)).":** $value\n";
690689
}
691690
$response .= "\n";
692691
}
693692

694693
// Health Check
695-
if (!empty($report['health_check'])) {
694+
if (! empty($report['health_check'])) {
696695
$response .= "## System Health\n\n";
697696
foreach ($report['health_check'] as $check => $result) {
698697
$emoji = $this->getStatusEmoji($result['status']);
699-
$response .= "$emoji **" . ucwords(str_replace('_', ' ', $check)) . ":** {$result['message']}";
698+
$response .= "$emoji **".ucwords(str_replace('_', ' ', $check)).":** {$result['message']}";
700699
if (isset($result['value'])) {
701700
$response .= " ({$result['value']})";
702701
}
@@ -706,11 +705,11 @@ protected function generateDebugReport(array $report, bool $detailed): ToolResul
706705
}
707706

708707
// Database Check
709-
if (!empty($report['database_check'])) {
708+
if (! empty($report['database_check'])) {
710709
$response .= "## Database Health\n\n";
711710
foreach ($report['database_check'] as $check => $result) {
712711
$emoji = $this->getStatusEmoji($result['status']);
713-
$response .= "$emoji **" . ucwords(str_replace('_', ' ', $check)) . ":** {$result['message']}";
712+
$response .= "$emoji **".ucwords(str_replace('_', ' ', $check)).":** {$result['message']}";
714713
if (isset($result['value'])) {
715714
$value = is_array($result['value']) ? implode(', ', $result['value']) : $result['value'];
716715
$response .= " ($value)";
@@ -721,15 +720,15 @@ protected function generateDebugReport(array $report, bool $detailed): ToolResul
721720
}
722721

723722
// Restify Analysis
724-
if (!empty($report['restify_analysis'])) {
723+
if (! empty($report['restify_analysis'])) {
725724
$response .= "## Restify Analysis\n\n";
726725

727726
if (isset($report['restify_analysis']['repositories'])) {
728727
$repos = $report['restify_analysis']['repositories'];
729728
$emoji = $this->getStatusEmoji($repos['status']);
730729
$response .= "$emoji **Repositories:** {$repos['message']} ({$repos['count']} found)\n";
731730

732-
if (!empty($repos['list']) && $detailed) {
731+
if (! empty($repos['list']) && $detailed) {
733732
foreach ($repos['list'] as $repo) {
734733
$response .= " - $repo\n";
735734
}
@@ -746,7 +745,7 @@ protected function generateDebugReport(array $report, bool $detailed): ToolResul
746745
}
747746

748747
// Issues
749-
if (!empty($report['issues'])) {
748+
if (! empty($report['issues'])) {
750749
$response .= "## Issues Found\n\n";
751750
foreach ($report['issues'] as $issue) {
752751
$emoji = $issue['severity'] === 'error' ? '' : '⚠️';
@@ -756,7 +755,7 @@ protected function generateDebugReport(array $report, bool $detailed): ToolResul
756755
}
757756

758757
// Fixes Applied
759-
if (!empty($report['fixes_applied'])) {
758+
if (! empty($report['fixes_applied'])) {
760759
$response .= "## Automatic Fixes Applied\n\n";
761760
foreach ($report['fixes_applied'] as $fix) {
762761
$emoji = $fix['status'] === 'success' ? '' : '';
@@ -766,7 +765,7 @@ protected function generateDebugReport(array $report, bool $detailed): ToolResul
766765
}
767766

768767
// Suggestions
769-
if (!empty($report['suggestions'])) {
768+
if (! empty($report['suggestions'])) {
770769
$response .= "## Recommendations\n\n";
771770
foreach ($report['suggestions'] as $suggestion) {
772771
$priority = strtoupper($suggestion['priority']);
@@ -805,11 +804,13 @@ protected function getStatusEmoji(string $status): string
805804

806805
protected function formatBytes(int $size, int $precision = 2): string
807806
{
808-
if ($size === 0) return '0B';
807+
if ($size === 0) {
808+
return '0B';
809+
}
809810

810811
$base = log($size, 1024);
811812
$suffixes = ['B', 'KB', 'MB', 'GB', 'TB'];
812813

813-
return round(pow(1024, $base - floor($base)), $precision) . ' ' . $suffixes[floor($base)];
814+
return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)];
814815
}
815816
}

0 commit comments

Comments
 (0)