• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

saygoweb / anorm / 18453392201

13 Oct 2025 02:29AM UTC coverage: 91.003% (-9.0%) from 100.0%
18453392201

Pull #38

github

web-flow
Merge 641cc5828 into 6b2794b89
Pull Request #38: Implement Mango Query Support for Anorm QueryBuilder

215 of 267 new or added lines in 4 files covered. (80.52%)

526 of 578 relevant lines covered (91.0%)

11.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/src/SqlCondition.php
1
<?php
2

3
namespace Anorm;
4

5
/**
6
 * Represents a SQL condition with its bindings
7
 * Used by Mango Query parser to build WHERE clauses safely
8
 */
9
class SqlCondition
10
{
11
    private string $sql;
12
    private array $bindings;
13

14
    public function __construct(string $sql, array $bindings = [])
15
    {
16
        $this->sql = $sql;
27✔
17
        $this->bindings = $bindings;
27✔
18
    }
19

20
    public function getSql(): string
21
    {
22
        return $this->sql;
27✔
23
    }
24

25
    public function getBindings(): array
26
    {
27
        return $this->bindings;
25✔
28
    }
29

30
    /**
31
     * Combine this condition with another using the specified operator
32
     */
33
    public function combine(SqlCondition $other, string $operator = 'AND'): SqlCondition
34
    {
35
        $combinedSql = "({$this->sql}) {$operator} ({$other->getSql()})";
10✔
36
        $combinedBindings = array_merge($this->bindings, $other->getBindings());
10✔
37
        
38
        return new SqlCondition($combinedSql, $combinedBindings);
10✔
39
    }
40

41
    /**
42
     * Wrap this condition in parentheses
43
     */
44
    public function wrap(): SqlCondition
45
    {
NEW
46
        return new SqlCondition("({$this->sql})", $this->bindings);
×
47
    }
48

49
    /**
50
     * Create an empty condition (always true)
51
     */
52
    public static function empty(): SqlCondition
53
    {
54
        return new SqlCondition('1=1', []);
1✔
55
    }
56

57
    /**
58
     * Create a condition that's always false
59
     */
60
    public static function never(): SqlCondition
61
    {
NEW
62
        return new SqlCondition('1=0', []);
×
63
    }
64

65
    /**
66
     * Check if this condition is empty (always true)
67
     */
68
    public function isEmpty(): bool
69
    {
70
        return $this->sql === '1=1' && empty($this->bindings);
26✔
71
    }
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc