Driver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 2
c 5
b 1
f 0
lcom 0
cbo 2
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getReconnectExceptions() 0 8 1
A shouldStall() 0 4 1
1
<?php
2
3
namespace BsbDoctrineReconnect\DBAL\Driver\PDOMySql;
4
5
use BsbDoctrineReconnect\DBAL\Driver as DriverInterface;
6
use Doctrine\DBAL\DBALException;
7
use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySqlDriver;
8
9
/**
10
 * Class Driver
11
 *
12
 * @package BsbDoctrineReconnect\DBAL\Driver\PDOMySql
13
 */
14
class Driver extends PDOMySqlDriver implements DriverInterface
15
{
16
    /**
17
     * @return array
18
     */
19
    public function getReconnectExceptions()
20
    {
21
        return [
22
            'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away',
23
            'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, '
24
            . 'or not known'
25
        ];
26
    }
27
28
    /**
29
     * @param DBALException $e
30
     * @return bool
31
     */
32
    public function shouldStall(DBALException $e)
33
    {
34
        return stristr($e->getMessage(), 'php_network_getaddresses') !== false;
35
    }
36
}
37