Skip to content

Commit 574fbb7

Browse files
committed
Update documentation
1 parent 8c7cc76 commit 574fbb7

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

docs/9.0/reader/record-mapping.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title: Denormalize a Tabular Data record into an object
88
<p class="message-notice">New in version <code>9.12.0</code></p>
99

1010
If you are working with a class which implements the `TabularDataReader` interface you can now deserialize
11-
your data using the `TabularDataReader::getObjects` method. The method will convert your document records
11+
your data using the `TabularDataReader::getRecordsAsObject` method. The method will convert your document records
1212
into objects using PHP's powerful Reflection API.
1313

1414
Here's an example using the `Reader` class which implements the `TabularDataReader` interface:
@@ -18,7 +18,7 @@ use League\Csv\Reader;
1818

1919
$csv = Reader::createFromString($document);
2020
$csv->setHeaderOffset(0);
21-
foreach ($csv->getObjects(ClimaticRecord::class) as $weather) {
21+
foreach ($csv->getRecordsAsObject(ClimaticRecord::class) as $weather) {
2222
// each $weather entry will be an instance of the ClimaticRecord class;
2323
}
2424
```
@@ -89,14 +89,14 @@ enum Place
8989
}
9090
```
9191

92-
To get instances of your object, you now can call `TabularDataReader::getObjects` which returns
92+
To get instances of your object, you now can call `TabularDataReader::getRecordsAsObject` which returns
9393
an `Iterator` containing only instances of your specified class.
9494

9595
```php
9696
use League\Csv\Reader;
9797

9898
$csv = Reader::createFromString($document);
99-
foreach ($csv->getObjects(ClimaticRecord::class) as $instance) {
99+
foreach ($csv->getRecordsAsObject(ClimaticRecord::class) as $instance) {
100100
// each $instance entry will be an instance of the ClimaticRecord class;
101101
}
102102
```
@@ -166,7 +166,7 @@ The attribute can take up to four (4) arguments which are all optional:
166166
<p class="message-info">The <code>ignore</code> argument was added in version <code>9.13.0</code></p>
167167
<p class="message-info">You can use the mechanism on a CSV without a header row but it requires
168168
adding a <code>MapCell</code> attribute on each property or method needed for the conversion. Or you
169-
can use the optional second argument of <code>TabularDataReader::getObjects</code> to specify the
169+
can use the optional second argument of <code>TabularDataReader::getRecordsAsObject</code> to specify the
170170
header value, just like with <code>TabularDataReader::getRecords</code></p>
171171

172172
In any case, if type casting fails, an exception will be thrown.
@@ -228,15 +228,15 @@ use League\Csv\Serializer\Denormalizer;
228228

229229
$csv = Reader::createFromString($document);
230230
$csv->setHeaderOffset(0);
231-
foreach ($csv->getObjects(ClimaticRecord::class) {
231+
foreach ($csv->getRecordsAsObject(ClimaticRecord::class) {
232232
// the first record contains an empty string for temperature
233233
// it is converted into the null value and handle by the
234234
// default conversion type casting;
235235
}
236236

237237
Denormalizer::disallowEmptyStringAsNull();
238238

239-
foreach ($csv->getObjects(ClimaticRecord::class) {
239+
foreach ($csv->getRecordsAsObject(ClimaticRecord::class) {
240240
// a TypeCastingFailed exception is thrown because we
241241
// can not convert the empty string into a valid
242242
// temperature property value

docs/9.0/reader/tabular-data-reader.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,25 @@ returned iterator. Added column will only contain the `null` value.
117117

118118
<p class="message-warning">If the header record contains non-unique string values, a <code>Exception</code> exception is triggered.</p>
119119

120-
### getObjects
120+
### getRecordsAsObject
121121

122-
<p class="message-notice">Added in version <code>9.12.0</code> for <code>Reader</code> and <code>ResultSet</code>.</p>
122+
`getObjects` is deprecated in favor of `getRecordsAsObject` to make the public API more consistent.
123+
124+
<p class="message-notice"><code>getObjects</code> Added in version <code>9.12.0</code> for <code>Reader</code> and <code>ResultSet</code>.</p>
125+
<p class="message-notice"><code>getRecordsAsObject</code> Added in version <code>9.15.0</code> for <code>Reader</code> and <code>ResultSet</code>.</p>
123126

124127
If you prefer working with objects instead of arrays it is possible to deserialize your CSV document using
125-
the `getObjects` method. This method will convert each CSV record into your specified class instances.
128+
the `getRecordsAsObject` method. This method will convert each CSV record into your specified class instances.
126129

127130
```php
128131
$csv = Reader::createFromString($document);
129132
$csv->setHeaderOffset(0);
130-
foreach ($csv->getObjects(ClimaticRecord::class) as $instance) {
133+
foreach ($csv->getRecordsAsObject(ClimaticRecord::class) as $instance) {
131134
// each $instance entry will be an instance of the Weather class;
132135
}
133136
```
134137

135-
The `getObjects` method can take an optional `$header` argument which is the same mapper argument as the one use
138+
The `getRecordsAsObject` method can take an optional `$header` argument which is the same mapper argument as the one use
136139
with the `getRecords` method.
137140

138141
<p class="message-info">You can get more info on how to configure your class to enable this feature by

0 commit comments

Comments
 (0)