<?php

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

declare(strict_types=1);

namespace Dagger;

/**
 * A git repository.
 */
class GitRepository extends Client\AbstractObject implements Client\IdAble
{
    /**
     * Returns details of a branch.
     */
    public function branch(string $name): GitRef
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('branch');
        $innerQueryBuilder->setArgument('name', $name);
        return new \Dagger\GitRef($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * branches that match any of the given glob patterns.
     */
    public function branches(?array $patterns = null): array
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('branches');
        if (null !== $patterns) {
        $leafQueryBuilder->setArgument('patterns', $patterns);
        }
        return (array)$this->queryLeaf($leafQueryBuilder, 'branches');
    }

    /**
     * Returns details of a commit.
     */
    public function commit(string $id): GitRef
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('commit');
        $innerQueryBuilder->setArgument('id', $id);
        return new \Dagger\GitRef($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Returns details for HEAD.
     */
    public function head(): GitRef
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('head');
        return new \Dagger\GitRef($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

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

    /**
     * Returns details for the latest semver tag.
     */
    public function latestVersion(): GitRef
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('latestVersion');
        return new \Dagger\GitRef($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Returns details of a ref.
     */
    public function ref(string $name): GitRef
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('ref');
        $innerQueryBuilder->setArgument('name', $name);
        return new \Dagger\GitRef($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Returns details of a tag.
     */
    public function tag(string $name): GitRef
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('tag');
        $innerQueryBuilder->setArgument('name', $name);
        return new \Dagger\GitRef($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * tags that match any of the given glob patterns.
     */
    public function tags(?array $patterns = null): array
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('tags');
        if (null !== $patterns) {
        $leafQueryBuilder->setArgument('patterns', $patterns);
        }
        return (array)$this->queryLeaf($leafQueryBuilder, 'tags');
    }

    /**
     * The URL of the git repository.
     */
    public function url(): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('url');
        return (string)$this->queryLeaf($leafQueryBuilder, 'url');
    }
}
