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