Skip to content

Commit abe6b81

Browse files
committed
fix(command): Make "roles" optional
1 parent dc81c1a commit abe6b81

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Command/CreateUsersCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ private static function parseUsers(string $filename): array
143143
$rolesIndex = array_search('roles', $header, true);
144144
$groupIndex = array_search('group', $header, true);
145145

146-
if (!\is_int($emailIndex) || !\is_int($nameIndex) || !\is_int($rolesIndex)) {
147-
throw new \RuntimeException("Could not find email, name, or roles in the header of {$filename}.");
146+
if (!\is_int($emailIndex) || !\is_int($nameIndex)) {
147+
throw new \RuntimeException("Could not find email or name in the header of {$filename}.");
148148
}
149149

150150
$users = [];
151151
while (($row = fgetcsv($file)) !== false) {
152152
$email = $row[$emailIndex];
153153
$name = $row[$nameIndex];
154-
$roles = $row[$rolesIndex];
154+
$roles = false !== $rolesIndex ? $row[$rolesIndex] : null;
155155
$group = false !== $groupIndex ? $row[$groupIndex] : null;
156156

157157
if (null === $email || null === $name) {

0 commit comments

Comments
 (0)