Spatie\Backup\Tasks\Backup\Manifest::count PHP Method

count() public method

public count ( ) : integer
return integer
    public function count() : int
    {
        $file = new SplFileObject($this->manifestPath, 'r');
        $file->seek(PHP_INT_MAX);
        return $file->key();
    }

Usage Example

Example #1
0
 protected function createZipContainingEveryFileInManifest(Manifest $manifest)
 {
     consoleOutput()->info("Zipping {$manifest->count()} files...");
     $pathToZip = $this->temporaryDirectory->path(config('laravel-backup.backup.destination.filename_prefix') . Carbon::now()->format('Y-m-d-H-i-s') . '.zip');
     $zip = Zip::createForManifest($manifest, $pathToZip);
     consoleOutput()->info("Created zip containing {$zip->count()} files. Size is {$zip->humanReadableSize()}");
     event(new BackupZipWasCreated($pathToZip));
     return $pathToZip;
 }