PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Framework / QueryBuilder / Clauses / Join.php

Join.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Framework/QueryBuilder/Clauses/Join.php

66 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Framework\QueryBuilder\Clauses;
4
5 use Give\Framework\QueryBuilder\QueryBuilder;
6 use Give\Framework\QueryBuilder\Types\JoinType;
7 use InvalidArgumentException;
8
9 /**
10 * @since 2.19.0
11 */
12 class Join
13 {
14 /**
15 * @var string
16 */
17 public $table;
18
19 /**
20 * @var string
21 */
22 public $joinType;
23
24 /**
25 * @var string|null
26 */
27 public $alias;
28
29 /**
30 * @param string $table
31 * @param string $joinType \Give\Framework\QueryBuilder\Types\JoinType
32 * @param string|null $alias
33 */
34 public function __construct($joinType, $table, $alias = null)
35 {
36 $this->table = QueryBuilder::prefixTable($table);
37 $this->joinType = $this->getJoinType($joinType);
38
39 if ( ! is_null($alias)) {
40 $this->alias = trim($alias);
41 }
42 }
43
44 /**
45 * @param string $type
46 *
47 * @return string
48 */
49 private function getJoinType($type)
50 {
51 $type = strtoupper($type);
52
53 if (array_key_exists($type, JoinType::getTypes())) {
54 return $type;
55 }
56
57 throw new InvalidArgumentException(
58 sprintf(
59 'Join type %s is not supported. Please provide one of the supported join types (%s)',
60 $type,
61 implode(',', JoinType::getTypes())
62 )
63 );
64 }
65 }
66