Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
NotBetween | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
render | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Db\Sql\Predicate; |
15 | |
16 | use Pop\Db\Sql\AbstractSql; |
17 | |
18 | /** |
19 | * Not Between predicate class |
20 | * |
21 | * @category Pop |
22 | * @package Pop\Db |
23 | * @author Nick Sagona, III <dev@nolainteractive.com> |
24 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
25 | * @license http://www.popphp.org/license New BSD License |
26 | * @version 6.5.0 |
27 | */ |
28 | class NotBetween extends AbstractPredicate |
29 | { |
30 | |
31 | /** |
32 | * Constructor |
33 | * |
34 | * Instantiate the NOT BETWEEN predicate set object |
35 | * |
36 | * @param array $values |
37 | * @param string $conjunction |
38 | * @throws Exception |
39 | */ |
40 | public function __construct(array $values, string $conjunction = 'AND') |
41 | { |
42 | $this->format = '%1 NOT BETWEEN %2 AND %3'; |
43 | parent::__construct($values, $conjunction); |
44 | } |
45 | |
46 | /** |
47 | * Render the predicate string |
48 | * |
49 | * |
50 | * @param AbstractSql $sql |
51 | * @throws Exception |
52 | * @return string |
53 | */ |
54 | public function render(AbstractSql $sql): string |
55 | { |
56 | if (count($this->values) != 3) { |
57 | throw new Exception('Error: The values array must have 3 values in it.'); |
58 | } |
59 | |
60 | [$column, $value1, $value2] = $this->values; |
61 | |
62 | $predicate = str_replace( |
63 | ['%1', '%2', '%3'], [$sql->quoteId($column), $sql->quote($value1), $sql->quote($value2)], $this->format |
64 | ); |
65 | |
66 | return '(' . $predicate . ')'; |
67 | } |
68 | |
69 | } |