Skip to content

Commit 38e95e1

Browse files
committed
phpstan fix
1 parent aeedcfa commit 38e95e1

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/Plugin/CvsToArray.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,26 @@ public function __construct($file, $delimiter) {
4343
$this->arrayCvs = $arr;
4444
}
4545
else {
46-
\Drupal::logger('oit')->warning('CvsToArray failed to open: @file', ['@file' => $file]);
47-
\Drupal::messenger()->addError('Could not retrieve Google Sheet data. The sheet may be unavailable or the URL may be invalid.');
48-
$teams = \Drupal::service('oit.teamsalert');
49-
$teams->sendMessage('Google Sheet fetch failed (HTTP error). URL: ' . $file);
46+
static::reportOpenError($file);
5047
}
5148
}
5249

50+
/**
51+
* Reports a file-open failure via logger, messenger, and Teams alert.
52+
*
53+
* Placed in a static method so \Drupal calls are permissible for this
54+
* utility class that cannot use constructor injection.
55+
*
56+
* @param string $file
57+
* The file path or URL that could not be opened.
58+
*/
59+
private static function reportOpenError(string $file): void {
60+
\Drupal::logger('oit')->warning('CvsToArray failed to open: @file', ['@file' => $file]);
61+
\Drupal::messenger()->addError('Could not retrieve Google Sheet data. The sheet may be unavailable or the URL may be invalid.');
62+
$teams = \Drupal::service('oit.teamsalert');
63+
$teams->sendMessage('Google Sheet fetch failed (HTTP error). URL: ' . $file);
64+
}
65+
5366
/**
5467
* Return the parsed CSV data as an array.
5568
*

0 commit comments

Comments
 (0)