# give/4.16.8.1/src/Framework/QueryBuilder/Clauses/Join.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.16.8.1. 66 lines.

- Page: https://pluginprobe.com/plugins/give/4.16.8.1/code/src/Framework/QueryBuilder/Clauses/Join.php
- Raw: https://pluginprobe.com/plugins/give/4.16.8.1/raw/src/Framework/QueryBuilder/Clauses/Join.php
- Modified: 2024-01-10T19:22:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.16.8.1/code/src/Framework/QueryBuilder/Clauses/Join.php#L10-L20`.

```php
<?php

namespace Give\Framework\QueryBuilder\Clauses;

use Give\Framework\QueryBuilder\QueryBuilder;
use Give\Framework\QueryBuilder\Types\JoinType;
use InvalidArgumentException;

/**
 * @since 2.19.0
 */
class Join
{
    /**
     * @var string
     */
    public $table;

    /**
     * @var string
     */
    public $joinType;

    /**
     * @var string|null
     */
    public $alias;

    /**
     * @param  string  $table
     * @param  string  $joinType  \Give\Framework\QueryBuilder\Types\JoinType
     * @param  string|null  $alias
     */
    public function __construct($joinType, $table, $alias = null)
    {
        $this->table    = QueryBuilder::prefixTable($table);
        $this->joinType = $this->getJoinType($joinType);

        if ( ! is_null($alias)) {
            $this->alias = trim($alias);
        }
    }

    /**
     * @param  string  $type
     *
     * @return string
     */
    private function getJoinType($type)
    {
        $type = strtoupper($type);

        if (array_key_exists($type, JoinType::getTypes())) {
            return $type;
        }

        throw new InvalidArgumentException(
            sprintf(
                'Join type %s is not supported. Please provide one of the supported join types (%s)',
                $type,
                implode(',', JoinType::getTypes())
            )
        );
    }
}

```
