Laravel Hetzner Cloud

PHP MIT

Production-ready Laravel SDK for the Hetzner Cloud API with support for servers, volumes, networks, firewalls, load balancers, SSH keys, floating IPs, and more.

Stars
19
Forks
0
Downloads
2,275
Open Issues
0
Files main

Repository Files

Loading file structure...
src/Managers/LoadBalancerTypeManager.php
<?php

namespace Vendor\HetznerCloud\Managers;

use Vendor\HetznerCloud\Collections\LoadBalancerTypeCollection;
use Vendor\HetznerCloud\DTOs\LoadBalancerType;

class LoadBalancerTypeManager extends AbstractManager
{
    public function all()
    {
        $response = $this->getRequest('load_balancer_types', $this->buildQueryParams());

        return $this->hydrate($response, function (array $data) {
            $types = array_map(fn (array $item) => LoadBalancerType::fromArray($item), $data['load_balancer_types'] ?? []);

            return new LoadBalancerTypeCollection($types);
        });
    }

    public function get()
    {
        return $this->all();
    }

    public function find(int $id)
    {
        $response = $this->getRequest("load_balancer_types/{$id}");

        return $this->hydrate($response, function (array $data) {
            return LoadBalancerType::fromArray($data['load_balancer_type'] ?? []);
        });
    }
}