<?php

/**
 * This class has been generated by dagger-php-sdk. DO NOT EDIT.
 */

declare(strict_types=1);

namespace Dagger;

/**
 * A collection of environment variables.
 */
class EnvFile extends Client\AbstractObject implements Client\IdAble
{
    /**
     * Return as a file
     */
    public function asFile(): File
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('asFile');
        return new \Dagger\File($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Check if a variable exists
     */
    public function exists(string $name): bool
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('exists');
        $leafQueryBuilder->setArgument('name', $name);
        return (bool)$this->queryLeaf($leafQueryBuilder, 'exists');
    }

    /**
     * Lookup a variable (last occurrence wins) and return its value, or an empty string
     */
    public function get(string $name, ?bool $raw = null): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('get');
        $leafQueryBuilder->setArgument('name', $name);
        if (null !== $raw) {
        $leafQueryBuilder->setArgument('raw', $raw);
        }
        return (string)$this->queryLeaf($leafQueryBuilder, 'get');
    }

    /**
     * A unique identifier for this EnvFile.
     */
    public function id(): EnvFileId
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('id');
        return new \Dagger\EnvFileId((string)$this->queryLeaf($leafQueryBuilder, 'id'));
    }

    /**
     * Return all variables
     */
    public function variables(?bool $raw = null): array
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('variables');
        if (null !== $raw) {
        $leafQueryBuilder->setArgument('raw', $raw);
        }
        return (array)$this->queryLeaf($leafQueryBuilder, 'variables');
    }

    /**
     * Add a variable
     */
    public function withVariable(string $name, string $value): EnvFile
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withVariable');
        $innerQueryBuilder->setArgument('name', $name);
        $innerQueryBuilder->setArgument('value', $value);
        return new \Dagger\EnvFile($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Remove all occurrences of the named variable
     */
    public function withoutVariable(string $name): EnvFile
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withoutVariable');
        $innerQueryBuilder->setArgument('name', $name);
        return new \Dagger\EnvFile($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }
}
