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

IlyasDeckers / ody-core / 13587688054

28 Feb 2025 12:00PM UTC coverage: 33.151% (+0.02%) from 33.13%
13587688054

push

github

IlyasDeckers
Register commands from serviceproviders

0 of 6 new or added lines in 1 file covered. (0.0%)

544 of 1641 relevant lines covered (33.15%)

9.97 hits per line

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

0.0
/src/Console/Console.php
1
<?php
2
declare (strict_types = 1);
3
namespace Ody\Core\Console;
4

5
use Composer\ClassMapGenerator\ClassMapGenerator;
6
use Ody\Core\Env;
7
use Symfony\Component\Console\Application;
8
use Exception;
9

10
final class Console
11
{
12
    /**
13
     * @throws Exception
14
     */
15
    public static function init(): void
×
16
    {
17
        Env::load('./');
×
18
        $application = new Application();
×
19
        $application->addCommands(
×
20
            (new Console())->generateCommandsClassMap()
×
21
        );
×
22
        $application->run();
×
23
    }
24

25
    private function generateCommandsClassMap(): array
×
26
    {
27
        $classMapGenerator = new ClassMapGenerator;
×
28
        $classMapGenerator->scanPaths('App/Console/Commands');
×
29
        $classMapGenerator->scanPaths(__dir__ . '/Commands');
×
30
        $classMapGenerator = $classMapGenerator->getClassMap();
×
31

32
        $classMap = [];
×
33
        foreach (array_keys($classMapGenerator->getMap()) as $class) {
×
34
            $classMap[] = new $class();
×
35
        }
36

37
        // TODO: Place these in ServiceProviders
38
        if (class_exists('Ody\DB\Migrations\Command\StatusCommand')) {
×
39
            $classMap[] = new \Ody\DB\Migrations\Command\StatusCommand('migrations:status');
×
40
            $classMap[] = new \Ody\DB\Migrations\Command\MigrateCommand('migrations:run');
×
41
            $classMap[] = new \Ody\DB\Migrations\Command\CleanupCommand('migrations:clear');
×
42
            $classMap[] = new \Ody\DB\Migrations\Command\DumpCommand('migrations:dump');
×
43
            $classMap[] = new \Ody\DB\Migrations\Command\InitCommand('migrations:init');
×
44
            $classMap[] = new \Ody\DB\Migrations\Command\RollbackCommand('migrations:rollback');
×
45
            $classMap[] = new \Ody\DB\Migrations\Command\StatusCommand('migrations:status');
×
46
            $classMap[] = new \Ody\DB\Migrations\Command\CreateCommand('migrations:create');
×
47
            $classMap[] = new \Ody\DB\Migrations\Command\DiffCommand('migrations:diff');
×
48
        }
49

NEW
50
        $providers = config('app.service_providers');
×
NEW
51
        foreach ($providers as $provider) {
×
NEW
52
            $providerClass = (new $provider());
×
NEW
53
            if (method_exists($providerClass, 'commands')) {
×
NEW
54
                foreach ($providerClass->commands() as $command) {
×
NEW
55
                    $classMap[] = new $command();
×
56
                }
57
            }
58
        }
59

60
        return $classMap;
×
61
    }
62
}
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