refactor: susun semula struktur folder — Laravel source ke src/

This commit is contained in:
Saufi
2026-05-19 15:58:35 +08:00
parent f052251b94
commit bf53c71b45
10806 changed files with 1385379 additions and 121 deletions

View File

@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
namespace Laravel\Boost\Install;
use Illuminate\Container\Container;
use Illuminate\Support\Collection;
use Laravel\Boost\BoostManager;
use Laravel\Boost\Install\Agents\Agent;
use Laravel\Boost\Install\Enums\Platform;
class AgentsDetector
{
public function __construct(
private readonly Container $container,
private readonly BoostManager $boostManager
) {}
/**
* Detect installed agents on the current platform.
*
* @return array<string>
*/
public function discoverSystemInstalledAgents(): array
{
$platform = Platform::current();
return $this->getAgents()
->filter(fn (Agent $program): bool => $program->detectOnSystem($platform))
->map(fn (Agent $program): string => $program->name())
->values()
->toArray();
}
/**
* Detect agents used in the current project.
*
* @return array<string>
*/
public function discoverProjectInstalledAgents(string $basePath): array
{
return $this->getAgents()
->filter(fn (Agent $program): bool => $program->detectInProject($basePath))
->map(fn (Agent $program): string => $program->name())
->values()
->toArray();
}
/**
* Get all registered agents.
*
* @return Collection<string, Agent>
*/
public function getAgents(): Collection
{
return collect($this->boostManager->getAgents())
->map(fn (string $className) => $this->container->make($className));
}
}