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

brick / orm / 23255296146

18 Mar 2026 04:24PM UTC coverage: 47.104%. Remained the same
23255296146

push

github

BenMorel
Avoid \Exception that somehow confuses ECS

1 of 5 new or added lines in 1 file covered. (20.0%)

402 existing lines in 24 files now uncovered.

553 of 1174 relevant lines covered (47.1%)

10.6 hits per line

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

0.0
/src/Exception/ORMException.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\ORM\Exception;
6

7
use Exception;
8

9
use function bin2hex;
10
use function count;
11
use function implode;
12
use function is_string;
13
use function preg_replace_callback;
14
use function strtoupper;
15

16
/**
17
 * Base class for all ORM exceptions.
18
 */
19
class ORMException extends Exception
20
{
21
    /**
22
     * Returns a parsable string representation of the given string, hex-encoding every non-printable ASCII char.
23
     *
24
     * Example: "ABC\xFE\xFF"
25
     */
26
    protected static function exportString(string $string): string
27
    {
UNCOV
28
        $export = preg_replace_callback('/[^\x20-\x7E]/', function (array $matches) {
×
29
            /** @var array{string} $matches */
UNCOV
30
            return '\x' . strtoupper(bin2hex($matches[0]));
×
UNCOV
31
        }, $string);
×
32

UNCOV
33
        return '"' . $export . '"';
×
34
    }
35

36
    /**
37
     * Returns a parsable string representation of the given array of scalars (int|string).
38
     *
39
     * This method is used to produce useful exception messages containing object identities.
40
     *
41
     * Examples:
42
     *
43
     * - 123
44
     * - [123, "ABC"]
45
     *
46
     * @param list<int|string> $scalarIdentity The identity, as a list of scalar values. Must contain at least one entry.
47
     *                                         Each entry must be an int or a string.
48
     */
49
    protected static function exportScalarIdentity(array $scalarIdentity): string
50
    {
UNCOV
51
        $result = [];
×
52

UNCOV
53
        foreach ($scalarIdentity as $value) {
×
54
            if (is_string($value)) {
×
UNCOV
55
                $result[] = self::exportString($value);
×
56
            } else {
57
                $result[] = (string) $value;
×
58
            }
59
        }
60

UNCOV
61
        $result = implode(', ', $result);
×
62

UNCOV
63
        if (count($scalarIdentity) === 1) {
×
UNCOV
64
            return $result;
×
65
        }
66

UNCOV
67
        return '[' . $result . ']';
×
68
    }
69
}
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