@@ -138,24 +138,28 @@ public function setMoveExistingTo(string $backup): Installer
138
138
*/
139
139
public function setHook (string $ hook ): Installer
140
140
{
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 );
155
151
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
+ );
157
159
}
158
160
161
+ $ this ->hooksToHandle = $ hooks ;
162
+
159
163
return $ this ;
160
164
}
161
165
0 commit comments