PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
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 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / vendor_prefixed / sentry / sentry / src / Stacktrace.php

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

88 lines 2.5 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 /**
7 * This class contains all the information about an error stacktrace.
8 *
9 * @author Stefano Arlandini <sarlandini@alice.it>
10 */
11 final class Stacktrace
12 {
13 /**
14 * @var Frame[] The frames that compose the stacktrace
15 */
16 private $frames = [];
17 /**
18 * Constructor.
19 *
20 * @param Frame[] $frames A non-empty list of stack frames. The list must be
21 * ordered from caller to callee. The last frame is the
22 * one creating the exception
23 */
24 public function __construct(array $frames)
25 {
26 if (empty($frames)) {
27 throw new \InvalidArgumentException('Expected a non empty list of frames.');
28 }
29 foreach ($frames as $frame) {
30 if (!$frame instanceof Frame) {
31 throw new \UnexpectedValueException(\sprintf('Expected an instance of the "%s" class. Got: "%s".', Frame::class, \get_debug_type($frame)));
32 }
33 }
34 $this->frames = $frames;
35 }
36 /**
37 * Gets the stacktrace frames.
38 *
39 * @return Frame[]
40 */
41 public function getFrames() : array
42 {
43 return $this->frames;
44 }
45 /**
46 * Gets the frame at the given index.
47 *
48 * @param int $index The index from which the frame should be get
49 *
50 * @throws \OutOfBoundsException
51 */
52 public function getFrame(int $index) : Frame
53 {
54 if ($index < 0 || $index >= \count($this->frames)) {
55 throw new \OutOfBoundsException();
56 }
57 return $this->frames[$index];
58 }
59 /**
60 * Adds a new frame to the stacktrace.
61 *
62 * @param Frame $frame The frame
63 */
64 public function addFrame(Frame $frame) : self
65 {
66 \array_unshift($this->frames, $frame);
67 return $this;
68 }
69 /**
70 * Removes the frame at the given index from the stacktrace.
71 *
72 * @param int $index The index of the frame
73 *
74 * @throws \OutOfBoundsException If the index is out of range
75 */
76 public function removeFrame(int $index) : self
77 {
78 if (!isset($this->frames[$index])) {
79 throw new \OutOfBoundsException(\sprintf('Cannot remove the frame at index %d.', $index));
80 }
81 if (\count($this->frames) === 1) {
82 throw new \RuntimeException('Cannot remove all frames from the stacktrace.');
83 }
84 \array_splice($this->frames, $index, 1);
85 return $this;
86 }
87 }
88