1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Application\Service; |
6
|
|
|
|
7
|
|
|
use Application\DBAL\Types\MembershipType; |
8
|
|
|
use Application\DBAL\Types\ProductTypeType; |
9
|
|
|
use Application\Model\Organization; |
10
|
|
|
use Application\Model\User; |
11
|
|
|
use Application\Repository\OrganizationRepository; |
12
|
|
|
use Doctrine\DBAL\Connection; |
13
|
|
|
use Ecodev\Felix\Api\Exception; |
14
|
|
|
use Ecodev\Felix\Api\ExceptionWithoutMailLogging; |
15
|
|
|
use Laminas\Validator\EmailAddress; |
16
|
|
|
use Throwable; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Service to import users from CSV with maximal performance. |
20
|
|
|
* |
21
|
|
|
* Users are never deleted, even though technically they should be, to limit the loss of |
22
|
|
|
* data in case of human error in the incoming files. Because it could mean losing all historic |
23
|
|
|
* of purchases. |
24
|
|
|
* |
25
|
|
|
* On the other hand, organizations are **always** deleted, because they don't have any related objects, |
26
|
|
|
* and they are not editable (not even visible) in any way in the app. |
27
|
|
|
*/ |
28
|
|
|
class Importer |
29
|
|
|
{ |
30
|
|
|
private int $lineNumber = 0; |
31
|
|
|
|
32
|
|
|
private int $lastReview = 0; |
33
|
|
|
|
34
|
|
|
private array $reviewByNumber = []; |
35
|
|
|
|
36
|
|
|
private array $countryByName = []; |
37
|
|
|
|
38
|
|
|
private Connection $connection; |
39
|
|
|
|
40
|
|
|
private int $updatedUsers = 0; |
41
|
|
|
|
42
|
|
|
private int $updatedOrganizations = 0; |
43
|
|
|
|
44
|
|
|
private int $deletedOrganizations = 0; |
45
|
|
|
|
46
|
|
|
private array $seenEmails = []; |
47
|
|
|
|
48
|
|
|
private array $seenPatterns = []; |
49
|
|
|
|
50
|
|
|
private ?int $currentUser; |
51
|
|
|
|
52
|
|
|
private array $errors = []; |
53
|
|
|
|
54
|
|
|
private array $usersParams = []; |
55
|
|
|
|
56
|
|
|
private array $organizationsParams = []; |
57
|
|
|
|
58
|
18 |
|
public function import(string $filename): array |
59
|
|
|
{ |
60
|
18 |
|
$start = microtime(true); |
61
|
18 |
|
$this->connection = _em()->getConnection(); |
62
|
18 |
|
$this->fetchReviews(); |
63
|
18 |
|
$this->fetchLastReview(); |
64
|
18 |
|
$this->fetchCountries(); |
65
|
18 |
|
$this->currentUser = User::getCurrent() ? User::getCurrent()->getId() : null; |
66
|
18 |
|
$this->updatedUsers = 0; |
67
|
18 |
|
$this->updatedOrganizations = 0; |
68
|
18 |
|
$this->deletedOrganizations = 0; |
69
|
18 |
|
$this->seenEmails = []; |
70
|
18 |
|
$this->seenPatterns = []; |
71
|
|
|
|
72
|
18 |
|
if (!file_exists($filename)) { |
73
|
1 |
|
throw new Exception('File not found: ' . $filename); |
74
|
|
|
} |
75
|
|
|
|
76
|
17 |
|
$file = fopen($filename, 'rb'); |
77
|
17 |
|
if ($file === false) { |
78
|
|
|
throw new Exception('Could not read file: ' . $filename); |
79
|
|
|
} |
80
|
|
|
|
81
|
17 |
|
$this->skipBOM($file); |
82
|
|
|
|
83
|
|
|
try { |
84
|
17 |
|
$this->connection->beginTransaction(); |
85
|
17 |
|
$this->read($file); |
86
|
|
|
|
87
|
17 |
|
$this->markToDelete(); |
88
|
17 |
|
$this->updateAllUsers(); |
89
|
17 |
|
$this->updateAllOrganizations(); |
90
|
17 |
|
$this->deleteOldOrganizations(); |
91
|
|
|
|
92
|
17 |
|
if ($this->errors) { |
93
|
12 |
|
throw new ExceptionWithoutMailLogging(implode(PHP_EOL, $this->errors)); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
// Give user automatic access via organization |
97
|
|
|
/** @var OrganizationRepository $organizationRepository */ |
98
|
5 |
|
$organizationRepository = _em()->getRepository(Organization::class); |
99
|
5 |
|
$organizationRepository->applyOrganizationAccesses(); |
100
|
|
|
|
101
|
5 |
|
$this->connection->commit(); |
102
|
12 |
|
} catch (Throwable $exception) { |
103
|
12 |
|
$this->connection->rollBack(); |
104
|
|
|
|
105
|
12 |
|
throw $exception; |
106
|
5 |
|
} finally { |
107
|
17 |
|
fclose($file); |
108
|
|
|
} |
109
|
|
|
|
110
|
5 |
|
$totalUsers = (int) $this->connection->fetchOne('SELECT COUNT(*) FROM user'); |
111
|
5 |
|
$totalOrganizations = (int) $this->connection->fetchOne('SELECT COUNT(*) FROM organization'); |
112
|
|
|
|
113
|
5 |
|
$time = round(microtime(true) - $start, 1); |
114
|
|
|
|
115
|
|
|
return [ |
116
|
5 |
|
'updatedUsers' => $this->updatedUsers, |
117
|
5 |
|
'updatedOrganizations' => $this->updatedOrganizations, |
118
|
5 |
|
'deletedOrganizations' => $this->deletedOrganizations, |
119
|
5 |
|
'totalUsers' => $totalUsers, |
120
|
5 |
|
'totalOrganizations' => $totalOrganizations, |
121
|
5 |
|
'totalLines' => $this->lineNumber, |
122
|
5 |
|
'time' => $time, |
123
|
|
|
]; |
124
|
|
|
} |
125
|
|
|
|
126
|
18 |
|
private function fetchReviews(): void |
127
|
|
|
{ |
128
|
18 |
|
$records = $this->connection->fetchAllAssociative('SELECT id, review_number FROM product WHERE review_number IS NOT NULL'); |
129
|
|
|
|
130
|
18 |
|
$this->reviewByNumber = []; |
131
|
18 |
|
foreach ($records as $r) { |
132
|
18 |
|
$this->reviewByNumber[$r['review_number']] = $r['id']; |
133
|
|
|
} |
134
|
18 |
|
} |
135
|
|
|
|
136
|
18 |
|
private function fetchLastReview(): void |
137
|
|
|
{ |
138
|
18 |
|
$records = $this->connection->fetchAllAssociative('SELECT id, review_number FROM product WHERE review_number IS NOT NULL AND is_active = 1 ORDER BY review_number DESC LIMIT 1'); |
139
|
18 |
|
$this->lastReview = (int) $records[0]['review_number']; |
140
|
18 |
|
} |
141
|
|
|
|
142
|
18 |
|
private function fetchCountries(): void |
143
|
|
|
{ |
144
|
18 |
|
$records = $this->connection->fetchAllAssociative('SELECT id, LOWER(name) AS name FROM country'); |
145
|
|
|
|
146
|
18 |
|
$this->countryByName = []; |
147
|
18 |
|
foreach ($records as $r) { |
148
|
18 |
|
$r['name'] = $this->toUpper($r['name']); |
149
|
18 |
|
$this->countryByName[$r['name']] = $r; |
150
|
|
|
} |
151
|
18 |
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param resource $file |
155
|
|
|
*/ |
156
|
17 |
|
private function skipBOM($file): void |
157
|
|
|
{ |
158
|
|
|
// Consume BOM, but if not BOM, rewind to beginning |
159
|
17 |
|
if (fgets($file, 4) !== "\xEF\xBB\xBF") { |
160
|
15 |
|
rewind($file); |
161
|
|
|
} |
162
|
17 |
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param resource $file |
166
|
|
|
*/ |
167
|
17 |
|
private function read($file): void |
168
|
|
|
{ |
169
|
17 |
|
$this->lineNumber = 0; |
170
|
17 |
|
$expectedColumnCount = 14; |
171
|
17 |
|
while ($line = fgetcsv($file, 0, "\t")) { |
172
|
17 |
|
++$this->lineNumber; |
173
|
|
|
|
174
|
17 |
|
$actualColumnCount = count($line); |
175
|
17 |
|
if ($actualColumnCount !== $expectedColumnCount) { |
176
|
1 |
|
$this->throw("Doit avoir exactement $expectedColumnCount colonnes, mais en a " . $actualColumnCount); |
177
|
|
|
|
178
|
1 |
|
continue; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
// un-escape all fields |
182
|
16 |
|
$line = array_map(fn ($r) => html_entity_decode($r), $line); |
183
|
|
|
|
184
|
|
|
[ |
185
|
16 |
|
$email, |
186
|
|
|
$pattern, |
187
|
|
|
$subscriptionType, |
188
|
|
|
$lastReviewNumber, |
189
|
|
|
$ignored, |
190
|
|
|
$firstName, |
191
|
|
|
$lastName, |
192
|
|
|
$street, |
193
|
|
|
$street2, |
194
|
|
|
$postcode, |
195
|
|
|
$locality, |
196
|
|
|
$country, |
197
|
|
|
$phone, |
198
|
|
|
$membership, |
199
|
|
|
] = $line; |
200
|
|
|
|
201
|
16 |
|
$email = trim($email); |
202
|
16 |
|
$pattern = trim($pattern); |
203
|
|
|
|
204
|
16 |
|
if (!$email && !$pattern) { |
205
|
1 |
|
$this->throw('Il faut soit un email, soit un pattern, mais aucun existe'); |
206
|
|
|
|
207
|
1 |
|
continue; |
208
|
|
|
} |
209
|
|
|
|
210
|
15 |
|
$lastReviewId = $this->readReviewId($lastReviewNumber); |
211
|
|
|
|
212
|
15 |
|
if ($email) { |
213
|
12 |
|
$this->assertEmail($email); |
214
|
12 |
|
$membership = $this->readMembership($membership); |
215
|
12 |
|
$country = $this->readCountryId($country); |
216
|
12 |
|
$subscriptionType = $this->readSubscriptionType($subscriptionType); |
217
|
|
|
|
218
|
12 |
|
$this->updateUser( |
219
|
12 |
|
$email, |
220
|
|
|
$subscriptionType, |
221
|
|
|
$lastReviewId, |
222
|
|
|
$membership, |
223
|
|
|
$firstName, |
224
|
|
|
$lastName, |
225
|
12 |
|
trim(implode(' ', [$street, $street2])), |
226
|
|
|
$postcode, |
227
|
|
|
$locality, |
228
|
|
|
$country, |
229
|
|
|
$phone |
230
|
|
|
); |
231
|
|
|
} |
232
|
|
|
|
233
|
15 |
|
if ($pattern) { |
234
|
5 |
|
$this->assertPattern($pattern); |
235
|
|
|
|
236
|
5 |
|
$this->updateOrganization( |
237
|
5 |
|
$pattern, |
238
|
|
|
$lastReviewId |
239
|
|
|
); |
240
|
|
|
} |
241
|
|
|
} |
242
|
17 |
|
} |
243
|
|
|
|
244
|
12 |
|
private function assertEmail(string $email): void |
245
|
|
|
{ |
246
|
12 |
|
$validator = new EmailAddress(); |
247
|
12 |
|
if (!$validator->isValid($email)) { |
248
|
1 |
|
$this->throw('Ce n\'est pas une addresse email valide : "' . $email . '"'); |
249
|
|
|
|
250
|
1 |
|
return; |
251
|
|
|
} |
252
|
|
|
|
253
|
11 |
|
if (array_key_exists($email, $this->seenEmails)) { |
254
|
1 |
|
$this->throw('L\'email "' . $email . '" est dupliqué et a déjà été vu à la ligne ' . $this->seenEmails[$email]); |
255
|
|
|
|
256
|
1 |
|
return; |
257
|
|
|
} |
258
|
|
|
|
259
|
11 |
|
$this->seenEmails[$email] = $this->lineNumber; |
260
|
11 |
|
} |
261
|
|
|
|
262
|
5 |
|
private function assertPattern(string $pattern): void |
263
|
|
|
{ |
264
|
5 |
|
if (@preg_match('~' . $pattern . '~', '') === false) { |
265
|
1 |
|
$this->throw('Ce n\'est pas une expression régulière valide : "' . $pattern . '"'); |
266
|
|
|
|
267
|
1 |
|
return; |
268
|
|
|
} |
269
|
|
|
|
270
|
4 |
|
if (preg_match('~^\|~', $pattern) || preg_match('~\|$~', $pattern)) { |
271
|
1 |
|
$this->throw('L\'expression régulière ne peut pas commencer ou terminer par `|`, car c\'est trop dangeureux: "' . $pattern . '"'); |
272
|
|
|
|
273
|
1 |
|
return; |
274
|
|
|
} |
275
|
|
|
|
276
|
3 |
|
if (array_key_exists($pattern, $this->seenPatterns)) { |
277
|
1 |
|
$this->throw('Le pattern "' . $pattern . '" est dupliqué et a déjà été vu à la ligne ' . $this->seenPatterns[$pattern]); |
278
|
|
|
|
279
|
1 |
|
return; |
280
|
|
|
} |
281
|
|
|
|
282
|
3 |
|
$count = $this->connection->executeQuery('SELECT COUNT(*) FROM user WHERE email REGEXP :pattern', ['pattern' => $pattern])->fetchOne(); |
|
|
|
|
283
|
3 |
|
$maximumUserPerPattern = 100; |
284
|
3 |
|
if ($count > $maximumUserPerPattern) { |
285
|
|
|
$this->throw(<<<STRING |
286
|
|
|
L'expression régulière "$pattern" affecte $count utilisateurs, ce qui est supérieur à la limite de $maximumUserPerPattern. Si c'est vraiment voulu, il faut contacter Ecodev. |
287
|
|
|
STRING |
288
|
|
|
); |
289
|
|
|
} |
290
|
|
|
|
291
|
3 |
|
$this->seenPatterns[$pattern] = $this->lineNumber; |
292
|
3 |
|
} |
293
|
|
|
|
294
|
15 |
|
private function readReviewId(string $reviewNumber): ?string |
295
|
|
|
{ |
296
|
15 |
|
if (!$reviewNumber) { |
297
|
11 |
|
return null; |
298
|
|
|
} |
299
|
|
|
|
300
|
6 |
|
if ($reviewNumber && !preg_match('~^\d+$~', $reviewNumber)) { |
301
|
1 |
|
$this->throw('Un numéro de revue doit être entièrement numérique, mais est : "' . $reviewNumber . '"'); |
302
|
|
|
|
303
|
1 |
|
return null; |
304
|
|
|
} |
305
|
|
|
|
306
|
5 |
|
$reviewNumberNumeric = (int) $reviewNumber; |
307
|
5 |
|
if (!array_key_exists($reviewNumberNumeric, $this->reviewByNumber)) { |
308
|
2 |
|
$this->throw('Revue introuvable pour le numéro de revue : ' . $reviewNumber); |
309
|
|
|
|
310
|
2 |
|
return null; |
311
|
|
|
} |
312
|
|
|
|
313
|
3 |
|
return $reviewNumberNumeric >= $this->lastReview ? $this->reviewByNumber[$reviewNumberNumeric] : null; |
314
|
|
|
} |
315
|
|
|
|
316
|
12 |
|
private function readCountryId(string $country): ?string |
317
|
|
|
{ |
318
|
12 |
|
if (!$country) { |
319
|
9 |
|
return null; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
// Case insensitive match |
323
|
5 |
|
$upper = $this->toUpper($country); |
324
|
5 |
|
if (array_key_exists($upper, $this->countryByName)) { |
325
|
3 |
|
return $this->countryByName[$upper]['id']; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
// Suggest our best guess, so user can fix their data without lookup up countries manually |
329
|
2 |
|
$best = 0; |
330
|
2 |
|
$bestGuess = 0; |
331
|
2 |
|
foreach ($this->countryByName as $r) { |
332
|
2 |
|
similar_text($upper, $r['name'], $percent); |
333
|
2 |
|
if ($percent > $best) { |
334
|
2 |
|
$best = $percent; |
335
|
2 |
|
$bestGuess = $r; |
336
|
|
|
} |
337
|
|
|
} |
338
|
|
|
|
339
|
2 |
|
$this->throw('Pays "' . $country . '" introuvable. Vouliez-vous dire "' . $bestGuess['name'] . '" ?'); |
340
|
|
|
|
341
|
2 |
|
return null; |
342
|
|
|
} |
343
|
|
|
|
344
|
12 |
|
private function throw(string $message): void |
345
|
|
|
{ |
346
|
12 |
|
$this->errors[] = ('A la ligne ' . $this->lineNumber . ' : ' . $message); |
347
|
12 |
|
} |
348
|
|
|
|
349
|
17 |
|
private function deleteOldOrganizations(): void |
350
|
|
|
{ |
351
|
17 |
|
$sql = 'DELETE FROM organization WHERE should_delete'; |
352
|
17 |
|
$this->deletedOrganizations += $this->connection->executeStatement($sql); |
353
|
17 |
|
} |
354
|
|
|
|
355
|
12 |
|
private function readMembership($membership): string |
356
|
|
|
{ |
357
|
12 |
|
if ($membership === '1') { |
358
|
1 |
|
return MembershipType::MEMBER; |
359
|
|
|
} |
360
|
|
|
|
361
|
12 |
|
return MembershipType::NONE; |
362
|
|
|
} |
363
|
|
|
|
364
|
12 |
|
private function readSubscriptionType(string $subscriptionType): ?string |
365
|
|
|
{ |
366
|
12 |
|
if (!$subscriptionType) { |
367
|
8 |
|
return null; |
368
|
|
|
} |
369
|
|
|
|
370
|
6 |
|
if ($subscriptionType === 'Web') { |
371
|
2 |
|
return ProductTypeType::DIGITAL; |
372
|
|
|
} |
373
|
|
|
|
374
|
5 |
|
if ($subscriptionType === 'Papier') { |
375
|
4 |
|
return ProductTypeType::PAPER; |
376
|
|
|
} |
377
|
|
|
|
378
|
2 |
|
if ($subscriptionType === 'Papier/web') { |
379
|
1 |
|
return ProductTypeType::BOTH; |
380
|
|
|
} |
381
|
|
|
|
382
|
1 |
|
$this->throw('Le subscriptionType est invalide : "' . $subscriptionType . '"'); |
383
|
|
|
|
384
|
1 |
|
return null; |
385
|
|
|
} |
386
|
|
|
|
387
|
12 |
|
private function updateUser(...$args): void |
388
|
|
|
{ |
389
|
12 |
|
$params = $args; |
390
|
12 |
|
$params[] = false; // web_temporary_access |
391
|
12 |
|
$params[] = false; // should_delete |
392
|
12 |
|
$params[] = ''; // password |
393
|
12 |
|
$params[] = $this->currentUser; |
394
|
|
|
|
395
|
12 |
|
array_push($this->usersParams, ...$params); |
396
|
12 |
|
++$this->updatedUsers; |
397
|
12 |
|
} |
398
|
|
|
|
399
|
17 |
|
private function updateAllUsers(): void |
400
|
|
|
{ |
401
|
17 |
|
if (!$this->updatedUsers) { |
402
|
5 |
|
return; |
403
|
|
|
} |
404
|
|
|
|
405
|
12 |
|
$placeholders = $this->placeholders($this->updatedUsers, '(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())'); |
406
|
|
|
|
407
|
|
|
$sql = 'INSERT INTO user ( |
408
|
|
|
email, |
409
|
|
|
subscription_type, |
410
|
|
|
subscription_last_review_id, |
411
|
|
|
membership, |
412
|
|
|
first_name, |
413
|
|
|
last_name, |
414
|
|
|
street, |
415
|
|
|
postcode, |
416
|
|
|
locality, |
417
|
|
|
country_id, |
418
|
|
|
phone, |
419
|
|
|
web_temporary_access, |
420
|
|
|
should_delete, |
421
|
|
|
password, |
422
|
|
|
creator_id, |
423
|
|
|
creation_date |
424
|
|
|
) |
425
|
12 |
|
VALUES ' . $placeholders . ' |
426
|
|
|
ON DUPLICATE KEY UPDATE |
427
|
|
|
email = VALUES(email), |
428
|
|
|
subscription_type = VALUES(subscription_type), |
429
|
|
|
subscription_last_review_id = VALUES(subscription_last_review_id), |
430
|
|
|
membership = VALUES(membership), |
431
|
|
|
first_name = VALUES(first_name), |
432
|
|
|
last_name = VALUES(last_name), |
433
|
|
|
street = VALUES(street), |
434
|
|
|
postcode = VALUES(postcode), |
435
|
|
|
locality = VALUES(locality), |
436
|
|
|
country_id = VALUES(country_id), |
437
|
|
|
phone = VALUES(phone), |
438
|
|
|
web_temporary_access = VALUES(web_temporary_access), |
439
|
|
|
should_delete = VALUES(should_delete), |
440
|
|
|
updater_id = VALUES(creator_id), |
441
|
|
|
update_date = NOW()'; |
442
|
|
|
|
443
|
12 |
|
$this->connection->executeStatement($sql, $this->usersParams); |
444
|
12 |
|
} |
445
|
|
|
|
446
|
5 |
|
private function updateOrganization(...$args): void |
447
|
|
|
{ |
448
|
5 |
|
$params = $args; |
449
|
5 |
|
$params[] = false; // should_delete |
450
|
5 |
|
$params[] = $this->currentUser; |
451
|
|
|
|
452
|
5 |
|
array_push($this->organizationsParams, ...$params); |
453
|
|
|
|
454
|
5 |
|
++$this->updatedOrganizations; |
455
|
5 |
|
} |
456
|
|
|
|
457
|
17 |
|
private function updateAllOrganizations(): void |
458
|
|
|
{ |
459
|
17 |
|
if (!$this->updatedOrganizations) { |
460
|
12 |
|
return; |
461
|
|
|
} |
462
|
|
|
|
463
|
5 |
|
$placeholders = $this->placeholders($this->updatedOrganizations, '(?, ?, ?, ?, NOW())'); |
464
|
|
|
|
465
|
|
|
$sql = 'INSERT INTO organization (pattern, subscription_last_review_id, should_delete, creator_id, creation_date) |
466
|
5 |
|
VALUES ' . $placeholders . ' |
467
|
|
|
ON DUPLICATE KEY UPDATE |
468
|
|
|
pattern = VALUES(pattern), |
469
|
|
|
subscription_last_review_id = VALUES(subscription_last_review_id), |
470
|
|
|
updater_id = VALUES(creator_id), |
471
|
|
|
should_delete = VALUES(should_delete), |
472
|
|
|
update_date = NOW()'; |
473
|
|
|
|
474
|
5 |
|
$this->connection->executeStatement($sql, $this->organizationsParams); |
475
|
5 |
|
} |
476
|
|
|
|
477
|
17 |
|
private function markToDelete(): void |
478
|
|
|
{ |
479
|
17 |
|
$this->connection->executeStatement('UPDATE user SET should_delete = 1'); |
480
|
17 |
|
$this->connection->executeStatement('UPDATE organization SET should_delete = 1'); |
481
|
17 |
|
} |
482
|
|
|
|
483
|
|
|
/** |
484
|
|
|
* To upper without any accent |
485
|
|
|
*/ |
486
|
18 |
|
private function toUpper(string $name): string |
487
|
|
|
{ |
488
|
18 |
|
$withoutAccent = iconv('UTF-8', 'ASCII//TRANSLIT', mb_strtolower($name)); |
489
|
|
|
|
490
|
18 |
|
return trim(mb_strtoupper($withoutAccent)); |
491
|
|
|
} |
492
|
|
|
|
493
|
15 |
|
private function placeholders(int $count, string $placeholder): string |
494
|
|
|
{ |
495
|
15 |
|
return implode(',' . PHP_EOL, array_fill(0, $count, $placeholder)); |
496
|
|
|
} |
497
|
|
|
} |
498
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.