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/DTOs/Datacenter.php
<?php

namespace Vendor\HetznerCloud\DTOs;

class Datacenter
{
    public int $id;

    public string $name;

    public string $description;

    public array $location = [];

    public array $serverTypes = [];

    /**
     * Create a new DTO instance from array data.
     */
    public static function fromArray(array $data): self
    {
        $dc = new self;
        $dc->id = (int) ($data['id'] ?? 0);
        $dc->name = (string) ($data['name'] ?? '');
        $dc->description = (string) ($data['description'] ?? '');
        $dc->location = (array) ($data['location'] ?? []);
        $dc->serverTypes = (array) ($data['server_types'] ?? []);

        return $dc;
    }
}