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

avoutic / web-framework / 45418632783

24 Nov 2026 02:47PM UTC coverage: 69.305% (-4.3%) from 73.637%
45418632783

push

github

avoutic
Mark the config_values table as deprecated

2872 of 4144 relevant lines covered (69.31%)

2.89 hits per line

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

68.75
/src/Console/ConsoleTaskRegistryService.php
1
<?php
2

3
/*
4
 * This file is part of WebFramework.
5
 *
6
 * (c) Avoutic <avoutic@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
namespace WebFramework\Console;
13

14
use Psr\Container\ContainerInterface as Container;
15
use WebFramework\Config\ConfigService;
16
use WebFramework\Task\CacheClearTask;
17
use WebFramework\Task\CleanupVerificationCodesTask;
18
use WebFramework\Task\ConfigShowTask;
19
use WebFramework\Task\ConsoleTask;
20
use WebFramework\Task\DbConvertFromSchemeTask;
21
use WebFramework\Task\DbConvertProductionTask;
22
use WebFramework\Task\DbMakeMigrationTask;
23
use WebFramework\Task\DbMigrateTask;
24
use WebFramework\Task\DbRollbackTask;
25
use WebFramework\Task\DbStatusTask;
26
use WebFramework\Task\DefinitionsShowTask;
27
use WebFramework\Task\QueueClear;
28
use WebFramework\Task\QueueList;
29
use WebFramework\Task\QueueWorker;
30
use WebFramework\Task\SanityCheckTask;
31
use WebFramework\Task\TaskRunnerTask;
32

33
/**
34
 * Class ConsoleTaskRegistryService.
35
 *
36
 * Registers and manages app-specific console tasks.
37
 */
38
class ConsoleTaskRegistryService
39
{
40
    /** @var array<string, class-string> */
41
    private array $frameworkCommands = [
42
        'cache:clear' => CacheClearTask::class,
43
        'config:show' => ConfigShowTask::class,
44
        'definitions:show' => DefinitionsShowTask::class,
45
        'db:migrate' => DbMigrateTask::class,
46
        'db:rollback' => DbRollbackTask::class,
47
        'db:convert-from-scheme' => DbConvertFromSchemeTask::class,
48
        'db:convert-production' => DbConvertProductionTask::class,
49
        'db:status' => DbStatusTask::class,
50
        'db:make' => DbMakeMigrationTask::class,
51
        'queue:clear' => QueueClear::class,
52
        'queue:list' => QueueList::class,
53
        'queue:worker' => QueueWorker::class,
54
        'sanity:check' => SanityCheckTask::class,
55
        'task:run' => TaskRunnerTask::class,
56
        'verification-codes:cleanup' => CleanupVerificationCodesTask::class,
57
    ];
58

59
    /**
60
     * ConsoleTaskRegistryService constructor.
61
     *
62
     * @param ConfigService $configService The configuration service
63
     * @param Container     $container     The container
64
     */
65
    public function __construct(
×
66
        private ConfigService $configService,
67
        private Container $container,
68
    ) {}
×
69

70
    /**
71
     * Retrieve all framework-specific tasks.
72
     *
73
     * @return array<string, class-string> Array of command => task mappings
74
     */
75
    public function getFrameworkTasks(): array
×
76
    {
77
        return $this->frameworkCommands;
×
78
    }
79

80
    /**
81
     * Retrieve all app-specific tasks.
82
     *
83
     * @return array<string, class-string> Array of command => task mappings
84
     */
85
    public function getAppTasks(): array
3 ✔
86
    {
87
        return $this->configService->get('console_tasks');
3 ✔
88
    }
89

90
    /**
91
     * Get a task for a command.
92
     *
93
     * @param string $command The command to get a task for
94
     *
95
     * @return ConsoleTask The task for the command
96
     */
97
    public function getTaskForCommand(string $command): ?ConsoleTask
2 ✔
98
    {
99
        $taskClass = $this->frameworkCommands[$command] ?? null;
2 ✔
100

101
        if (!$taskClass)
2 ✔
102
        {
103
            $taskClass = $this->getAppTasks()[$command] ?? null;
2 ✔
104
        }
105

106
        if (!$taskClass)
2 ✔
107
        {
108
            return null;
×
109
        }
110

111
        $task = $this->container->get($taskClass);
2 ✔
112

113
        if (!$task instanceof ConsoleTask)
2 ✔
114
        {
115
            throw new \RuntimeException("Task {$taskClass} does not implement ConsoleTask");
1 ✔
116
        }
117

118
        return $task;
1 ✔
119
    }
120
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc