PluginProbe
Import WP – CSV & XML Import Export for WordPress / trunk
Import WP – CSV & XML Import Export for WordPress vtrunk
2.15.1 2.15.0 2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 All 144 releases
jc-importer / class / Common / Exporter / ExporterRecord.php

ExporterRecord.php in Import WP – CSV & XML Import Export for WordPress trunk, at class/Common/Exporter/ExporterRecord.php

112 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImportWP\Common\Exporter;
4
5 class ExporterRecord implements \ArrayAccess, \Iterator, \Countable
6 {
7 private $_data = [];
8 private $_mapper_type;
9 private $keys = array();
10 private $position;
11
12 public function __construct($data, $mapper_type)
13 {
14 $this->_data = $data;
15 $this->_mapper_type = $mapper_type;
16
17 $this->keys = array_keys($this->_data);
18 }
19
20 #[\ReturnTypeWillChange]
21 public function current()
22 {
23 return $this->_data[$this->keys[$this->position]];
24 }
25
26 /** @return void */
27 #[\ReturnTypeWillChange]
28 public function next()
29 {
30 $this->position++;
31 }
32
33 #[\ReturnTypeWillChange]
34 public function key()
35 {
36 return $this->keys[$this->position];
37 }
38
39 /** @return bool */
40 #[\ReturnTypeWillChange]
41 public function valid()
42 {
43 return isset($this->keys[$this->position]);
44 }
45
46 /** @return void */
47 #[\ReturnTypeWillChange]
48 public function rewind()
49 {
50 $this->position = 0;
51 }
52
53 /** @return int<0, \max> */
54 #[\ReturnTypeWillChange]
55 public function count()
56 {
57 return count($this->keys);
58 }
59
60 /**
61 * @param mixed $offset
62 * @return bool
63 */
64 #[\ReturnTypeWillChange]
65 public function offsetExists($offset)
66 {
67 if (!isset($this->_data[$offset])) {
68 $value = apply_filters('iwp/exporter_record/' . $this->_mapper_type, null, $offset, $this->_data);
69 if (!is_null($value)) {
70 $this->_data[$offset] = $value;
71 $this->keys = array_keys($this->_data);
72 }
73 }
74
75 return isset($this->_data[$offset]);
76 }
77
78 #[\ReturnTypeWillChange]
79 public function offsetGet($offset)
80 {
81 return $this->offsetExists($offset) ? $this->_data[$offset] : null;
82 }
83
84 /**
85 * @param mixed $offset
86 * @param mixed $value
87 * @return void
88 */
89 #[\ReturnTypeWillChange]
90 public function offsetSet($offset, $value)
91 {
92 if (is_null($offset)) {
93 $this->_data[] = $value;
94 } else {
95 $this->_data[$offset] = $value;
96 }
97
98 $this->keys = array_keys($this->_data);
99 }
100
101 /**
102 * @param mixed $offset
103 * @return void
104 */
105 #[\ReturnTypeWillChange]
106 public function offsetUnset($offset)
107 {
108 unset($this->_data[$offset]);
109 $this->keys = array_keys($this->_data);
110 }
111 }
112