Passed
Pull Request — master (#407)
by
unknown
03:23
created

cron_task()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 3.0.0
13
 */
14
15
use Quantum\Libraries\Cron\CronManager;
16
use Quantum\Libraries\Cron\CronTask;
17
use Quantum\Libraries\Cron\Schedule;
18
19
if (!function_exists('cron_manager')) {
20
    /**
21
     * Get CronManager instance
22
     * @param string|null $cronDirectory
23
     * @return CronManager
24
     */
25
    function cron_manager(?string $cronDirectory = null): CronManager
26
    {
27
        return new CronManager($cronDirectory);
28
    }
29
}
30
31
if (!function_exists('cron_task')) {
32
    /**
33
     * Create a new cron task
34
     * @param string $name
35
     * @param string $expression
36
     * @param callable $callback
37
     * @return CronTask
38
     * @throws \Quantum\Libraries\Cron\Exceptions\CronException
39
     */
40
    function cron_task(string $name, string $expression, callable $callback): CronTask
41
    {
42
        return new CronTask($name, $expression, $callback);
43
    }
44
}
45
46
if (!function_exists('schedule')) {
47
    /**
48
     * Create a new schedule with fluent API
49
     * @param string $name
50
     * @return Schedule
51
     */
52
    function schedule(string $name): Schedule
53
    {
54
        return new Schedule($name);
55
    }
56
}
57