Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
BackupService
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 getBackups
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getBackup
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Vultr\VultrPhp\Services\Backups;
6
7use Vultr\VultrPhp\Services\VultrService;
8use Vultr\VultrPhp\Util\ListOptions;
9
10/**
11 * Backup service handler, for backup endpoints.
12 *
13 * @see https://www.vultr.com/api/#tag/backup
14 */
15class BackupService extends VultrService
16{
17    /**
18     * Get information about backups on the account, or filtered based on the instance_id.
19     * @param $instance_id - string|null - Get the current backups for the instance.
20     * @param $options - ListOptions|null - Interact via reference.
21     * @throws BackupException
22     * @return Backup[]
23     */
24    public function getBackups(?string $instance_id = null, ?ListOptions &$options = null) : array
25    {
26        $params = [];
27        if ($instance_id !== null)
28        {
29            $params['instance_id'] = $instance_id;
30        }
31
32        return $this->getListObjects('backups', new Backup(), $options, $params);
33    }
34
35    /**
36     * Get a backup information based on the backup_id.
37     * @param $backup_id - string - UUID of the backup image.
38     * @throws BackupException
39     * @throws VultrException
40     * @return Backup
41     */
42    public function getBackup(string $backup_id) : Backup
43    {
44        return $this->getObject('backups/'.$backup_id, new Backup());
45    }
46}