Laravel Hetzner Storagebox

PHP MIT

Production-ready Laravel package for integrating Hetzner Storage Box into Laravel applications using the native Storage facade and filesystem API.

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

Repository Files

Loading file structure...
src/DTOs/StorageBox.php
<?php

namespace GhostCompiler\Hetzner\StorageBox\DTOs;

class StorageBox
{
    public int $id;

    public ?string $username = null;

    public string $status;

    public string $name;

    public array $storageBoxType = [];

    public array $location = [];

    public array $accessSettings = [];

    public ?string $server = null;

    public ?string $system = null;

    public array $stats = [];

    public array $labels = [];

    public array $protection = [];

    public ?array $snapshotPlan = null;

    public string $created;

    /**
     * Create a new DTO instance from array data.
     */
    public static function fromArray(array $data): self
    {
        $box = new self;
        $box->id = (int) ($data['id'] ?? 0);
        $box->username = isset($data['username']) ? (string) $data['username'] : null;
        $box->status = (string) ($data['status'] ?? '');
        $box->name = (string) ($data['name'] ?? '');
        $box->storageBoxType = (array) ($data['storage_box_type'] ?? []);
        $box->location = (array) ($data['location'] ?? []);
        $box->accessSettings = (array) ($data['access_settings'] ?? []);
        $box->server = isset($data['server']) ? (string) $data['server'] : null;
        $box->system = isset($data['system']) ? (string) $data['system'] : null;
        $box->stats = (array) ($data['stats'] ?? []);
        $box->labels = (array) ($data['labels'] ?? []);
        $box->protection = (array) ($data['protection'] ?? []);
        $box->snapshotPlan = isset($data['snapshot_plan']) ? (array) $data['snapshot_plan'] : null;
        $box->created = (string) ($data['created'] ?? '');

        return $box;
    }
}