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

daycry / cronjob / 18288101817

06 Oct 2025 04:45PM UTC coverage: 68.511% (-1.0%) from 69.514%
18288101817

push

github

daycry
Update README.md

483 of 705 relevant lines covered (68.51%)

5.53 hits per line

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

66.67
/src/Traits/ActivityTrait.php
1
<?php
2

3
namespace Daycry\CronJob\Traits;
4

5
use CodeIgniter\I18n\Time;
6
use Cron\CronExpression;
7

8
/**
9
 * Trait ActivityTrait
10
 */
11
trait ActivityTrait
12
{
13
    use LogTrait;
14

15
    /**
16
     * Determines whether this task should be run now
17
     * according to its schedule and environment.
18
     */
19
    public function shouldRun(?Time $testTime = null): bool
20
    {
21
        $this->testTime = $testTime;
14✔
22
        // Are we restricting to environments?
23
        if (! empty($this->environments) && ! $this->runsInEnvironment($_SERVER['CI_ENVIRONMENT'])) {
14✔
24
            return false;
2✔
25
        }
26

27
        $cron = new CronExpression($this->getExpression());
13✔
28

29
        $testTime = ($testTime) ?: 'now';
13✔
30

31
        return $cron->isDue($testTime, config('App')->appTimezone);
13✔
32
    }
33

34
    /**
35
     * Returns the date this was last ran.
36
     *
37
     * @return string|Time
38
     */
39
    public function lastRun()
40
    {
41
        if ($this->config->logPerformance === false) {
1✔
42
            return '--';
×
43
        }
44

45
        $name = ($this->name) ?: $this->buildName();
1✔
46

47
        $this->setHandler();
1✔
48

49
        return $this->handler->lastRun($name);
1✔
50
    }
51

52
    /**
53
     * Returns the last run time as a Time instance or null when not available.
54
     * (Non-breaking addition alongside legacy lastRun() method that can return string "--").
55
     */
56
    public function getLastRunTime(): ?Time
57
    {
58
        if ($this->config->logPerformance === false) {
×
59
            return null;
×
60
        }
61
        $val = $this->lastRun();
×
62
        return $val instanceof Time ? $val : null;
×
63
    }
64
}
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