• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 14049246919

24 Mar 2025 09:42PM UTC coverage: 79.353% (-0.04%) from 79.391%
14049246919

push

github

web-flow
feat(support): support array parameters in string manipulations (#1073)

48 of 48 new or added lines in 2 files covered. (100.0%)

735 existing lines in 126 files now uncovered.

10492 of 13222 relevant lines covered (79.35%)

90.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Tempest/Core/src/Commands/DiscoveryGenerateCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Core\Commands;
6

7
use Closure;
8
use Tempest\Cache\DiscoveryCacheStrategy;
9
use Tempest\Console\ConsoleCommand;
10
use Tempest\Console\HasConsole;
11
use Tempest\Container\Container;
12
use Tempest\Container\GenericContainer;
13
use Tempest\Core\DiscoveryCache;
14
use Tempest\Core\FrameworkKernel;
15
use Tempest\Core\Kernel;
16
use Tempest\Core\Kernel\LoadDiscoveryClasses;
17

18
use function Tempest\env;
19

20
final readonly class DiscoveryGenerateCommand
21
{
22
    use HasConsole;
23

24
    public function __construct(
×
25
        private Kernel $kernel,
26
        private DiscoveryCache $discoveryCache,
UNCOV
27
    ) {}
×
28

UNCOV
29
    #[ConsoleCommand(name: 'discovery:generate', description: 'Compile and cache all discovery according to the configured discovery caching strategy')]
×
30
    public function __invoke(): void
31
    {
UNCOV
32
        $strategy = $this->resolveDiscoveryCacheStrategy();
×
33

UNCOV
34
        if ($strategy === DiscoveryCacheStrategy::NONE) {
×
35
            $this->info('Discovery cache disabled, nothing to generate.');
×
36

UNCOV
37
            return;
×
38
        }
39

UNCOV
40
        $this->clearDiscoveryCache();
×
41

UNCOV
42
        $this->console->task(
×
43
            label: "Generating discovery cache using the {$strategy->value} strategy",
×
44
            handler: fn (Closure $log) => $this->generateDiscoveryCache($strategy, $log),
×
45
        );
×
46

UNCOV
47
        $this->discoveryCache->storeStrategy($strategy);
×
48
    }
49

UNCOV
50
    public function clearDiscoveryCache(): void
×
51
    {
UNCOV
52
        $this->console->call(DiscoveryClearCommand::class);
×
53
    }
54

UNCOV
55
    public function generateDiscoveryCache(DiscoveryCacheStrategy $strategy, Closure $log): void
×
56
    {
UNCOV
57
        $kernel = $this->resolveKernel();
×
58

UNCOV
59
        $loadDiscoveryClasses = new LoadDiscoveryClasses(
×
60
            kernel: $kernel,
×
61
            container: $kernel->container,
×
62
            discoveryCache: $this->discoveryCache,
×
63
        );
×
64

UNCOV
65
        $discoveries = $loadDiscoveryClasses->build();
×
66

UNCOV
67
        foreach ($discoveries as $discovery) {
×
68
            $log($discovery::class);
×
69
            $discoveryItems = $discovery->getItems();
×
70

UNCOV
71
            if ($strategy === DiscoveryCacheStrategy::PARTIAL) {
×
72
                $discoveryItems = $discoveryItems->onlyVendor();
×
73
            }
74

UNCOV
75
            $this->discoveryCache->store($discovery, $discoveryItems);
×
76
        }
77
    }
78

UNCOV
79
    private function resolveDiscoveryCacheStrategy(): DiscoveryCacheStrategy
×
80
    {
UNCOV
81
        $cache = env('CACHE');
×
82

UNCOV
83
        if ($cache !== null) {
×
84
            return DiscoveryCacheStrategy::make($cache);
×
85
        }
86

UNCOV
87
        return DiscoveryCacheStrategy::make(env('DISCOVERY_CACHE'));
×
88
    }
89

UNCOV
90
    public function resolveKernel(): Kernel
×
91
    {
UNCOV
92
        $container = new GenericContainer();
×
93
        $container->singleton(Container::class, $container);
×
94

UNCOV
95
        return new FrameworkKernel(
×
96
            root: $this->kernel->root,
×
97
            discoveryLocations: $this->kernel->discoveryLocations,
×
98
            container: $container,
×
99
        )
×
100
            ->registerKernel()
×
101
            ->loadComposer()
×
102
            ->loadConfig();
×
103
    }
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc