Skip to content

Commit 678843c

Browse files
committed
Watcher::addPath() now accepts string|array
Watcher::addExtension() now accepts string|array
1 parent 6fdb95c commit 678843c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Watcher.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected function inotifyWatchPath(string $path): void
136136
protected function inotifyRemovePathWatch(EventInfo $eventInfo): void
137137
{
138138
$descriptor = $eventInfo->getWatchDescriptor();
139-
if ($eventInfo->getWatchedItem()->getFullPath() != $this->watchedItems[$descriptor]){
139+
if ($eventInfo->getWatchedItem()->getFullPath() != $this->watchedItems[$descriptor]) {
140140
return;
141141
}
142142

@@ -234,7 +234,7 @@ public function watch(): void
234234

235235
// INDIVIDUAL LISTENERS
236236
foreach ($inotifyEvents as $inotifyEvent) {
237-
// var_export($inotifyEvent);
237+
// var_export($inotifyEvent);
238238
// Make sure that we support this event
239239
if (in_array($inotifyEvent['mask'], $this->watchedMasks)) {
240240
$this->fireEvent($inotifyEvent);
@@ -257,23 +257,33 @@ public function watch(): void
257257
/**
258258
* Add file extension filter
259259
*
260-
* @param string $extension
260+
* @param string|array $extension
261261
* @return $this
262262
*/
263-
public function addExtension(string $extension): Watcher
263+
public function addExtension(string|array $extension): Watcher
264264
{
265+
if (is_array($extension)) {
266+
$this->extensions = array_merge($this->extensions, $extension);
267+
return $this;
268+
}
269+
265270
$this->extensions[] = $extension;
266271
return $this;
267272
}
268273

269274
/**
270275
* Add path to watch
271276
*
272-
* @param string $path
277+
* @param string|array $path
273278
* @return $this
274279
*/
275-
public function addPath(string $path): Watcher
280+
public function addPath(string|array $path): Watcher
276281
{
282+
if (is_array($path)) {
283+
$this->paths = array_merge($this->paths, $path);
284+
return $this;
285+
}
286+
277287
$this->paths[] = $path;
278288
return $this;
279289
}

0 commit comments

Comments
 (0)