Code Duplication    Length = 27-28 lines in 2 locations

src/Drivers/Mysqli/Connection.php 1 location

@@ 55-82 (lines=28) @@
52
     * @return boolean True if connected
53
     * @throws ConnectionException If a connection error was encountered
54
     */
55
    public function connect($suppress_error = false)
56
    {
57
        $data = $this->getParams();
58
        $conn = mysqli_init();
59
60
        if (!empty($data['options'])) {
61
            foreach ($data['options'] as $option => $value) {
62
                $conn->options($option, $value);
63
            }
64
        }
65
66
        if (!$suppress_error && ! $this->silence_connection_warning) {
67
            $conn->real_connect($data['host'], null, null, null, (int) $data['port'], $data['socket']);
68
        } else {
69
            @ $conn->real_connect($data['host'], null, null, null, (int) $data['port'], $data['socket']);
70
        }
71
72
        if ($conn->connect_error) {
73
            throw new ConnectionException('Connection Error: ['.$conn->connect_errno.']'
74
                .$conn->connect_error);
75
        }
76
77
        $conn->set_charset('utf8');
78
        $this->connection = $conn;
79
        $this->mbPush();
80
81
        return true;
82
    }
83
84
    /**
85
     * Pings the Sphinx server.

src/Drivers/SimpleConnection.php 1 location

@@ 42-68 (lines=27) @@
39
     * @return boolean True if connected
40
     * @throws ConnectionException If a connection error was encountered
41
     */
42
    public function connect($suppress_error = false)
43
    {
44
        $data = $this->getParams();
45
        $conn = mysqli_init();
46
47
        if (!empty($data['options'])) {
48
            foreach ($data['options'] as $option => $value) {
49
                $conn->options($option, $value);
50
            }
51
        }
52
53
        if (!$suppress_error && ! $this->silence_connection_warning) {
54
            $conn->real_connect($data['host'], null, null, null, (int) $data['port'], $data['socket']);
55
        } else {
56
            @ $conn->real_connect($data['host'], null, null, null, (int) $data['port'], $data['socket']);
57
        }
58
59
        if ($conn->connect_error) {
60
            throw new ConnectionException('Connection Error: ['.$conn->connect_errno.']'
61
                .$conn->connect_error);
62
        }
63
64
        $conn->set_charset('utf8');
65
        $this->connection = $conn;
66
67
        return true;
68
    }
69
70
    /**
71
     * Pings the Sphinx server.