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

ICanBoogie / ActiveRecord / 6362433236

30 Sep 2023 11:14AM UTC coverage: 85.731% (+5.6%) from 80.178%
6362433236

push

github

olvlvl
Rename StaticModelProvider methods

1436 of 1675 relevant lines covered (85.73%)

29.41 hits per line

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

85.71
/lib/ActiveRecord/StatementNotValid.php
1
<?php
2

3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
namespace ICanBoogie\ActiveRecord;
13

14
use PDOException;
15
use RuntimeException;
16

17
use function array_pad;
18
use function is_array;
19
use function json_encode;
20
use function sprintf;
21

22
/**
23
 * Exception thrown in attempt to execute a statement that is not valid.
24
 */
25
class StatementNotValid extends RuntimeException implements Exception
26
{
27
    /**
28
     * @var string
29
     */
30
    public readonly string $statement;
31

32
    /**
33
     * @var array<mixed>
34
     */
35
    public readonly array $args;
36

37
    /**
38
     * @param array{ string, array<mixed> }|string $statement
39
     */
40
    public function __construct(
41
        $statement,
42
        public readonly ?PDOException $original = null
43
    ) {
44
        $args = [];
2✔
45

46
        if (is_array($statement)) {
2✔
47
            [ $statement, $args ] = $statement;
×
48
        }
49

50
        $this->statement = $statement;
2✔
51
        $this->args = $args;
2✔
52

53
        parent::__construct($this->format_message($statement, $args, $original));
2✔
54
    }
55

56
    private function format_message(string $statement, array $args, PDOException $previous = null): string
57
    {
58
        $message = null;
2✔
59

60
        if ($previous) {
2✔
61
            $er = array_pad($previous->errorInfo, 3, '');
1✔
62

63
            $message = sprintf('%s(%s) %s — ', $er[0], $er[1], $er[2]);
1✔
64
        }
65

66
        $message .= "`$statement`";
2✔
67

68
        if ($args) {
2✔
69
            $message .= " " . ($args ? json_encode($args) : "[]");
×
70
        }
71

72
        return $message;
2✔
73
    }
74
}
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