refactor: comments
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -11,9 +11,6 @@ namespace KTXM\PeopleManager\Import;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Configuration for a contact import run.
|
||||
*/
|
||||
final class ImportOptions {
|
||||
|
||||
public const ERROR_CONTINUE = 0;
|
||||
@@ -63,14 +60,11 @@ final class ImportOptions {
|
||||
*/
|
||||
public static function fromArray(array $data): self {
|
||||
$options = new self();
|
||||
if (isset($data['supersede'])) {
|
||||
$options->setSupersede((bool)$data['supersede']);
|
||||
}
|
||||
if (isset($data['counts'])) {
|
||||
$options->setCounts((bool)$data['counts']);
|
||||
}
|
||||
if (isset($data['errors'])) {
|
||||
$options->setErrors((int)$data['errors']);
|
||||
$options->supersede = (bool)($data['supersede'] ?? false);
|
||||
$options->counts = (bool)($data['counts'] ?? true);
|
||||
$options->errors = (int)($data['errors'] ?? self::ERROR_CONTINUE);
|
||||
if (!in_array($options->errors, [self::ERROR_CONTINUE, self::ERROR_FAIL], true)) {
|
||||
throw new InvalidArgumentException('Invalid errors option specified');
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user