PluginProbe
Packeta / 2.3.2
Packeta v2.3.2
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / Log / LogSizeLimiterState.php

LogSizeLimiterState.php in Packeta 2.3.2, at src/Packetery/Module/Log/LogSizeLimiterState.php

96 lines 2.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
5 namespace Packetery\Module\Log;
6
7 class LogSizeLimiterState {
8
9 /** @var array<int, string> */
10 private $recordQueue;
11
12 /** @var int */
13 private $totalSize;
14
15 /** @var array<int, string> */
16 private $currentRecordLines;
17
18 /** @var int|null */
19 private $currentRecordTime;
20
21 /**
22 * @param array<int, string> $recordQueue
23 * @param int $totalSize
24 * @param array<int, string> $currentRecordLines
25 * @param int|null $currentRecordTime
26 */
27 public function __construct(
28 array $recordQueue,
29 int $totalSize,
30 array $currentRecordLines,
31 ?int $currentRecordTime
32 ) {
33 $this->recordQueue = $recordQueue;
34 $this->totalSize = $totalSize;
35 $this->currentRecordLines = $currentRecordLines;
36 $this->currentRecordTime = $currentRecordTime;
37 }
38
39 /**
40 * @return array<int, string>
41 */
42 public function getRecordQueue(): array {
43 return $this->recordQueue;
44 }
45
46 public function shiftRecordQueue(): ?string {
47 return array_shift( $this->recordQueue );
48 }
49
50 public function addRecordToQueue( string $recordContent ): void {
51 $this->recordQueue[] = $recordContent;
52 }
53
54 public function getTotalSize(): int {
55 return $this->totalSize;
56 }
57
58 public function addToTotalSize( int $size ): void {
59 $this->totalSize += $size;
60 }
61
62 public function subtractFromTotalSize( int $size ): void {
63 $this->totalSize -= $size;
64 }
65
66 /**
67 * @return array<int, string>
68 */
69 public function getCurrentRecordLines(): array {
70 return $this->currentRecordLines;
71 }
72
73 /**
74 * @param array<int, string> $currentRecordLines
75 */
76 public function setCurrentRecordLines( array $currentRecordLines ): void {
77 $this->currentRecordLines = $currentRecordLines;
78 }
79
80 public function addCurrentRecordLine( string $line ): void {
81 $this->currentRecordLines[] = $line;
82 }
83
84 public function emptyCurrentRecordLines(): void {
85 $this->currentRecordLines = [];
86 }
87
88 public function getCurrentRecordTime(): ?int {
89 return $this->currentRecordTime;
90 }
91
92 public function setCurrentRecordTime( ?int $currentRecordTime ): void {
93 $this->currentRecordTime = $currentRecordTime;
94 }
95 }
96