<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/devtools/cloudbuild/v1/cloudbuild.proto

namespace Google\Cloud\Build\V1;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * PullRequestFilter contains filter properties for matching GitHub Pull
 * Requests.
 *
 * Generated from protobuf message <code>google.devtools.cloudbuild.v1.PullRequestFilter</code>
 */
class PullRequestFilter extends \Google\Protobuf\Internal\Message
{
    /**
     * Configure builds to run whether a repository owner or collaborator need to
     * comment `/gcbrun`.
     *
     * Generated from protobuf field <code>.google.devtools.cloudbuild.v1.PullRequestFilter.CommentControl comment_control = 5;</code>
     */
    private $comment_control = 0;
    /**
     * If true, branches that do NOT match the git_ref will trigger a build.
     *
     * Generated from protobuf field <code>bool invert_regex = 6;</code>
     */
    private $invert_regex = false;
    protected $git_ref;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $branch
     *           Regex of branches to match.
     *           The syntax of the regular expressions accepted is the syntax accepted by
     *           RE2 and described at https://github.com/google/re2/wiki/Syntax
     *     @type int $comment_control
     *           Configure builds to run whether a repository owner or collaborator need to
     *           comment `/gcbrun`.
     *     @type bool $invert_regex
     *           If true, branches that do NOT match the git_ref will trigger a build.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Devtools\Cloudbuild\V1\Cloudbuild::initOnce();
        parent::__construct($data);
    }

    /**
     * Regex of branches to match.
     * The syntax of the regular expressions accepted is the syntax accepted by
     * RE2 and described at https://github.com/google/re2/wiki/Syntax
     *
     * Generated from protobuf field <code>string branch = 2;</code>
     * @return string
     */
    public function getBranch()
    {
        return $this->readOneof(2);
    }

    public function hasBranch()
    {
        return $this->hasOneof(2);
    }

    /**
     * Regex of branches to match.
     * The syntax of the regular expressions accepted is the syntax accepted by
     * RE2 and described at https://github.com/google/re2/wiki/Syntax
     *
     * Generated from protobuf field <code>string branch = 2;</code>
     * @param string $var
     * @return $this
     */
    public function setBranch($var)
    {
        GPBUtil::checkString($var, True);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * Configure builds to run whether a repository owner or collaborator need to
     * comment `/gcbrun`.
     *
     * Generated from protobuf field <code>.google.devtools.cloudbuild.v1.PullRequestFilter.CommentControl comment_control = 5;</code>
     * @return int
     */
    public function getCommentControl()
    {
        return $this->comment_control;
    }

    /**
     * Configure builds to run whether a repository owner or collaborator need to
     * comment `/gcbrun`.
     *
     * Generated from protobuf field <code>.google.devtools.cloudbuild.v1.PullRequestFilter.CommentControl comment_control = 5;</code>
     * @param int $var
     * @return $this
     */
    public function setCommentControl($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Build\V1\PullRequestFilter\CommentControl::class);
        $this->comment_control = $var;

        return $this;
    }

    /**
     * If true, branches that do NOT match the git_ref will trigger a build.
     *
     * Generated from protobuf field <code>bool invert_regex = 6;</code>
     * @return bool
     */
    public function getInvertRegex()
    {
        return $this->invert_regex;
    }

    /**
     * If true, branches that do NOT match the git_ref will trigger a build.
     *
     * Generated from protobuf field <code>bool invert_regex = 6;</code>
     * @param bool $var
     * @return $this
     */
    public function setInvertRegex($var)
    {
        GPBUtil::checkBool($var);
        $this->invert_regex = $var;

        return $this;
    }

    /**
     * @return string
     */
    public function getGitRef()
    {
        return $this->whichOneof("git_ref");
    }

}

