mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Libraries\WatchRecord;
|
|
|
|
abstract class WatchRecord implements WatchRecordInterface
|
|
{
|
|
/**
|
|
* Array of the occurred events.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $events;
|
|
|
|
/**
|
|
* Full path of the file/directory on which the event occurred.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $path;
|
|
|
|
/**
|
|
* The input of the watch record.
|
|
* For example, an inotifywatch record should have an input similar to
|
|
* "DELETE /var/www/media/song.mp3".
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $input;
|
|
|
|
/**
|
|
* @param $input string The output from a watcher command (which is an input for our script)
|
|
*/
|
|
public function __construct(string $input)
|
|
{
|
|
$this->input = $input;
|
|
}
|
|
|
|
public function isFile(): bool
|
|
{
|
|
return !$this->isDirectory();
|
|
}
|
|
|
|
/**
|
|
* Check if a given event name exists in the event array.
|
|
*/
|
|
protected function eventExists(string $event): bool
|
|
{
|
|
return in_array($event, $this->events, true);
|
|
}
|
|
|
|
public function getPath(): string
|
|
{
|
|
return $this->path;
|
|
}
|
|
|
|
public function __toString()
|
|
{
|
|
return $this->input;
|
|
}
|
|
}
|