1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace Skaut\Skautis\Wsdl\Event; |
5
|
|
|
|
6
|
|
|
use Serializable; |
7
|
|
|
use Throwable; |
8
|
|
|
|
9
|
|
|
class RequestFailEvent implements Serializable |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var string Nazev funkce volane pomoci SOAP requestu |
14
|
|
|
*/ |
15
|
|
|
private $fname; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Parametry SOAP requestu na server |
19
|
|
|
* |
20
|
|
|
* @var array<int, mixed> |
21
|
|
|
*/ |
22
|
|
|
private $args; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var float Pocet sekund trvani pozadvku |
26
|
|
|
*/ |
27
|
|
|
private $time; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Ne vsechny exceptions jdou serializovat. |
31
|
|
|
* Po unserializaci je null. |
32
|
|
|
* |
33
|
|
|
* @var Throwable|null |
34
|
|
|
*/ |
35
|
|
|
private $throwable; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $exceptionClass; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Pouziva __toString() methodu |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private $exceptionString; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param string $fname Nazev volane funkce |
51
|
|
|
* @param array<int, mixed> $args Argumenty pozadavku |
52
|
|
|
*/ |
53
|
4 |
|
public function __construct( |
54
|
|
|
string $fname, |
55
|
|
|
array $args, |
56
|
|
|
Throwable $throwable, |
57
|
|
|
float $duration |
58
|
|
|
) { |
59
|
4 |
|
$this->fname = $fname; |
60
|
4 |
|
$this->args = $args; |
61
|
4 |
|
$this->throwable = $throwable; |
62
|
4 |
|
$this->exceptionClass = get_class($throwable); |
63
|
4 |
|
$this->exceptionString = (string) $throwable; |
64
|
4 |
|
$this->time = $duration; |
65
|
4 |
|
} |
66
|
|
|
|
67
|
2 |
|
public function serialize(): string |
68
|
|
|
{ |
69
|
|
|
$data = [ |
70
|
2 |
|
'fname' => $this->fname, |
71
|
2 |
|
'args' => $this->args, |
72
|
2 |
|
'time' => $this->time, |
73
|
2 |
|
'exception_class' => $this->exceptionClass, |
74
|
2 |
|
'exception_string' => $this->exceptionString, |
75
|
|
|
]; |
76
|
2 |
|
return serialize($data); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param string $data |
81
|
|
|
*/ |
82
|
2 |
|
public function unserialize($data): void |
83
|
|
|
{ |
84
|
2 |
|
$data = unserialize($data, ['allowed_classes' => [self::class]]); |
85
|
2 |
|
$this->fname = (string) $data['fname']; |
86
|
2 |
|
$this->args = (array) $data['args']; |
87
|
2 |
|
$this->time = (float) $data['time']; |
88
|
2 |
|
$this->exceptionClass = (string) $data['exception_class']; |
89
|
2 |
|
$this->exceptionString = (string) $data['exception_string']; |
90
|
2 |
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Vrati tridu exception |
94
|
|
|
* |
95
|
|
|
* Pouziva se tato metoda protoze SoapFault exception vyhozena SoapClientem nejde serializovat |
96
|
|
|
*/ |
97
|
3 |
|
public function getExceptionClass(): string |
98
|
|
|
{ |
99
|
3 |
|
if ($this->throwable === null) { |
100
|
2 |
|
return $this->exceptionClass; |
101
|
|
|
} |
102
|
|
|
|
103
|
1 |
|
return get_class($this->throwable); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Vrati textovou podobu exception |
108
|
|
|
*/ |
109
|
3 |
|
public function getExceptionString(): string |
110
|
|
|
{ |
111
|
3 |
|
if ($this->throwable === null) { |
112
|
2 |
|
return $this->exceptionString; |
113
|
|
|
} |
114
|
|
|
|
115
|
1 |
|
return (string)$this->throwable; |
116
|
|
|
} |
117
|
|
|
|
118
|
2 |
|
public function getFname(): string |
119
|
|
|
{ |
120
|
2 |
|
return $this->fname; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return array<int, mixed> |
|
|
|
|
126
|
|
|
*/ |
127
|
2 |
|
public function getArgs(): array |
128
|
|
|
{ |
129
|
2 |
|
return $this->args; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Pocet sekund trvani pozadvku |
135
|
|
|
*/ |
136
|
2 |
|
public function getDuration(): float |
137
|
|
|
{ |
138
|
2 |
|
return $this->time; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return Throwable|null null when object is de-serialized |
143
|
|
|
* |
144
|
|
|
* @see RequestFailEvent::getExceptionString() |
145
|
|
|
* @see RequestFailEvent::getExceptionClass() |
146
|
|
|
*/ |
147
|
|
|
public function getThrowable(): ?Throwable |
148
|
|
|
{ |
149
|
|
|
return $this->throwable; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
} |
153
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.