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

daycry / doctrine / 16048908161

03 Jul 2025 11:13AM UTC coverage: 57.859% (-21.0%) from 78.852%
16048908161

push

github

daycry
Refactor and enhance Doctrine debug toolbar integration

Moved and expanded DoctrineCollector and related classes under Debug/Toolbar/Collectors for better organization and improved debug toolbar integration. Added DoctrineConnectionProxy for query logging, updated Services to provide the new collector, and refactored Doctrine.php to use the new middleware and proxy. Improved code documentation and structure in cache handler extensions. Updated README and tests to reflect namespace changes.

11 of 132 new or added lines in 5 files covered. (8.33%)

254 of 439 relevant lines covered (57.86%)

11.59 hits per line

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

75.0
/src/Debug/Toolbar/Collectors/DoctrineQueryMiddleware.php
1
<?php
2

3
namespace Daycry\Doctrine\Debug\Toolbar\Collectors;
4

5
use Doctrine\DBAL\Driver;
6
use Doctrine\DBAL\Driver\API\ExceptionConverter;
7
use Doctrine\DBAL\Driver\Connection;
8
use Doctrine\DBAL\Driver\Middleware;
9
use Doctrine\DBAL\Driver\Result;
10
use Doctrine\DBAL\Driver\Statement;
11
use Doctrine\DBAL\Platforms\AbstractPlatform;
12
use Doctrine\DBAL\ServerVersionProvider;
13

14
class DoctrineQueryMiddleware implements Middleware
15
{
16
    protected $collector;
17

18
    public function __construct(DoctrineCollector $collector)
19
    {
20
        $this->collector = $collector;
52✔
21
    }
22

23
    public function wrap(Driver $driver): Driver
24
    {
25
        $collector = $this->collector;
52✔
26

27
        return new class ($driver, $collector) implements Driver {
52✔
28
            private $driver;
29
            private $collector;
30

31
            public function __construct(Driver $driver, DoctrineCollector $collector)
32
            {
33
                $this->driver    = $driver;
52✔
34
                $this->collector = $collector;
52✔
35
            }
36

37
            public function connect(array $params): Connection
38
            {
39
                $conn      = $this->driver->connect($params);
44✔
40
                $collector = $this->collector;
44✔
41

42
                return new class ($conn, $collector) implements Connection {
44✔
43
                    private $conn;
44
                    private $collector;
45

46
                    public function __construct($conn, DoctrineCollector $collector)
47
                    {
48
                        $this->conn      = $conn;
44✔
49
                        $this->collector = $collector;
44✔
50
                    }
51

52
                    public function prepare(string $sql): Statement
53
                    {
54
                        return $this->conn->prepare($sql);
22✔
55
                    }
56

57
                    public function query(string $sql): Result
58
                    {
59
                        $start  = microtime(true);
24✔
60
                        $result = $this->conn->query($sql);
24✔
61
                        $end    = microtime(true);
24✔
62
                        $this->collector->addQuery([
24✔
63
                            'sql'      => $sql,
24✔
64
                            'params'   => [],
24✔
65
                            'types'    => [],
24✔
66
                            'start'    => $start,
24✔
67
                            'end'      => $end,
24✔
68
                            'duration' => $end - $start,
24✔
69
                        ]);
24✔
70

71
                        return $result;
24✔
72
                    }
73

74
                    public function beginTransaction(): void
75
                    {
76
                        $this->conn->beginTransaction();
×
77
                    }
78

79
                    public function commit(): void
80
                    {
81
                        $this->conn->commit();
×
82
                    }
83

84
                    public function rollBack(): void
85
                    {
86
                        $this->conn->rollBack();
×
87
                    }
88

89
                    public function lastInsertId($name = null): string
90
                    {
NEW
91
                        return $this->conn->lastInsertId($name);
×
92
                    }
93

94
                    public function getNativeConnection()
95
                    {
NEW
96
                        return $this->conn->getNativeConnection();
×
97
                    }
98

99
                    public function exec(string $sql): int|string
100
                    {
101
                        return $this->conn->exec($sql);
×
102
                    }
103

104
                    public function quote(string $value): string
105
                    {
NEW
106
                        return $this->conn->quote($value);
×
107
                    }
108

109
                    public function getServerVersion(): string
110
                    {
111
                        return $this->conn->getServerVersion();
44✔
112
                    }
113

114
                    public function __call($name, $arguments)
115
                    {
NEW
116
                        return $this->conn->{$name}(...$arguments);
×
117
                    }
118
                };
44✔
119
            }
120

121
            public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform
122
            {
123
                return $this->driver->getDatabasePlatform($versionProvider);
52✔
124
            }
125

126
            public function getExceptionConverter(): ExceptionConverter
127
            {
128
                return $this->driver->getExceptionConverter();
×
129
            }
130
        };
52✔
131
    }
132
}
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