%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/www/admin1/vendor/spatie/laravel-backup/src/Tasks/Backup/ |
Upload File : |
<?php
namespace Spatie\Backup\Tasks\Backup;
use Countable;
use Generator;
use SplFileObject;
class Manifest implements Countable
{
protected string $manifestPath;
public static function create(string $manifestPath): self
{
return new static($manifestPath);
}
public function __construct(string $manifestPath)
{
$this->manifestPath = $manifestPath;
touch($manifestPath);
}
public function path(): string
{
return $this->manifestPath;
}
public function addFiles(array | string | Generator $filePaths): self
{
if (is_string($filePaths)) {
$filePaths = [$filePaths];
}
foreach ($filePaths as $filePath) {
if (! empty($filePath)) {
file_put_contents($this->manifestPath, $filePath.PHP_EOL, FILE_APPEND);
}
}
return $this;
}
public function files(): Generator | array
{
$file = new SplFileObject($this->path());
while (! $file->eof()) {
$filePath = $file->fgets();
if (! empty($filePath)) {
yield trim($filePath);
}
}
}
public function count(): int
{
$file = new SplFileObject($this->manifestPath, 'r');
$file->seek(PHP_INT_MAX);
return $file->key();
}
}