PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.23
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.23
1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 All 168 releases
woocommerce-pos / vendor_prefixed / sentry / sentry / src / Options.php

Options.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.23, at vendor_prefixed/sentry/sentry/src/Options.php

1,408 lines 50.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sentry;
5
6 use WCPOS\Vendor\Psr\Log\LoggerInterface;
7 use WCPOS\Vendor\Psr\Log\NullLogger;
8 use WCPOS\Vendor\Sentry\HttpClient\HttpClientInterface;
9 use WCPOS\Vendor\Sentry\Integration\ErrorListenerIntegration;
10 use WCPOS\Vendor\Sentry\Integration\IntegrationInterface;
11 use WCPOS\Vendor\Sentry\Logs\Log;
12 use WCPOS\Vendor\Sentry\Metrics\Types\Metric;
13 use WCPOS\Vendor\Sentry\Transport\TransportInterface;
14 /**
15 * Configuration container for the Sentry client.
16 *
17 * @author Stefano Arlandini <[email protected]>
18 */
19 final class Options
20 {
21 /**
22 * The default maximum number of breadcrumbs that will be sent with an
23 * event.
24 */
25 public const DEFAULT_MAX_BREADCRUMBS = 100;
26 /**
27 * The default maximum execution time in seconds for the request+response
28 * as a whole.
29 */
30 public const DEFAULT_HTTP_TIMEOUT = 5;
31 /**
32 * The default maximum number of seconds to wait while trying to connect to a
33 * server.
34 */
35 public const DEFAULT_HTTP_CONNECT_TIMEOUT = 2;
36 /**
37 * @var array<string, mixed> The configuration options
38 */
39 private $options;
40 /**
41 * @var OptionsResolver The options resolver
42 */
43 private $resolver;
44 /**
45 * Class constructor.
46 *
47 * @param array<string, mixed> $options The configuration options
48 */
49 public function __construct(array $options = [])
50 {
51 $this->resolver = new OptionsResolver();
52 $this->configureOptions($this->resolver);
53 // Migrate `strict_trace_propagation` over to `strict_trace_continuation` if not set.
54 // If both are set, then `strict_trace_continuation` will take precedence.
55 if (isset($options['strict_trace_propagation']) && !isset($options['strict_trace_continuation'])) {
56 $options['strict_trace_continuation'] = $options['strict_trace_propagation'];
57 }
58 $this->options = $this->resolver->resolve($options, $this->getLoggerOrNullLogger($options));
59 if ($this->options['enable_tracing'] === \true && $this->options['traces_sample_rate'] === null) {
60 $this->options = \array_merge($this->options, ['traces_sample_rate' => 1]);
61 }
62 }
63 /**
64 * Gets the prefixes which should be stripped from filenames to create
65 * relative paths.
66 *
67 * @return string[]
68 */
69 public function getPrefixes() : array
70 {
71 return $this->options['prefixes'];
72 }
73 /**
74 * Sets the prefixes which should be stripped from filenames to create
75 * relative paths.
76 *
77 * @param string[] $prefixes The prefixes
78 */
79 public function setPrefixes(array $prefixes) : self
80 {
81 return $this->updateOptions(['prefixes' => $prefixes]);
82 }
83 /**
84 * Gets the sampling factor to apply to events. A value of 0 will deny
85 * sending any events, and a value of 1 will send 100% of events.
86 */
87 public function getSampleRate() : float
88 {
89 return $this->options['sample_rate'];
90 }
91 /**
92 * Sets the sampling factor to apply to events. A value of 0 will deny
93 * sending any events, and a value of 1 will send 100% of events.
94 *
95 * @param float $sampleRate The sampling factor
96 */
97 public function setSampleRate(float $sampleRate) : self
98 {
99 return $this->updateOptions(['sample_rate' => $sampleRate]);
100 }
101 /**
102 * Gets the sampling factor to apply to transaction. A value of 0 will deny
103 * sending any transaction, and a value of 1 will send 100% of transaction.
104 */
105 public function getTracesSampleRate() : ?float
106 {
107 return $this->options['traces_sample_rate'];
108 }
109 /**
110 * Sets if tracing should be enabled or not. If null tracesSampleRate takes
111 * precedence.
112 *
113 * @param bool|null $enableTracing Boolean if tracing should be enabled or not
114 *
115 * @deprecated since version 4.7. To be removed in version 5.0
116 */
117 public function setEnableTracing(?bool $enableTracing) : self
118 {
119 return $this->updateOptions(['enable_tracing' => $enableTracing]);
120 }
121 /**
122 * Gets if tracing is enabled or not.
123 *
124 * @return bool|null If the option `enable_tracing` is set or not
125 *
126 * @deprecated since version 4.7. To be removed in version 5.0
127 */
128 public function getEnableTracing() : ?bool
129 {
130 return $this->options['enable_tracing'];
131 }
132 /**
133 * Sets if logs should be enabled or not.
134 *
135 * This option no longer gates the manual logging API or logging integrations.
136 * To implement a kill switch, use a `before_send_log` callback that returns `null`.
137 *
138 * @param bool|null $enableLogs Boolean if logs should be enabled or not
139 *
140 * @deprecated since version 4.31. To be removed in version 5.0
141 */
142 public function setEnableLogs(?bool $enableLogs) : self
143 {
144 return $this->updateOptions(['enable_logs' => $enableLogs]);
145 }
146 /**
147 * Gets if logs is enabled or not.
148 *
149 * This option no longer gates the manual logging API or logging integrations.
150 * To implement a kill switch, use a `before_send_log` callback that returns `null`.
151 *
152 * @deprecated since version 4.31. To be removed in version 5.0
153 */
154 public function getEnableLogs() : bool
155 {
156 return $this->options['enable_logs'] ?? \false;
157 }
158 /**
159 * Gets the number of buffered logs that trigger an immediate flush.
160 */
161 public function getLogFlushThreshold() : ?int
162 {
163 /**
164 * @var int|null $logFlushThreshold
165 */
166 $logFlushThreshold = $this->options['log_flush_threshold'];
167 return $logFlushThreshold;
168 }
169 /**
170 * Sets the number of buffered logs that trigger an immediate flush.
171 * null will never trigger an immediate flush.
172 */
173 public function setLogFlushThreshold(?int $logFlushThreshold) : self
174 {
175 return $this->updateOptions(['log_flush_threshold' => $logFlushThreshold]);
176 }
177 /**
178 * Gets the number of buffered metrics that trigger an immediate flush.
179 */
180 public function getMetricFlushThreshold() : ?int
181 {
182 /**
183 * @var int|null $metricFlushThreshold
184 */
185 $metricFlushThreshold = $this->options['metric_flush_threshold'];
186 return $metricFlushThreshold;
187 }
188 /**
189 * Sets the number of buffered metrics that trigger an immediate flush.
190 * null will never trigger an immediate flush.
191 */
192 public function setMetricFlushThreshold(?int $metricFlushThreshold) : self
193 {
194 return $this->updateOptions(['metric_flush_threshold' => $metricFlushThreshold]);
195 }
196 /**
197 * Sets if metrics should be enabled or not.
198 *
199 * This option no longer gates the manual metrics API or metrics integrations.
200 * To implement a kill switch, use a `before_send_metric` callback that returns `null`.
201 *
202 * @deprecated since version 4.31. To be removed in version 5.0
203 */
204 public function setEnableMetrics(bool $enableMetrics) : self
205 {
206 return $this->updateOptions(['enable_metrics' => $enableMetrics]);
207 }
208 /**
209 * Returns whether metrics are enabled or not.
210 *
211 * This option no longer gates the manual metrics API or metrics integrations.
212 * To implement a kill switch, use a `before_send_metric` callback that returns `null`.
213 *
214 * @deprecated since version 4.31. To be removed in version 5.0
215 */
216 public function getEnableMetrics() : bool
217 {
218 /**
219 * @var bool $enableMetrics
220 */
221 $enableMetrics = $this->options['enable_metrics'] ?? \true;
222 return $enableMetrics;
223 }
224 /**
225 * Sets the sampling factor to apply to transactions. A value of 0 will deny
226 * sending any transactions, and a value of 1 will send 100% of transactions.
227 *
228 * @param ?float $sampleRate The sampling factor
229 */
230 public function setTracesSampleRate(?float $sampleRate) : self
231 {
232 return $this->updateOptions(['traces_sample_rate' => $sampleRate]);
233 }
234 public function getProfilesSampleRate() : ?float
235 {
236 /** @var int|float|null $value */
237 $value = $this->options['profiles_sample_rate'] ?? null;
238 return $value ?? null;
239 }
240 public function setProfilesSampleRate(?float $sampleRate) : self
241 {
242 return $this->updateOptions(['profiles_sample_rate' => $sampleRate]);
243 }
244 /**
245 * Gets a callback that will be invoked when we sample a profile.
246 *
247 * @phpstan-return null|callable(Tracing\SamplingContext): float
248 */
249 public function getProfilesSampler() : ?callable
250 {
251 /** @var callable(Tracing\SamplingContext): float|null $value */
252 $value = $this->options['profiles_sampler'];
253 return $value;
254 }
255 /**
256 * Sets a callback that will be invoked when we take the profiling sampling decision.
257 * Return a number between 0 and 1 to define the sample rate for the provided SamplingContext.
258 *
259 * @param ?callable $sampler The sampler
260 *
261 * @phpstan-param null|callable(Tracing\SamplingContext): float $sampler
262 */
263 public function setProfilesSampler(?callable $sampler) : self
264 {
265 return $this->updateOptions(['profiles_sampler' => $sampler]);
266 }
267 /**
268 * Gets whether tracing is enabled or not. The feature is enabled when at
269 * least one of the `traces_sample_rate` and `traces_sampler` options is
270 * set and `enable_tracing` is set and not false.
271 */
272 public function isTracingEnabled() : bool
273 {
274 if ($this->getEnableTracing() !== null && $this->getEnableTracing() === \false) {
275 return \false;
276 }
277 return $this->getTracesSampleRate() !== null || $this->getTracesSampler() !== null;
278 }
279 /**
280 * Gets whether the stacktrace will be attached on captureMessage.
281 */
282 public function shouldAttachStacktrace() : bool
283 {
284 return $this->options['attach_stacktrace'];
285 }
286 /**
287 * Sets whether the stacktrace will be attached on captureMessage.
288 *
289 * @param bool $enable Flag indicating if the stacktrace will be attached to captureMessage calls
290 */
291 public function setAttachStacktrace(bool $enable) : self
292 {
293 return $this->updateOptions(['attach_stacktrace' => $enable]);
294 }
295 /**
296 * Gets whether a metric has their code location attached.
297 *
298 * @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
299 */
300 public function shouldAttachMetricCodeLocations() : bool
301 {
302 return $this->options['attach_metric_code_locations'];
303 }
304 /**
305 * Sets whether a metric will have their code location attached.
306 *
307 * @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
308 */
309 public function setAttachMetricCodeLocations(bool $enable) : self
310 {
311 return $this->updateOptions(['attach_metric_code_locations' => $enable]);
312 }
313 /**
314 * Gets the number of lines of code context to capture, or null if none.
315 */
316 public function getContextLines() : ?int
317 {
318 return $this->options['context_lines'];
319 }
320 /**
321 * Sets the number of lines of code context to capture, or null if none.
322 *
323 * @param int|null $contextLines The number of lines of code
324 */
325 public function setContextLines(?int $contextLines) : self
326 {
327 return $this->updateOptions(['context_lines' => $contextLines]);
328 }
329 /**
330 * Gets the environment.
331 */
332 public function getEnvironment() : ?string
333 {
334 return $this->options['environment'];
335 }
336 /**
337 * Sets the environment.
338 *
339 * @param string|null $environment The environment
340 */
341 public function setEnvironment(?string $environment) : self
342 {
343 return $this->updateOptions(['environment' => $environment]);
344 }
345 /**
346 * Gets the list of paths to exclude from in_app detection.
347 *
348 * @return string[]
349 */
350 public function getInAppExcludedPaths() : array
351 {
352 return $this->options['in_app_exclude'];
353 }
354 /**
355 * Sets the list of paths to exclude from in_app detection.
356 *
357 * @param string[] $paths The list of paths
358 */
359 public function setInAppExcludedPaths(array $paths) : self
360 {
361 return $this->updateOptions(['in_app_exclude' => $paths]);
362 }
363 /**
364 * Gets the list of paths which has to be identified as in_app.
365 *
366 * @return string[]
367 */
368 public function getInAppIncludedPaths() : array
369 {
370 return $this->options['in_app_include'];
371 }
372 /**
373 * Set the list of paths to include in in_app detection.
374 *
375 * @param string[] $paths The list of paths
376 */
377 public function setInAppIncludedPaths(array $paths) : self
378 {
379 return $this->updateOptions(['in_app_include' => $paths]);
380 }
381 /**
382 * Gets a PSR-3 compatible logger to log internal debug messages.
383 */
384 public function getLogger() : ?LoggerInterface
385 {
386 return $this->options['logger'] ?? null;
387 }
388 /**
389 * Helper to always get a logger instance even if it was not set.
390 *
391 * It checks for a logger using the following order:
392 * 1. the passed `$options`
393 * 2. already configured `logger` option
394 * 3. `NullLogger` as fallback
395 *
396 * @param array<string, mixed> $options
397 */
398 public function getLoggerOrNullLogger(array $options = []) : LoggerInterface
399 {
400 $logger = $options['logger'] ?? null;
401 if ($logger instanceof LoggerInterface) {
402 return $logger;
403 }
404 return $this->getLogger() ?? new NullLogger();
405 }
406 /**
407 * Sets a PSR-3 compatible logger to log internal debug messages.
408 */
409 public function setLogger(LoggerInterface $logger) : self
410 {
411 return $this->updateOptions(['logger' => $logger]);
412 }
413 public function isSpotlightEnabled() : bool
414 {
415 return \is_string($this->options['spotlight']) || $this->options['spotlight'];
416 }
417 /**
418 * @param bool|string $enable can be passed a boolean or the Spotlight URL (which will also enable Spotlight)
419 */
420 public function enableSpotlight($enable) : self
421 {
422 return $this->updateOptions(['spotlight' => $enable]);
423 }
424 public function getSpotlightUrl() : string
425 {
426 if (\is_string($this->options['spotlight'])) {
427 return $this->options['spotlight'];
428 }
429 return $this->options['spotlight_url'];
430 }
431 /**
432 * @return $this
433 *
434 * @deprecated since version 4.11. To be removed in 5.x. You may use `enableSpotlight` instead.
435 */
436 public function setSpotlightUrl(string $url) : self
437 {
438 return $this->updateOptions(['spotlight_url' => $url]);
439 }
440 /**
441 * Gets the release tag to be passed with every event sent to Sentry.
442 */
443 public function getRelease() : ?string
444 {
445 return $this->options['release'];
446 }
447 /**
448 * Sets the release tag to be passed with every event sent to Sentry.
449 *
450 * @param string|null $release The release
451 */
452 public function setRelease(?string $release) : self
453 {
454 return $this->updateOptions(['release' => $release]);
455 }
456 /**
457 * Gets the DSN of the Sentry server the authenticated user is bound to.
458 */
459 public function getDsn() : ?Dsn
460 {
461 return $this->options['dsn'];
462 }
463 /**
464 * Gets the Org ID.
465 */
466 public function getOrgId() : ?int
467 {
468 return $this->options['org_id'];
469 }
470 /**
471 * Sets the Org ID.
472 */
473 public function setOrgId(int $orgId) : self
474 {
475 return $this->updateOptions(['org_id' => $orgId]);
476 }
477 /**
478 * Gets the name of the server the SDK is running on (e.g. the hostname).
479 */
480 public function getServerName() : string
481 {
482 return $this->options['server_name'];
483 }
484 /**
485 * Sets the name of the server the SDK is running on (e.g. the hostname).
486 *
487 * @param string $serverName The server name
488 */
489 public function setServerName(string $serverName) : self
490 {
491 return $this->updateOptions(['server_name' => $serverName]);
492 }
493 /**
494 * Gets a list of exceptions to be ignored and not sent to Sentry.
495 *
496 * @return string[]
497 *
498 * @phpstan-return list<class-string<\Throwable>>
499 */
500 public function getIgnoreExceptions() : array
501 {
502 return $this->options['ignore_exceptions'];
503 }
504 /**
505 * Sets a list of exceptions to be ignored and not sent to Sentry.
506 *
507 * @param string[] $ignoreErrors The list of exceptions to be ignored
508 */
509 public function setIgnoreExceptions(array $ignoreErrors) : self
510 {
511 return $this->updateOptions(['ignore_exceptions' => $ignoreErrors]);
512 }
513 /**
514 * Gets a list of transaction names to be ignored and not sent to Sentry.
515 *
516 * @return string[]
517 */
518 public function getIgnoreTransactions() : array
519 {
520 return $this->options['ignore_transactions'];
521 }
522 /**
523 * Sets a list of transaction names to be ignored and not sent to Sentry.
524 *
525 * @param string[] $ignoreTransaction The list of transaction names to be ignored
526 */
527 public function setIgnoreTransactions(array $ignoreTransaction) : self
528 {
529 return $this->updateOptions(['ignore_transactions' => $ignoreTransaction]);
530 }
531 /**
532 * Gets a callback that will be invoked before an event is sent to the server.
533 * If `null` is returned it won't be sent.
534 *
535 * @phpstan-return callable(Event, ?EventHint): ?Event
536 */
537 public function getBeforeSendCallback() : callable
538 {
539 return $this->options['before_send'];
540 }
541 /**
542 * Sets a callable to be called to decide whether an event should
543 * be captured or not.
544 *
545 * @param callable $callback The callable
546 *
547 * @phpstan-param callable(Event, ?EventHint): ?Event $callback
548 */
549 public function setBeforeSendCallback(callable $callback) : self
550 {
551 return $this->updateOptions(['before_send' => $callback]);
552 }
553 /**
554 * Gets a callback that will be invoked before an transaction is sent to the server.
555 * If `null` is returned it won't be sent.
556 *
557 * @phpstan-return callable(Event, ?EventHint): ?Event
558 */
559 public function getBeforeSendTransactionCallback() : callable
560 {
561 return $this->options['before_send_transaction'];
562 }
563 /**
564 * Sets a callable to be called to decide whether an transaction should
565 * be captured or not.
566 *
567 * @param callable $callback The callable
568 *
569 * @phpstan-param callable(Event, ?EventHint): ?Event $callback
570 */
571 public function setBeforeSendTransactionCallback(callable $callback) : self
572 {
573 return $this->updateOptions(['before_send_transaction' => $callback]);
574 }
575 /**
576 * Gets a callback that will be invoked before a check-in is sent to the server.
577 * If `null` is returned it won't be sent.
578 *
579 * @phpstan-return callable(Event, ?EventHint): ?Event
580 */
581 public function getBeforeSendCheckInCallback() : callable
582 {
583 return $this->options['before_send_check_in'];
584 }
585 /**
586 * Sets a callable to be called to decide whether a check-in should
587 * be captured or not.
588 *
589 * @param callable $callback The callable
590 *
591 * @phpstan-param callable(Event, ?EventHint): ?Event $callback
592 */
593 public function setBeforeSendCheckInCallback(callable $callback) : self
594 {
595 return $this->updateOptions(['before_send_check_in' => $callback]);
596 }
597 /**
598 * Gets a callback that will be invoked before an log is sent to the server.
599 * If `null` is returned it won't be sent.
600 *
601 * @phpstan-return callable(Log): ?Log
602 */
603 public function getBeforeSendLogCallback() : callable
604 {
605 return $this->options['before_send_log'];
606 }
607 /**
608 * Sets a callable to be called to decide whether a log should
609 * be captured or not.
610 *
611 * @param callable $callback The callable
612 *
613 * @phpstan-param callable(Log): ?Log $callback
614 */
615 public function setBeforeSendLogCallback(callable $callback) : self
616 {
617 return $this->updateOptions(['before_send_log' => $callback]);
618 }
619 /**
620 * Gets a callback that will be invoked before metrics are sent to the server.
621 * If `null` is returned it won't be sent.
622 *
623 * @phpstan-return callable(Event, ?EventHint): ?Event
624 *
625 * @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
626 */
627 public function getBeforeSendMetricsCallback() : callable
628 {
629 return $this->options['before_send_metrics'];
630 }
631 /**
632 * Gets a callback that will be invoked before a metric is added.
633 * Returning `null` means that the metric will be discarded.
634 */
635 public function getBeforeSendMetricCallback() : callable
636 {
637 /**
638 * @var callable $callback
639 */
640 $callback = $this->options['before_send_metric'];
641 return $callback;
642 }
643 /**
644 * Sets a new callback that is invoked before metrics are sent.
645 * Returning `null` means that the metric will be discarded.
646 *
647 * @return $this
648 */
649 public function setBeforeSendMetricCallback(callable $callback) : self
650 {
651 return $this->updateOptions(['before_send_metric' => $callback]);
652 }
653 /**
654 * Sets a callable to be called to decide whether metrics should
655 * be send or not.
656 *
657 * @param callable $callback The callable
658 *
659 * @phpstan-param callable(Event, ?EventHint): ?Event $callback
660 *
661 * @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
662 */
663 public function setBeforeSendMetricsCallback(callable $callback) : self
664 {
665 return $this->updateOptions(['before_send_metrics' => $callback]);
666 }
667 /**
668 * Gets an allow list of trace propagation targets.
669 *
670 * @return string[]|null
671 */
672 public function getTracePropagationTargets() : ?array
673 {
674 return $this->options['trace_propagation_targets'];
675 }
676 /**
677 * Set an allow list of trace propagation targets.
678 *
679 * @param string[] $tracePropagationTargets Trace propagation targets
680 */
681 public function setTracePropagationTargets(array $tracePropagationTargets) : self
682 {
683 return $this->updateOptions(['trace_propagation_targets' => $tracePropagationTargets]);
684 }
685 /**
686 * Returns whether strict trace continuation is enabled or not.
687 */
688 public function isStrictTraceContinuationEnabled() : bool
689 {
690 /**
691 * @var bool $result
692 */
693 $result = $this->options['strict_trace_continuation'];
694 return $result;
695 }
696 /**
697 * Sets if strict trace continuation should be enabled or not.
698 */
699 public function enableStrictTraceContinuation(bool $strictTraceContinuation) : self
700 {
701 return $this->updateOptions(['strict_trace_continuation' => $strictTraceContinuation]);
702 }
703 /**
704 * Returns whether strict trace propagation is enabled or not.
705 *
706 * @deprecated since version 4.21. To be removed in version 5.0. Use `isStrictTraceContinuationEnabled` instead.
707 */
708 public function isStrictTracePropagationEnabled() : bool
709 {
710 return $this->isStrictTraceContinuationEnabled();
711 }
712 /**
713 * Sets if strict trace propagation should be enabled or not.
714 *
715 * @deprecated since version 4.21. To be removed in version 5.0. Use `enableStrictTraceContinuation` instead.
716 */
717 public function enableStrictTracePropagation(bool $strictTracePropagation) : self
718 {
719 return $this->enableStrictTraceContinuation($strictTracePropagation);
720 }
721 /**
722 * Gets a list of default tags for events.
723 *
724 * @return array<string, string>
725 */
726 public function getTags() : array
727 {
728 return $this->options['tags'];
729 }
730 /**
731 * Sets a list of default tags for events.
732 *
733 * @param array<string, string> $tags A list of tags
734 */
735 public function setTags(array $tags) : self
736 {
737 return $this->updateOptions(['tags' => $tags]);
738 }
739 /**
740 * Gets a bit mask for error_reporting used in {@link ErrorListenerIntegration} to filter which errors to report.
741 */
742 public function getErrorTypes() : int
743 {
744 return $this->options['error_types'] ?? \error_reporting();
745 }
746 /**
747 * Sets a bit mask for error_reporting used in {@link ErrorListenerIntegration} to filter which errors to report.
748 *
749 * @param int $errorTypes The bit mask
750 */
751 public function setErrorTypes(int $errorTypes) : self
752 {
753 return $this->updateOptions(['error_types' => $errorTypes]);
754 }
755 /**
756 * Gets the maximum number of breadcrumbs sent with events.
757 */
758 public function getMaxBreadcrumbs() : int
759 {
760 return $this->options['max_breadcrumbs'];
761 }
762 /**
763 * Sets the maximum number of breadcrumbs sent with events.
764 *
765 * @param int $maxBreadcrumbs The maximum number of breadcrumbs
766 */
767 public function setMaxBreadcrumbs(int $maxBreadcrumbs) : self
768 {
769 return $this->updateOptions(['max_breadcrumbs' => $maxBreadcrumbs]);
770 }
771 /**
772 * Gets a callback that will be invoked when adding a breadcrumb.
773 *
774 * @phpstan-return callable(Breadcrumb): ?Breadcrumb
775 */
776 public function getBeforeBreadcrumbCallback() : callable
777 {
778 return $this->options['before_breadcrumb'];
779 }
780 /**
781 * Sets a callback that will be invoked when adding a breadcrumb, allowing
782 * to optionally modify it before adding it to future events. Note that you
783 * must return a valid breadcrumb from this callback. If you do not wish to
784 * modify the breadcrumb, simply return it at the end. Returning `null` will
785 * cause the breadcrumb to be dropped.
786 *
787 * @param callable $callback The callback
788 *
789 * @phpstan-param callable(Breadcrumb): ?Breadcrumb $callback
790 */
791 public function setBeforeBreadcrumbCallback(callable $callback) : self
792 {
793 return $this->updateOptions(['before_breadcrumb' => $callback]);
794 }
795 /**
796 * Sets the list of integrations that should be installed after SDK was
797 * initialized or a function that receives default integrations and returns
798 * a new, updated list.
799 *
800 * @param IntegrationInterface[]|callable(IntegrationInterface[]): IntegrationInterface[] $integrations The list or callable
801 */
802 public function setIntegrations($integrations) : self
803 {
804 return $this->updateOptions(['integrations' => $integrations]);
805 }
806 /**
807 * Returns all configured integrations that will be used by the Client.
808 *
809 * @return IntegrationInterface[]|callable(IntegrationInterface[]): IntegrationInterface[]
810 */
811 public function getIntegrations()
812 {
813 return $this->options['integrations'];
814 }
815 public function setTransport(TransportInterface $transport) : self
816 {
817 return $this->updateOptions(['transport' => $transport]);
818 }
819 public function getTransport() : ?TransportInterface
820 {
821 return $this->options['transport'];
822 }
823 public function setHttpClient(HttpClientInterface $httpClient) : self
824 {
825 return $this->updateOptions(['http_client' => $httpClient]);
826 }
827 public function getHttpClient() : ?HttpClientInterface
828 {
829 return $this->options['http_client'];
830 }
831 /**
832 * Should default PII be sent by default.
833 */
834 public function shouldSendDefaultPii() : bool
835 {
836 return $this->options['send_default_pii'];
837 }
838 /**
839 * Sets if default PII should be sent with every event (if possible).
840 *
841 * @param bool $enable Flag indicating if default PII will be sent
842 */
843 public function setSendDefaultPii(bool $enable) : self
844 {
845 return $this->updateOptions(['send_default_pii' => $enable]);
846 }
847 /**
848 * Returns whether the default integrations are enabled.
849 */
850 public function hasDefaultIntegrations() : bool
851 {
852 return $this->options['default_integrations'];
853 }
854 /**
855 * Sets whether the default integrations are enabled.
856 *
857 * @param bool $enable Flag indicating whether the default integrations should be enabled
858 */
859 public function setDefaultIntegrations(bool $enable) : self
860 {
861 return $this->updateOptions(['default_integrations' => $enable]);
862 }
863 /**
864 * Gets the max length for values in the event payload.
865 */
866 public function getMaxValueLength() : int
867 {
868 return $this->options['max_value_length'];
869 }
870 /**
871 * Sets the max length for specific values in the event payload.
872 *
873 * @param int $maxValueLength The number of characters after which the values containing text will be truncated
874 */
875 public function setMaxValueLength(int $maxValueLength) : self
876 {
877 return $this->updateOptions(['max_value_length' => $maxValueLength]);
878 }
879 /**
880 * Gets the http proxy setting.
881 */
882 public function getHttpProxy() : ?string
883 {
884 return $this->options['http_proxy'];
885 }
886 /**
887 * Sets the http proxy. Be aware this option only works when curl client is used.
888 *
889 * @param string|null $httpProxy The http proxy
890 */
891 public function setHttpProxy(?string $httpProxy) : self
892 {
893 return $this->updateOptions(['http_proxy' => $httpProxy]);
894 }
895 public function getHttpProxyAuthentication() : ?string
896 {
897 return $this->options['http_proxy_authentication'];
898 }
899 public function setHttpProxyAuthentication(?string $httpProxy) : self
900 {
901 return $this->updateOptions(['http_proxy_authentication' => $httpProxy]);
902 }
903 /**
904 * Gets the maximum number of seconds to wait while trying to connect to a server.
905 */
906 public function getHttpConnectTimeout() : float
907 {
908 return $this->options['http_connect_timeout'];
909 }
910 /**
911 * Sets the maximum number of seconds to wait while trying to connect to a server.
912 *
913 * @param float $httpConnectTimeout The amount of time in seconds
914 */
915 public function setHttpConnectTimeout(float $httpConnectTimeout) : self
916 {
917 return $this->updateOptions(['http_connect_timeout' => $httpConnectTimeout]);
918 }
919 /**
920 * Gets the maximum execution time for the request+response as a whole.
921 */
922 public function getHttpTimeout() : float
923 {
924 return $this->options['http_timeout'];
925 }
926 /**
927 * Sets the maximum execution time for the request+response as a whole. The
928 * value should also include the time for the connect phase, so it should be
929 * greater than the value set for the `http_connect_timeout` option.
930 *
931 * @param float $httpTimeout The amount of time in seconds
932 */
933 public function setHttpTimeout(float $httpTimeout) : self
934 {
935 return $this->updateOptions(['http_timeout' => $httpTimeout]);
936 }
937 public function getHttpSslVerifyPeer() : bool
938 {
939 return $this->options['http_ssl_verify_peer'];
940 }
941 public function setHttpSslVerifyPeer(bool $httpSslVerifyPeer) : self
942 {
943 return $this->updateOptions(['http_ssl_verify_peer' => $httpSslVerifyPeer]);
944 }
945 public function getHttpSslNativeCa() : bool
946 {
947 return $this->options['http_ssl_native_ca'];
948 }
949 public function setHttpSslNativeCa(bool $httpSslNativeCa) : self
950 {
951 return $this->updateOptions(['http_ssl_native_ca' => $httpSslNativeCa]);
952 }
953 /**
954 * Returns whether the requests should be compressed using GZIP or not.
955 */
956 public function isHttpCompressionEnabled() : bool
957 {
958 return $this->options['http_compression'];
959 }
960 /**
961 * Sets whether the request should be compressed using JSON or not.
962 */
963 public function setEnableHttpCompression(bool $enabled) : self
964 {
965 return $this->updateOptions(['http_compression' => $enabled]);
966 }
967 /**
968 * Returns whether a shared curl handle should be used or not.
969 *
970 * For PHP 8.5 and above, this will use the persistent curl handle. For previous PHP versions, it will use the
971 * regular share handle.
972 */
973 public function isShareHandleEnabled() : bool
974 {
975 /**
976 * @var bool $shareHandleEnabled
977 */
978 $shareHandleEnabled = $this->options['http_enable_curl_share_handle'];
979 return $shareHandleEnabled;
980 }
981 /**
982 * Sets whether the persistent curl handle should be used or not.
983 *
984 * For PHP 8.5 and above, this will use the persistent curl handle. For previous PHP versions, it will use the
985 * regular share handle.
986 */
987 public function setEnableShareHandle(bool $enabled) : self
988 {
989 return $this->updateOptions(['http_enable_curl_share_handle' => $enabled]);
990 }
991 /**
992 * Gets whether the silenced errors should be captured or not.
993 *
994 * @return bool If true, errors silenced through the @ operator will be reported,
995 * ignored otherwise
996 */
997 public function shouldCaptureSilencedErrors() : bool
998 {
999 return $this->options['capture_silenced_errors'];
1000 }
1001 /**
1002 * Sets whether the silenced errors should be captured or not.
1003 *
1004 * @param bool $shouldCapture If set to true, errors silenced through the @
1005 * operator will be reported, ignored otherwise
1006 */
1007 public function setCaptureSilencedErrors(bool $shouldCapture) : self
1008 {
1009 return $this->updateOptions(['capture_silenced_errors' => $shouldCapture]);
1010 }
1011 /**
1012 * Gets the limit up to which integrations should capture the HTTP request
1013 * body.
1014 */
1015 public function getMaxRequestBodySize() : string
1016 {
1017 return $this->options['max_request_body_size'];
1018 }
1019 /**
1020 * Sets the limit up to which integrations should capture the HTTP request
1021 * body.
1022 *
1023 * @param string $maxRequestBodySize The limit up to which request body are
1024 * captured. It can be set to one of the
1025 * following values:
1026 *
1027 * - never: request bodies are never sent
1028 * - small: only small request bodies will
1029 * be captured where the cutoff for small
1030 * depends on the SDK (typically 4KB)
1031 * - medium: medium-sized requests and small
1032 * requests will be captured. (typically 10KB)
1033 * - always: the SDK will always capture the
1034 * request body for as long as sentry can
1035 * make sense of it
1036 */
1037 public function setMaxRequestBodySize(string $maxRequestBodySize) : self
1038 {
1039 return $this->updateOptions(['max_request_body_size' => $maxRequestBodySize]);
1040 }
1041 /**
1042 * Gets the callbacks used to customize how objects are serialized in the payload
1043 * of the event.
1044 *
1045 * @return array<string, callable>
1046 */
1047 public function getClassSerializers() : array
1048 {
1049 return $this->options['class_serializers'];
1050 }
1051 /**
1052 * Sets a list of callables that will be called to customize how objects are
1053 * serialized in the event's payload. The list must be a map of FQCN/callable
1054 * pairs.
1055 *
1056 * @param array<string, callable> $serializers The list of serializer callbacks
1057 */
1058 public function setClassSerializers(array $serializers) : self
1059 {
1060 return $this->updateOptions(['class_serializers' => $serializers]);
1061 }
1062 /**
1063 * Gets a callback that will be invoked when we sample a Transaction.
1064 *
1065 * @phpstan-return null|callable(Tracing\SamplingContext): float
1066 */
1067 public function getTracesSampler() : ?callable
1068 {
1069 return $this->options['traces_sampler'];
1070 }
1071 /**
1072 * Sets a callback that will be invoked when we take the sampling decision for Transactions.
1073 * Return a number between 0 and 1 to define the sample rate for the provided SamplingContext.
1074 *
1075 * @param ?callable $sampler The sampler
1076 *
1077 * @phpstan-param null|callable(Tracing\SamplingContext): float $sampler
1078 */
1079 public function setTracesSampler(?callable $sampler) : self
1080 {
1081 return $this->updateOptions(['traces_sampler' => $sampler]);
1082 }
1083 /**
1084 * Configures the options of the client.
1085 *
1086 * @param OptionsResolver $resolver The resolver for the options
1087 */
1088 private function configureOptions(OptionsResolver $resolver) : void
1089 {
1090 $resolver->setAllowedTypes('prefixes', 'string[]');
1091 $resolver->setAllowedTypes('sample_rate', ['int', 'float']);
1092 $resolver->setAllowedTypes('enable_tracing', ['null', 'bool']);
1093 $resolver->setAllowedTypes('enable_logs', 'bool');
1094 $resolver->setAllowedTypes('log_flush_threshold', ['null', 'int']);
1095 $resolver->setAllowedTypes('enable_metrics', 'bool');
1096 $resolver->setAllowedTypes('metric_flush_threshold', ['null', 'int']);
1097 $resolver->setAllowedTypes('traces_sample_rate', ['null', 'int', 'float']);
1098 $resolver->setAllowedTypes('traces_sampler', ['null', 'callable']);
1099 $resolver->setAllowedTypes('profiles_sample_rate', ['null', 'int', 'float']);
1100 $resolver->setAllowedTypes('profiles_sampler', ['null', 'callable']);
1101 $resolver->setAllowedTypes('attach_stacktrace', 'bool');
1102 $resolver->setAllowedTypes('attach_metric_code_locations', 'bool');
1103 $resolver->setAllowedTypes('context_lines', ['null', 'int']);
1104 $resolver->setAllowedTypes('environment', ['null', 'string']);
1105 $resolver->setAllowedTypes('in_app_exclude', 'string[]');
1106 $resolver->setAllowedTypes('in_app_include', 'string[]');
1107 $resolver->setAllowedTypes('logger', ['null', LoggerInterface::class]);
1108 $resolver->setAllowedTypes('spotlight', ['bool', 'string', 'null']);
1109 $resolver->setAllowedTypes('spotlight_url', 'string');
1110 $resolver->setAllowedTypes('release', ['null', 'string']);
1111 $resolver->setAllowedTypes('dsn', ['null', 'string', 'bool', Dsn::class]);
1112 $resolver->setAllowedTypes('org_id', ['null', 'int']);
1113 $resolver->setAllowedTypes('server_name', 'string');
1114 $resolver->setAllowedTypes('before_send', ['callable']);
1115 $resolver->setAllowedTypes('before_send_transaction', ['callable']);
1116 $resolver->setAllowedTypes('before_send_log', 'callable');
1117 $resolver->setAllowedTypes('before_send_metric', ['callable']);
1118 $resolver->setAllowedTypes('ignore_exceptions', 'string[]');
1119 $resolver->setAllowedTypes('ignore_transactions', 'string[]');
1120 $resolver->setAllowedTypes('trace_propagation_targets', ['null', 'string[]']);
1121 $resolver->setAllowedTypes('strict_trace_continuation', 'bool');
1122 $resolver->setAllowedTypes('strict_trace_propagation', 'bool');
1123 $resolver->setAllowedTypes('tags', 'string[]');
1124 $resolver->setAllowedTypes('error_types', ['null', 'int']);
1125 $resolver->setAllowedTypes('max_breadcrumbs', 'int');
1126 $resolver->setAllowedTypes('before_breadcrumb', ['callable']);
1127 $resolver->setAllowedTypes('integrations', ['WCPOS\\Vendor\\Sentry\\Integration\\IntegrationInterface[]', 'callable']);
1128 $resolver->setAllowedTypes('send_default_pii', 'bool');
1129 $resolver->setAllowedTypes('default_integrations', 'bool');
1130 $resolver->setAllowedTypes('max_value_length', 'int');
1131 $resolver->setAllowedTypes('transport', ['null', TransportInterface::class]);
1132 $resolver->setAllowedTypes('http_client', ['null', HttpClientInterface::class]);
1133 $resolver->setAllowedTypes('http_proxy', ['null', 'string']);
1134 $resolver->setAllowedTypes('http_proxy_authentication', ['null', 'string']);
1135 $resolver->setAllowedTypes('http_connect_timeout', ['int', 'float']);
1136 $resolver->setAllowedTypes('http_timeout', ['int', 'float']);
1137 $resolver->setAllowedTypes('http_ssl_verify_peer', 'bool');
1138 $resolver->setAllowedTypes('http_ssl_native_ca', 'bool');
1139 $resolver->setAllowedTypes('http_compression', 'bool');
1140 $resolver->setAllowedTypes('http_enable_curl_share_handle', 'bool');
1141 $resolver->setAllowedTypes('capture_silenced_errors', 'bool');
1142 $resolver->setAllowedTypes('max_request_body_size', 'string');
1143 $resolver->setAllowedTypes('class_serializers', 'array');
1144 $resolver->setAllowedValues('max_request_body_size', ['none', 'never', 'small', 'medium', 'always']);
1145 $resolver->setAllowedValues('dsn', \Closure::fromCallable([$this, 'validateDsnOption']));
1146 $resolver->setAllowedValues('max_breadcrumbs', \Closure::fromCallable([$this, 'validateMaxBreadcrumbsOptions']));
1147 $resolver->setAllowedValues('class_serializers', \Closure::fromCallable([$this, 'validateClassSerializersOption']));
1148 $resolver->setAllowedValues('context_lines', \Closure::fromCallable([$this, 'validateContextLinesOption']));
1149 $resolver->setAllowedValues('log_flush_threshold', \Closure::fromCallable([$this, 'validateLogFlushThresholdOption']));
1150 $resolver->setAllowedValues('metric_flush_threshold', \Closure::fromCallable([$this, 'validateMetricFlushThresholdOption']));
1151 $resolver->setNormalizer('dsn', \Closure::fromCallable([$this, 'normalizeDsnOption']));
1152 $resolver->setNormalizer('prefixes', function (array $value) {
1153 return \array_map([$this, 'normalizeAbsolutePath'], $value);
1154 });
1155 $resolver->setNormalizer('spotlight_url', \Closure::fromCallable([$this, 'normalizeSpotlightUrl']));
1156 $resolver->setNormalizer('spotlight', \Closure::fromCallable([$this, 'normalizeBooleanOrUrl']));
1157 $resolver->setNormalizer('in_app_exclude', function (array $value) {
1158 return \array_map([$this, 'normalizeAbsolutePath'], $value);
1159 });
1160 $resolver->setNormalizer('in_app_include', function (array $value) {
1161 return \array_map([$this, 'normalizeAbsolutePath'], $value);
1162 });
1163 $resolver->setDefaults([
1164 'integrations' => [],
1165 'default_integrations' => \true,
1166 'prefixes' => \array_filter(\explode(\PATH_SEPARATOR, \get_include_path() ?: '')),
1167 'sample_rate' => 1,
1168 'enable_tracing' => null,
1169 'enable_logs' => \false,
1170 'log_flush_threshold' => null,
1171 'enable_metrics' => \true,
1172 'metric_flush_threshold' => null,
1173 'traces_sample_rate' => null,
1174 'traces_sampler' => null,
1175 'profiles_sample_rate' => null,
1176 'profiles_sampler' => null,
1177 'attach_stacktrace' => \false,
1178 /**
1179 * @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
1180 */
1181 'attach_metric_code_locations' => \false,
1182 'context_lines' => 5,
1183 'environment' => $_SERVER['SENTRY_ENVIRONMENT'] ?? null,
1184 'logger' => null,
1185 'spotlight' => $_SERVER['SENTRY_SPOTLIGHT'] ?? null,
1186 /**
1187 * @deprecated since version 4.11. To be removed in 5.0. You may use `spotlight` instead.
1188 */
1189 'spotlight_url' => 'http://localhost:8969',
1190 'release' => $_SERVER['SENTRY_RELEASE'] ?? $_SERVER['AWS_LAMBDA_FUNCTION_VERSION'] ?? null,
1191 'dsn' => $_SERVER['SENTRY_DSN'] ?? null,
1192 'org_id' => null,
1193 'server_name' => \gethostname(),
1194 'ignore_exceptions' => [],
1195 'ignore_transactions' => [],
1196 'before_send' => static function (Event $event) : Event {
1197 return $event;
1198 },
1199 'before_send_transaction' => static function (Event $transaction) : Event {
1200 return $transaction;
1201 },
1202 'before_send_check_in' => static function (Event $checkIn) : Event {
1203 return $checkIn;
1204 },
1205 'before_send_log' => static function (Log $log) : Log {
1206 return $log;
1207 },
1208 /**
1209 * @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
1210 * Use `before_send_metric` instead.
1211 */
1212 'before_send_metrics' => static function (Event $metrics) : ?Event {
1213 return null;
1214 },
1215 'before_send_metric' => static function (Metric $metric) : Metric {
1216 return $metric;
1217 },
1218 'trace_propagation_targets' => null,
1219 'strict_trace_continuation' => \false,
1220 'strict_trace_propagation' => \false,
1221 'tags' => [],
1222 'error_types' => null,
1223 'max_breadcrumbs' => self::DEFAULT_MAX_BREADCRUMBS,
1224 'before_breadcrumb' => static function (Breadcrumb $breadcrumb) : Breadcrumb {
1225 return $breadcrumb;
1226 },
1227 'in_app_exclude' => [],
1228 'in_app_include' => [],
1229 'send_default_pii' => \false,
1230 'max_value_length' => 1024,
1231 'transport' => null,
1232 'http_client' => null,
1233 'http_proxy' => null,
1234 'http_proxy_authentication' => null,
1235 'http_connect_timeout' => self::DEFAULT_HTTP_CONNECT_TIMEOUT,
1236 'http_timeout' => self::DEFAULT_HTTP_TIMEOUT,
1237 'http_ssl_verify_peer' => \true,
1238 'http_ssl_native_ca' => \false,
1239 'http_compression' => \true,
1240 'http_enable_curl_share_handle' => \true,
1241 'capture_silenced_errors' => \false,
1242 'max_request_body_size' => 'medium',
1243 'class_serializers' => [],
1244 ]);
1245 }
1246 /**
1247 * Normalizes the given path as an absolute path.
1248 *
1249 * @param string $value The path
1250 */
1251 private function normalizeAbsolutePath(string $value) : string
1252 {
1253 $path = @\realpath($value);
1254 if ($path === \false) {
1255 $path = $value;
1256 }
1257 return $path;
1258 }
1259 /**
1260 * @param bool|string|null $booleanOrUrl
1261 *
1262 * @return bool|string
1263 */
1264 private function normalizeBooleanOrUrl($booleanOrUrl)
1265 {
1266 if (empty($booleanOrUrl)) {
1267 return \false;
1268 }
1269 if (\filter_var($booleanOrUrl, \FILTER_VALIDATE_URL)) {
1270 return $this->normalizeSpotlightUrl((string) $booleanOrUrl);
1271 }
1272 return \filter_var($booleanOrUrl, \FILTER_VALIDATE_BOOLEAN);
1273 }
1274 /**
1275 * Normalizes the spotlight URL by removing the `/stream` at the end if present.
1276 */
1277 private function normalizeSpotlightUrl(string $url) : string
1278 {
1279 if (\substr_compare($url, '/stream', -7, 7) === 0) {
1280 return \substr($url, 0, -7);
1281 }
1282 return $url;
1283 }
1284 /**
1285 * Normalizes the DSN option by parsing the host, public and secret keys and
1286 * an optional path.
1287 *
1288 * @param string|bool|Dsn|null $value The actual value of the option to normalize
1289 */
1290 private function normalizeDsnOption($value) : ?Dsn
1291 {
1292 if ($value === null || \is_bool($value)) {
1293 return null;
1294 }
1295 if ($value instanceof Dsn) {
1296 return $value;
1297 }
1298 switch (\strtolower($value)) {
1299 case '':
1300 case 'false':
1301 case '(false)':
1302 case 'empty':
1303 case '(empty)':
1304 case 'null':
1305 case '(null)':
1306 return null;
1307 }
1308 return Dsn::createFromString($value);
1309 }
1310 /**
1311 * Validates the DSN option ensuring that all required pieces are set and
1312 * that the URL is valid.
1313 *
1314 * @param string|bool|Dsn|null $dsn The value of the option
1315 */
1316 private function validateDsnOption($dsn) : bool
1317 {
1318 if ($dsn === null || $dsn instanceof Dsn) {
1319 return \true;
1320 }
1321 if (\is_bool($dsn)) {
1322 return $dsn === \false;
1323 }
1324 switch (\strtolower($dsn)) {
1325 case '':
1326 case 'false':
1327 case '(false)':
1328 case 'empty':
1329 case '(empty)':
1330 case 'null':
1331 case '(null)':
1332 return \true;
1333 }
1334 try {
1335 Dsn::createFromString($dsn);
1336 return \true;
1337 } catch (\InvalidArgumentException $exception) {
1338 return \false;
1339 }
1340 }
1341 /**
1342 * Validates if the value of the max_breadcrumbs option is valid.
1343 *
1344 * @param int $value The value to validate
1345 */
1346 private function validateMaxBreadcrumbsOptions(int $value) : bool
1347 {
1348 return $value >= 0;
1349 }
1350 /**
1351 * Validates that the values passed to the `class_serializers` option are valid.
1352 *
1353 * @param mixed[] $serializers The value to validate
1354 */
1355 private function validateClassSerializersOption(array $serializers) : bool
1356 {
1357 foreach (\array_keys($serializers) as $class) {
1358 if (!\is_string($class) || !\is_callable($serializers[$class])) {
1359 return \false;
1360 }
1361 }
1362 return \true;
1363 }
1364 /**
1365 * Validates that the value passed to the "context_lines" option is valid.
1366 *
1367 * @param int|null $contextLines The value to validate
1368 */
1369 private function validateContextLinesOption(?int $contextLines) : bool
1370 {
1371 return $contextLines === null || $contextLines >= 0;
1372 }
1373 /**
1374 * Validates that the value passed to the "log_flush_threshold" option is valid.
1375 *
1376 * @param int|null $logFlushThreshold The value to validate
1377 */
1378 private function validateLogFlushThresholdOption(?int $logFlushThreshold) : bool
1379 {
1380 return $logFlushThreshold === null || $logFlushThreshold > 0;
1381 }
1382 /**
1383 * Validates that the value passed to the "metric_flush_threshold" option is valid.
1384 *
1385 * @param int|null $metricFlushThreshold The value to validate
1386 */
1387 private function validateMetricFlushThresholdOption(?int $metricFlushThreshold) : bool
1388 {
1389 return $metricFlushThreshold === null || $metricFlushThreshold > 0;
1390 }
1391 /**
1392 * Merges the passed options with the current options and resolves them.
1393 * The result is stored back onto the class field.
1394 *
1395 * @param array<string, mixed> $override
1396 *
1397 * @return $this
1398 *
1399 * @internal
1400 */
1401 public function updateOptions(array $override = []) : self
1402 {
1403 $resolved = $this->resolver->resolveOnly($override, $this->options, $this->getLoggerOrNullLogger($override));
1404 $this->options = \array_merge($this->options, $resolved);
1405 return $this;
1406 }
1407 }
1408