Services::scheduler()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 2
cp 0
rs 10
cc 3
nc 2
nop 1
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of BlitzPHP Tasks.
7
 *
8
 * (c) 2025 Dimitri Sitchet Tomkeu <[email protected]>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13
14
namespace BlitzPHP\Tasks\Config;
15
16
use BlitzPHP\Container\Services as BaseServices;
17
use BlitzPHP\Tasks\CronExpression;
18
use BlitzPHP\Tasks\Scheduler;
19
20
class Services extends BaseServices
21
{
22
    /**
23
     * Renvoie le planificateur de tâches
24
     */
25
    public static function scheduler(bool $shared = true): Scheduler
26
    {
27
        if (true === $shared && isset(static::$instances[Scheduler::class])) {
28
            return static::$instances[Scheduler::class];
29
        }
30
31
        return static::$instances[Scheduler::class] = new Scheduler();
32
    }
33
34
    /**
35
     * Renvoie la classe CronExpression.
36
     */
37
    public static function cronExpression(bool $shared = true): CronExpression
38
    {
39
        if (true === $shared && isset(static::$instances[CronExpression::class])) {
40
            return static::$instances[CronExpression::class];
41
        }
42
43
        return static::$instances[CronExpression::class] = new CronExpression();
44
    }
45
}
46