Skip to content

Commit b623165

Browse files
committed
refactor: streamline code environment detection and remove redundant method
- Replaced `getAllPrograms` with `getCodeEnvironments` for consistency and public access. - Removed the private `getAllPrograms` method in favor of consolidated logic. - Adjusted usage across detection methods to align with the updated method structure.
1 parent 0ed0b93 commit b623165

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/Install/CodeEnvironmentsDetector.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function discoverSystemInstalledCodeEnvironments(): array
4141
{
4242
$platform = Platform::current();
4343

44-
return $this->getAllPrograms()
44+
return $this->getCodeEnvironments()
4545
->filter(fn (CodeEnvironment $program) => $program->detectOnSystem($platform))
4646
->map(fn (CodeEnvironment $program) => $program->name())
4747
->values()
@@ -55,32 +55,20 @@ public function discoverSystemInstalledCodeEnvironments(): array
5555
*/
5656
public function discoverProjectInstalledCodeEnvironments(string $basePath): array
5757
{
58-
return $this->getAllPrograms()
58+
return $this->getCodeEnvironments()
5959
->filter(fn ($program) => $program->detectInProject($basePath))
6060
->map(fn ($program) => $program->name())
6161
->values()
6262
->toArray();
6363
}
6464

6565
/**
66-
* Get all registered programs.
67-
*
68-
* @return Collection<string, CodeEnvironment>
69-
*/
70-
private function getAllPrograms(): Collection
71-
{
72-
return collect($this->programs)->map(
73-
fn (string $className) => $this->container->make($className)
74-
);
75-
}
76-
77-
/**
78-
* Get all registered programs (public access).
66+
* Get all registered code environments.
7967
*
8068
* @return Collection<string, CodeEnvironment>
8169
*/
8270
public function getCodeEnvironments(): Collection
8371
{
84-
return $this->getAllPrograms();
72+
return collect($this->programs)->map(fn (string $className) => $this->container->make($className));
8573
}
8674
}

0 commit comments

Comments
 (0)