Passed
Push — dev ( eeaa0f...91a85a )
by Janko
26:10
created

EventSchedulerCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 11
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Cli;
6
7
use Ahc\Cli\Input\Command;
8
use Psr\Container\ContainerInterface;
9
use Stu\Component\Event\EventSchedulerInterface;
10
11
/**
12
 * Provides cli method for manual event scheduling
13
 */
14
final class EventSchedulerCommand extends Command
15
{
16
    public function __construct(
17
        private ContainerInterface $dic
18
    ) {
19
        parent::__construct(
20
            'event:schedule',
21
            'Runs the event scheduler'
22
        );
23
24
        $this
25
            ->usage(
26
                '<bold>  $0 event:schedule</end> <comment></end> ## Runs the event scheduler<eol/>'
27
            );
28
    }
29
30
    public function execute(): void
31
    {
32
        $eventScheduler = $this->dic->get(EventSchedulerInterface::class);
33
        $eventScheduler->processEvents();
34
35
        $this->io()->ok(
36
            'Event Scheduler has been executed',
37
            true
38
        );
39
    }
40
}
41