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 Doba 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
|
|
|
* Po unserializaci je zde trida excpetion |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
private $exceptionClass = ''; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Po unserializaci je zde text exception |
46
|
|
|
* |
47
|
|
|
* Pouziva __toString() methodu |
48
|
|
|
* |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
private $exceptionString = ''; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $fname Nazev volane funkce |
55
|
|
|
* @param array<int, mixed> $args Argumenty pozadavku |
56
|
|
|
*/ |
57
|
4 |
|
public function __construct( |
58
|
|
|
string $fname, |
59
|
|
|
array $args, |
60
|
|
|
Throwable $throwable, |
61
|
|
|
float $duration |
62
|
|
|
) { |
63
|
4 |
|
$this->fname = $fname; |
64
|
4 |
|
$this->args = $args; |
65
|
4 |
|
$this->throwable = $throwable; |
66
|
4 |
|
$this->exceptionClass = get_class($throwable); |
67
|
4 |
|
$this->exceptionString = (string) $throwable; |
68
|
4 |
|
$this->time = $duration; |
69
|
4 |
|
} |
70
|
|
|
|
71
|
2 |
|
public function serialize(): string |
72
|
|
|
{ |
73
|
|
|
$data = [ |
74
|
2 |
|
'fname' => $this->fname, |
75
|
2 |
|
'args' => $this->args, |
76
|
2 |
|
'time' => $this->time, |
77
|
2 |
|
'exception_class' => $this->exceptionClass, |
78
|
2 |
|
'exception_string' => $this->exceptionString, |
79
|
|
|
]; |
80
|
2 |
|
return serialize($data); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $data |
85
|
|
|
*/ |
86
|
2 |
|
public function unserialize($data): void |
87
|
|
|
{ |
88
|
2 |
|
$data = unserialize($data, [self::class]); |
89
|
2 |
|
$this->fname = (string) $data['fname']; |
90
|
2 |
|
$this->args = (array) $data['args']; |
91
|
2 |
|
$this->time = (float) $data['time']; |
92
|
2 |
|
$this->exceptionClass = (string) $data['exception_class']; |
93
|
2 |
|
$this->exceptionString = (string) $data['exception_string']; |
94
|
2 |
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Vrati tridu exception |
98
|
|
|
* |
99
|
|
|
* Pouziva se tato metoda protoze SoapFault exception vyhozena SoapClientem nejde serializovat |
100
|
|
|
*/ |
101
|
3 |
|
public function getExceptionClass(): string |
102
|
|
|
{ |
103
|
3 |
|
if ($this->throwable === null) { |
104
|
2 |
|
return $this->exceptionClass; |
105
|
|
|
} |
106
|
|
|
|
107
|
1 |
|
return get_class($this->throwable); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Vrati textovou podobu exception |
112
|
|
|
*/ |
113
|
3 |
|
public function getExceptionString(): string |
114
|
|
|
{ |
115
|
3 |
|
if ($this->throwable === null) { |
116
|
2 |
|
return $this->exceptionString; |
117
|
|
|
} |
118
|
|
|
|
119
|
1 |
|
return (string)$this->throwable; |
120
|
|
|
} |
121
|
|
|
|
122
|
2 |
|
public function getFname(): string |
123
|
|
|
{ |
124
|
2 |
|
return $this->fname; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return array<int, mixed> |
|
|
|
|
130
|
|
|
*/ |
131
|
2 |
|
public function getArgs(): array |
132
|
|
|
{ |
133
|
2 |
|
return $this->args; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
2 |
|
public function getDuration(): float |
138
|
|
|
{ |
139
|
2 |
|
return $this->time; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return Throwable|null null when object is de-serialized |
144
|
|
|
* |
145
|
|
|
* @see RequestFailEvent::getExceptionString() |
146
|
|
|
* @see RequestFailEvent::getExceptionClass() |
147
|
|
|
*/ |
148
|
|
|
public function getThrowable(): ?Throwable |
149
|
|
|
{ |
150
|
|
|
return $this->throwable; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
} |
154
|
|
|
|
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.