Skip to content

Commit 7f334fe

Browse files
committed
cs-fix
1 parent 797665f commit 7f334fe

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/Source/Docs/DocsSourceFetcher.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(
4040
public function supports(SourceInterface $source): bool
4141
{
4242
$isSupported = $source instanceof DocsSource;
43-
$this->logger?->debug('Checking if source is supported', [
43+
$this->logger->debug('Checking if source is supported', [
4444
'sourceType' => $source::class,
4545
'isSupported' => $isSupported,
4646
]);
@@ -51,13 +51,13 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
5151
{
5252
if (!$source instanceof DocsSource) {
5353
$errorMessage = 'Source must be an instance of DocsSource';
54-
$this->logger?->error($errorMessage, [
54+
$this->logger->error($errorMessage, [
5555
'sourceType' => $source::class,
5656
]);
5757
throw new \InvalidArgumentException($errorMessage);
5858
}
5959

60-
$this->logger?->info('Fetching documentation from Context7', [
60+
$this->logger->info('Fetching documentation from Context7', [
6161
'library' => $source->library,
6262
'topic' => $source->topic,
6363
'tokens' => $source->tokens,
@@ -82,9 +82,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
8282
$tokens,
8383
);
8484

85-
trap($url);
86-
87-
$this->logger?->debug('Sending HTTP request to Context7', [
85+
$this->logger->debug('Sending HTTP request to Context7', [
8886
'url' => $url,
8987
'headers' => $this->defaultHeaders,
9088
]);
@@ -95,7 +93,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
9593
$statusCode = $response->getStatusCode();
9694

9795
if (!$response->isSuccess()) {
98-
$this->logger?->warning('Context7 request failed', [
96+
$this->logger->warning('Context7 request failed', [
9997
'url' => $url,
10098
'statusCode' => $statusCode,
10199
]);
@@ -108,7 +106,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
108106
return $builder->build();
109107
}
110108

111-
$this->logger?->debug('Context7 request successful', [
109+
$this->logger->debug('Context7 request successful', [
112110
'url' => $url,
113111
'statusCode' => $statusCode,
114112
]);
@@ -117,7 +115,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
117115
$content = $response->getBody();
118116
$contentLength = \strlen($content);
119117

120-
$this->logger?->debug('Received documentation content', [
118+
$this->logger->debug('Received documentation content', [
121119
'library' => $library,
122120
'topic' => $topic,
123121
'contentLength' => $contentLength,
@@ -136,7 +134,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
136134
// Add the processed content to the builder
137135
$builder->addText($processedContent);
138136
} catch (\Throwable $e) {
139-
$this->logger?->error('Error retrieving documentation from Context7', [
137+
$this->logger->error('Error retrieving documentation from Context7', [
140138
'library' => $source->library ?? 'unknown',
141139
'topic' => $source->topic ?? 'unknown',
142140
'error' => $e->getMessage(),
@@ -152,7 +150,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
152150
}
153151

154152
$content = $builder->build();
155-
$this->logger?->info('Documentation content fetched successfully', [
153+
$this->logger->info('Documentation content fetched successfully', [
156154
'contentLength' => \strlen($content),
157155
]);
158156

src/Source/Gitlab/GitlabSourceFetcher.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
/**
1616
* @implements SourceFetcherInterface<GitlabSource>
1717
*/
18+
#[LoggerPrefix(prefix: 'gitlab-source')]
1819
final readonly class GitlabSourceFetcher implements SourceFetcherInterface
1920
{
2021
public function __construct(
2122
private GitlabFinder $finder,
23+
private LoggerInterface $logger,
2224
private ContentBuilderFactory $builderFactory = new ContentBuilderFactory(),
23-
#[LoggerPrefix(prefix: 'gitlab-source')]
24-
private ?LoggerInterface $logger = null,
2525
) {}
2626

2727
public function supports(SourceInterface $source): bool
2828
{
2929
$isSupported = $source instanceof GitlabSource;
30-
$this->logger?->debug('Checking if source is supported', [
30+
$this->logger->debug('Checking if source is supported', [
3131
'sourceType' => $source::class,
3232
'isSupported' => $isSupported,
3333
]);
@@ -38,28 +38,28 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
3838
{
3939
if (!$source instanceof GitlabSource) {
4040
$errorMessage = 'Source must be an instance of GitlabSource';
41-
$this->logger?->error($errorMessage, [
41+
$this->logger->error($errorMessage, [
4242
'sourceType' => $source::class,
4343
]);
4444
throw new \InvalidArgumentException($errorMessage);
4545
}
4646

47-
$this->logger?->info('Fetching GitLab source content', [
47+
$this->logger->info('Fetching GitLab source content', [
4848
'repository' => $source->repository,
4949
'branch' => $source->branch,
5050
'hasModifiers' => !empty($source->modifiers),
5151
'showTreeView' => $source->showTreeView,
5252
]);
5353

5454
// Parse repository from string
55-
$this->logger?->debug('Parsing repository from string', [
55+
$this->logger->debug('Parsing repository from string', [
5656
'repository' => $source->repository,
5757
'branch' => $source->branch,
5858
]);
5959
$repository = new GitlabRepository($source->repository, $source->branch);
6060

6161
// Create builder
62-
$this->logger?->debug('Creating content builder');
62+
$this->logger->debug('Creating content builder');
6363
$builder = $this->builderFactory
6464
->create()
6565
->addTitle($source->getDescription(), 2);
@@ -76,27 +76,27 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
7676
);
7777

7878
// Find files using the finder and get the FinderResult
79-
$this->logger?->debug('Finding files in repository', [
79+
$this->logger->debug('Finding files in repository', [
8080
'repository' => $repository->getPath(),
8181
'branch' => $repository->branch,
8282
]);
8383
$finderResult = $this->finder->find($source);
8484
$fileCount = $finderResult->count();
85-
$this->logger?->debug('Files found in repository', [
85+
$this->logger->debug('Files found in repository', [
8686
'fileCount' => $fileCount,
8787
]);
8888

8989
// Add tree view if requested
9090
if ($source->showTreeView) {
91-
$this->logger?->debug('Adding tree view to output');
91+
$this->logger->debug('Adding tree view to output');
9292
$builder->addTreeView($finderResult->treeView);
9393
}
9494

9595
// Fetch and add the content of each file
96-
$this->logger?->debug('Processing repository files');
96+
$this->logger->debug('Processing repository files');
9797
foreach ($finderResult->files as $index => $file) {
9898
$path = $file->getRelativePathname();
99-
$this->logger?->debug('Processing file', [
99+
$this->logger->debug('Processing file', [
100100
'file' => $path,
101101
'index' => $index + 1,
102102
'total' => $fileCount,
@@ -105,7 +105,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
105105
$fileContent = $modifiersApplier->apply($file->getContents(), $path);
106106

107107
$language = $this->detectLanguage($path);
108-
$this->logger?->debug('Adding file to content', [
108+
$this->logger->debug('Adding file to content', [
109109
'file' => $path,
110110
'language' => $language,
111111
'contentLength' => \strlen($fileContent),
@@ -120,7 +120,7 @@ public function fetch(SourceInterface $source, ModifiersApplierInterface $modifi
120120
}
121121

122122
$content = $builder->build();
123-
$this->logger?->info('GitLab source content fetched successfully', [
123+
$this->logger->info('GitLab source content fetched successfully', [
124124
'repository' => $repository->getPath(),
125125
'branch' => $repository->branch,
126126
'fileCount' => $fileCount,
@@ -138,7 +138,7 @@ private function detectLanguage(string $filePath): ?string
138138
{
139139
$extension = \pathinfo($filePath, PATHINFO_EXTENSION);
140140

141-
$this->logger?->debug('Detecting language for file', [
141+
$this->logger->debug('Detecting language for file', [
142142
'file' => $filePath,
143143
'extension' => $extension,
144144
]);

0 commit comments

Comments
 (0)