Jake Vanderwerf
2026-05-11 ac444cba221832c012c0435fdc8339fe9f37febb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace JVBase\managers\queue;
if (!defined('ABSPATH')) {
    exit;
}
//Progress.php
final class Progress
{
    private Operation $operation;
 
    public function __construct(Operation $op)
    {
        $this->operation = $op;
    }
 
    public function advance(int $count = 1): void
    {
        $this->operation->processedItems = min(
            $this->operation->processedItems + $count,
            $this->operation->totalItems
        );
        JVB()->queue()->storage()->saveProgress($this->operation);
    }
 
    public function failItem(mixed $item, string $reason): void
    {
        $this->operation->failedItems[] = [
            'item' => $item,
            'reason' => $reason,
        ];
        JVB()->queue()->storage()->saveProgress($this->operation);
    }
}