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

Commit 857266d

Browse files
committed
Extracted attribute handler check into separate function
1 parent 8d6a47f commit 857266d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Commands/Import.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected function sync(Model $model)
119119
foreach ($toSync as $modelField => $ldapField) {
120120
// If the field is a loaded class and contains a `handle()` method,
121121
// we need to construct the attribute handler.
122-
if (is_string($ldapField) && class_exists($ldapField) && method_exists($ldapField, 'handle')) {
122+
if ($this->isHandler($ldapField)) {
123123
// We will construct the attribute handler using Laravel's
124124
// IoC to allow developers to utilize application
125125
// dependencies in the constructor.
@@ -135,4 +135,18 @@ protected function sync(Model $model)
135135
}
136136
}
137137
}
138+
139+
/**
140+
* Determines if the given handler value is a class that contains the 'handle' method.
141+
*
142+
* @param mixed $handler
143+
*
144+
* @return bool
145+
*/
146+
protected function isHandler($handler)
147+
{
148+
return is_string($handler) &&
149+
class_exists($handler) &&
150+
method_exists($handler, 'handle');
151+
}
138152
}

0 commit comments

Comments
 (0)