Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
VPCService
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 getVPC
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVPCs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createVPC
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 updateVPC
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 deleteVPC
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\VPC;
6
7use Vultr\VultrPhp\Services\VultrService;
8use Vultr\VultrPhp\Util\ListOptions;
9
10/**
11 * Virtual private cloud service handler, for all vpcs endpoints.
12 *
13 * @see https://www.vultr.com/api/#tag/VPCs
14 */
15class VPCService extends VultrService
16{
17    /**
18     * @see https://www.vultr.com/api/#tag/VPCs/operation/get-vpc
19     * @param $vpc_id - string - Example: cb676a46-66fd-4dfb-b839-443f2e6c0b60
20     * @throws VPCException
21     * @return VirtualPrivateCloud
22     */
23    public function getVPC(string $vpc_id) : VirtualPrivateCloud
24    {
25        return $this->getObject('vpcs/'.$vpc_id, new VirtualPrivateCloud());
26    }
27
28    /**
29     * @see https://www.vultr.com/api/#tag/VPCs/operation/list-vpcs
30     * @param $options - ListOptions|null - Interact via reference.
31     * @throws VPCException
32     * @return array
33     */
34    public function getVPCs(?ListOptions &$options = null) : array
35    {
36        return $this->getListObjects('vpcs', new VirtualPrivateCloud(), $options);
37    }
38
39    /**
40     * @see https://www.vultr.com/api/#tag/VPCs/operation/create-vpc
41     * @param $vpc - VirtualPrivateCloud
42     * @throws VPCException
43     * @return VirtualPrivateCloud
44     */
45    public function createVPC(VirtualPrivateCloud $vpc) : VirtualPrivateCloud
46    {
47        return $this->createObject('vpcs', new VirtualPrivateCloud(), $vpc->getInitializedProps());
48    }
49
50    /**
51     * @see https://www.vultr.com/api/#tag/VPCs/operation/update-vpc
52     * @param $vpc - VirtualPrivateCloud
53     * @throws VPCException
54     * @return void
55     */
56    public function updateVPC(VirtualPrivateCloud $vpc) : void
57    {
58        $this->patchObject('vpcs/'.$vpc->getId(), $vpc);
59    }
60
61    /**
62     * @see https://www.vultr.com/api/#tag/VPCs/operation/delete-vpc
63     * @param $vpc_id - string - Example: cb676a46-66fd-4dfb-b839-443f2e6c0b60
64     * @throws VPCException
65     * @return void
66     */
67    public function deleteVPC(string $vpc_id) : void
68    {
69        $this->deleteObject('vpcs/'.$vpc_id, new VirtualPrivateCloud());
70    }
71}
72