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

daycry / jobs / 20573383244

19 Nov 2025 03:37PM UTC coverage: 60.218% (-2.3%) from 62.5%
20573383244

push

github

daycry
- Improvements

22 of 25 new or added lines in 12 files covered. (88.0%)

46 existing lines in 3 files now uncovered.

1105 of 1835 relevant lines covered (60.22%)

4.63 hits per line

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

66.67
/src/Queues/BaseQueue.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Queues.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
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 Daycry\Jobs\Queues;
15

16
use Daycry\Jobs\Interfaces\IdGeneratorInterface;
17
use Daycry\Jobs\Interfaces\PayloadSerializerInterface;
18
use Daycry\Jobs\Libraries\DelayResult;
19
use Daycry\Jobs\Libraries\JsonPayloadSerializer;
20
use Daycry\Jobs\Libraries\RandomIdGenerator;
21

22
abstract class BaseQueue
23
{
24
    private ?DelayResult $delayResult               = null;
25
    private ?IdGeneratorInterface $idGenerator      = null;
26
    private ?PayloadSerializerInterface $serializer = null;
27

28
    /**
29
     * Calcula delay desde schedule y retorna DelayResult.
30
     */
31
    protected function calculateDelay(object $data): DelayResult
32
    {
33
        $schedule          = $data->schedule ?? null;
14✔
34
        $this->delayResult = DelayResult::fromSchedule($schedule);
14✔
35

36
        return $this->delayResult;
14✔
37
    }
38

39
    protected function getDelayResult(): DelayResult
40
    {
41
        return $this->delayResult ?? new DelayResult(0, null);
×
42
    }
43

44
    public function setIdGenerator(IdGeneratorInterface $generator): self
45
    {
46
        $this->idGenerator = $generator;
×
47

UNCOV
48
        return $this;
×
49
    }
50

51
    protected function getIdGenerator(): IdGeneratorInterface
52
    {
53
        if (! $this->idGenerator) {
6✔
54
            // Posible clase personalizada desde config en fases futuras
55
            $this->idGenerator = new RandomIdGenerator();
6✔
56
        }
57

58
        return $this->idGenerator;
6✔
59
    }
60

61
    protected function generateId(?string $prefix = null, int $bytes = 8): string
62
    {
63
        return $this->getIdGenerator()->generate($bytes, $prefix);
6✔
64
    }
65

66
    public function setSerializer(PayloadSerializerInterface $serializer): self
67
    {
68
        $this->serializer = $serializer;
×
69

UNCOV
70
        return $this;
×
71
    }
72

73
    protected function getSerializer(): PayloadSerializerInterface
74
    {
75
        if (! $this->serializer) {
9✔
76
            $this->serializer = new JsonPayloadSerializer();
9✔
77
        }
78

79
        return $this->serializer;
9✔
80
    }
81
}
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