Skip to content

Commit 67f961a

Browse files
Made setHook method a little clearer to read
1 parent a447332 commit 67f961a

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/Runner/Installer.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,24 +138,28 @@ public function setMoveExistingTo(string $backup): Installer
138138
*/
139139
public function setHook(string $hook): Installer
140140
{
141-
if (!empty($hook)) {
142-
$hooks = explode(',', $hook);
143-
if ($hooks === false) {
144-
throw new Exception\InvalidHookName('Invalid hook name \'' . $hook . '\'');
145-
}
146-
$hooks = array_map('trim', $hooks);
147-
$hooksValidationCallback = static function (string $hook): bool {
148-
return !HookUtil::isInstallable($hook);
149-
};
150-
if (!empty(($invalidHooks = array_filter($hooks, $hooksValidationCallback)))) {
151-
throw new Exception\InvalidHookName(
152-
'Invalid hook name \'' . implode(',', $invalidHooks) . '\''
153-
);
154-
}
141+
if (empty($hook)) {
142+
return $this;
143+
}
144+
145+
$hooks = explode(',', $hook);
146+
if ($hooks === false) {
147+
throw new Exception\InvalidHookName('Invalid hook name \'' . $hook . '\'');
148+
}
149+
150+
$hooks = array_map('trim', $hooks);
155151

156-
$this->hooksToHandle = $hooks;
152+
$hooksValidationCallback = static function (string $hook): bool {
153+
return !HookUtil::isInstallable($hook);
154+
};
155+
if (!empty(($invalidHooks = array_filter($hooks, $hooksValidationCallback)))) {
156+
throw new Exception\InvalidHookName(
157+
'Invalid hook name \'' . implode(',', $invalidHooks) . '\''
158+
);
157159
}
158160

161+
$this->hooksToHandle = $hooks;
162+
159163
return $this;
160164
}
161165

0 commit comments

Comments
 (0)