Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 623d14e

Browse files
committed
Small tweak.
1 parent c0dfa87 commit 623d14e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/Commands/Import.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,14 @@ public function import($users = [])
8989
$imported++;
9090

9191
// Log the successful import.
92-
if ($this->option('log') == 'true') {
92+
if ($this->isLogging()) {
9393
logger()->info("Imported user {$user->getCommonName()}");
9494
}
9595
}
9696
} catch (\Exception $e) {
97-
$message = "Unable to import user {$user->getCommonName()}. {$e->getMessage()}";
98-
9997
// Log the unsuccessful import.
100-
if ($this->option('log') == 'true') {
101-
logger()->error($message);
98+
if ($this->isLogging()) {
99+
logger()->error("Unable to import user {$user->getCommonName()}. {$e->getMessage()}");
102100
}
103101
}
104102
}
@@ -107,6 +105,16 @@ public function import($users = [])
107105
return $imported;
108106
}
109107

108+
/**
109+
* Returns true / false if the current import is being logged.
110+
*
111+
* @return bool
112+
*/
113+
public function isLogging()
114+
{
115+
return $this->option('log') == 'true';
116+
}
117+
110118
/**
111119
* {@inheritdoc}
112120
*/

0 commit comments

Comments
 (0)