PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.8.3
Import WP – CSV & XML Import Export for WordPress v2.8.3
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 2.8.3, at class/Common/Exporter/ExporterRecord.php

102 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 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 public function current()
21 {
22 return $this->_data[$this->keys[$this->position]];
23 }
24
25 /** @return void */
26 public function next()
27 {
28 $this->position++;
29 }
30
31 public function key()
32 {
33 return $this->keys[$this->position];
34 }
35
36 /** @return bool */
37 public function valid()
38 {
39 return isset($this->keys[$this->position]);
40 }
41
42 /** @return void */
43 public function rewind()
44 {
45 $this->position = 0;
46 }
47
48 /** @return int<0, \max> */
49 public function count()
50 {
51 return count($this->keys);
52 }
53
54 /**
55 * @param mixed $offset
56 * @return bool
57 */
58 public function offsetExists($offset)
59 {
60 if (!isset($this->_data[$offset])) {
61 $value = apply_filters('iwp/exporter_record/' . $this->_mapper_type, null, $offset, $this->_data);
62 if (!is_null($value)) {
63 $this->_data[$offset] = $value;
64 $this->keys = array_keys($this->_data);
65 }
66 }
67
68 return isset($this->_data[$offset]);
69 }
70
71 public function offsetGet($offset)
72 {
73 return $this->offsetExists($offset) ? $this->_data[$offset] : null;
74 }
75
76 /**
77 * @param mixed $offset
78 * @param mixed $value
79 * @return void
80 */
81 public function offsetSet($offset, $value)
82 {
83 if (is_null($offset)) {
84 $this->_data[] = $value;
85 } else {
86 $this->_data[$offset] = $value;
87 }
88
89 $this->keys = array_keys($this->_data);
90 }
91
92 /**
93 * @param mixed $offset
94 * @return void
95 */
96 public function offsetUnset($offset)
97 {
98 unset($this->_data[$offset]);
99 $this->keys = array_keys($this->_data);
100 }
101 }
102