PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 / JoinCondition.php

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

76 lines 1.6 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\Types\Operator;
6 use InvalidArgumentException;
7
8 /**
9 * @since 2.19.0
10 */
11 class JoinCondition
12 {
13 /**
14 * @var string
15 */
16 public $logicalOperator;
17
18 /**
19 * @var string
20 */
21 public $column1;
22
23 /**
24 * @var mixed
25 */
26 public $column2;
27
28 /**
29 * @var bool
30 */
31 public $quote;
32
33
34 /**
35 * @param string $logicalOperator
36 * @param string $column1
37 * @param string $column2
38 * @param bool $quote
39 */
40 public function __construct($logicalOperator, $column1, $column2, $quote = false)
41 {
42 $this->logicalOperator = $this->getLogicalOperator($logicalOperator);
43 $this->column1 = trim($column1);
44 $this->column2 = trim($column2);
45 $this->quote = $quote;
46 }
47
48 /**
49 * @param string $operator
50 *
51 * @return string
52 */
53 private function getLogicalOperator($operator)
54 {
55 $operator = strtoupper($operator);
56
57 $supportedOperators = [
58 Operator::ON,
59 Operator::_AND,
60 Operator::_OR
61 ];
62
63 if ( ! in_array($operator, $supportedOperators, true)) {
64 throw new InvalidArgumentException(
65 sprintf(
66 'Unsupported logical operator %s. Please provide one of the supported operators (%s)',
67 $operator,
68 implode(',', $supportedOperators)
69 )
70 );
71 }
72
73 return $operator;
74 }
75 }
76