PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11.3
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / logger / class-charitable-log-records.php

class-charitable-log-records.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.11.3, at includes/logger/class-charitable-log-records.php

135 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Log Records collection class.
4 *
5 * @package Charitable/Classes/Charitable_Log_Records
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.8.11
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Log_Records' ) ) :
18
19 /**
20 * Charitable_Log_Records
21 *
22 * @since 1.8.11
23 */
24 class Charitable_Log_Records implements Countable, Iterator {
25
26 /**
27 * Array of Charitable_Log_Record objects.
28 *
29 * @since 1.8.11
30 *
31 * @var Charitable_Log_Record[]
32 */
33 private $records = array();
34
35 /**
36 * Iterator position.
37 *
38 * @since 1.8.11
39 *
40 * @var int
41 */
42 private $position = 0;
43
44 /**
45 * Return the count of records.
46 *
47 * @since 1.8.11
48 *
49 * @return int
50 */
51 #[\ReturnTypeWillChange]
52 public function count() {
53 return count( $this->records );
54 }
55
56 /**
57 * Add a record to the collection.
58 *
59 * @since 1.8.11
60 *
61 * @param Charitable_Log_Record $record Record to add.
62 */
63 public function push( Charitable_Log_Record $record ) {
64 $this->records[] = $record;
65 }
66
67 /**
68 * Clear all records.
69 *
70 * @since 1.8.11
71 */
72 public function clear() {
73 $this->records = array();
74 $this->position = 0;
75 }
76
77 /**
78 * Return current record.
79 *
80 * @since 1.8.11
81 *
82 * @return Charitable_Log_Record
83 */
84 #[\ReturnTypeWillChange]
85 public function current() {
86 return $this->records[ $this->position ];
87 }
88
89 /**
90 * Return current key.
91 *
92 * @since 1.8.11
93 *
94 * @return int
95 */
96 #[\ReturnTypeWillChange]
97 public function key() {
98 return $this->position;
99 }
100
101 /**
102 * Advance to next position.
103 *
104 * @since 1.8.11
105 */
106 #[\ReturnTypeWillChange]
107 public function next() {
108 ++$this->position;
109 }
110
111 /**
112 * Rewind to beginning.
113 *
114 * @since 1.8.11
115 */
116 #[\ReturnTypeWillChange]
117 public function rewind() {
118 $this->position = 0;
119 }
120
121 /**
122 * Check if current position is valid.
123 *
124 * @since 1.8.11
125 *
126 * @return bool
127 */
128 #[\ReturnTypeWillChange]
129 public function valid() {
130 return isset( $this->records[ $this->position ] );
131 }
132 }
133
134 endif;
135