PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.18
ووسلام – همگام سازی ووکامرس و باسلام v1.10.18
1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 1.8.7 1.8.4 All 51 releases
sync-basalam / includes / Jobs / JobResult.php

JobResult.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.18, at includes/Jobs/JobResult.php

62 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Jobs;
4
5 use SyncBasalam\Jobs\Exceptions\JobException;
6
7 defined('ABSPATH') || exit;
8
9 class JobResult
10 {
11 private $success;
12 private $exception;
13 private $data;
14
15 private function __construct(bool $success, $exception = null, array $data = [])
16 {
17 $this->success = $success;
18 $this->exception = $exception;
19 $this->data = $data;
20 }
21
22 public static function success(array $data = []): self
23 {
24 return new self(true, null, $data);
25 }
26
27 public static function failed(JobException $exception, array $data = []): self
28 {
29 return new self(false, $exception, $data);
30 }
31
32 public function isSuccessful(): bool
33 {
34 return $this->success;
35 }
36
37 public function shouldRetry(): bool
38 {
39 return !$this->success && $this->exception && $this->exception->shouldRetry();
40 }
41
42 public function getException(): ?JobException
43 {
44 return $this->exception;
45 }
46
47 public function getData(): array
48 {
49 return $this->data;
50 }
51
52 public function getErrorMessage(): ?string
53 {
54 return $this->exception ? $this->exception->getMessage() : null;
55 }
56
57 public function getErrorContext(): array
58 {
59 return $this->exception ? $this->exception->getErrorContext() : [];
60 }
61 }
62