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

heimrichhannot / contao-utils-bundle / 6865351410

14 Nov 2023 02:54PM UTC coverage: 22.813% (-0.02%) from 22.835%
6865351410

push

github

koertho
backported new database util

2 of 14 new or added lines in 4 files covered. (14.29%)

1257 of 5510 relevant lines covered (22.81%)

1.55 hits per line

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

0.0
/src/Util/DatabaseUtil/CreateWhereForSerializedBlobResult.php
1
<?php
2

3
namespace HeimrichHannot\UtilsBundle\Util\DatabaseUtil;
4

5
class CreateWhereForSerializedBlobResult
6
{
7
    /**
8
     * @var string
9
     */
10
    public $field;
11
    /**
12
     * @var array
13
     */
14
    public $values;
15

16
    public function __construct(
17
        string $field,
18
        array $values
19
    ) {
NEW
20
        $this->field = $field;
×
NEW
21
        $this->values = $values;
×
22
    }
23

24
    /**
25
     * Return the where query with AND operation for each value. Values are inlined in the query ('REGEXP (':"3"')' instead of 'REGEXP (?)').
26
     */
27
    public function createInlineAndWhere(): string
28
    {
NEW
29
        return '('.$this->field.' REGEXP ('.implode(") AND ".$this->field.' REGEXP (', $this->getValueList()).'))';
×
30
    }
31

32
    /**
33
     * Return the where query with OR operation for each value. Values are inlined in the query ('REGEXP (':"3"')' instead of 'REGEXP (?)').
34
     */
35
    public function createInlineOrWhere(): string
36
    {
NEW
37
        return '('.$this->field.' REGEXP ('.implode(") OR ".$this->field.' REGEXP (', $this->getValueList()).'))';
×
38
    }
39

40
    /**
41
     * Return the where query with AND operation and placeholder for each value ('REGEXP (?)'). Values can be obtained from the values property.
42
     */
43
    public function createAndWhere(): string
44
    {
45

NEW
46
        return '('.$this->field.' REGEXP ('.implode(") AND ".$this->field.' REGEXP (', array_fill(0, count($this->getValueList()), '?')).'))';
×
47
    }
48

49
    /**
50
     * Return the where query with OR operation and placeholder for each value ('REGEXP (?)'). Values can be obtained from the values property.
51
     */
52
    public function createOrWhere(): string
53
    {
NEW
54
        return '('.$this->field.' REGEXP ('.implode(") OR ".$this->field.' REGEXP (', array_fill(0, count($this->getValueList()), '?')).'))';
×
55
    }
56

57
    private function getValueList(): array
58
    {
NEW
59
        $returnValues = [];
×
60

NEW
61
        foreach ($this->values as $val) {
×
NEW
62
            $returnValues[] = ":\"$val\"";
×
63
        }
64

NEW
65
        return $returnValues;
×
66
    }
67

68
}
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

© 2025 Coveralls, Inc