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

google / recaptcha / 30981639553

05 Aug 2026 06:31AM UTC coverage: 92.638% (-7.4%) from 100.0%
30981639553

Pull #634

github

web-flow
Merge 9a04f8353 into 6721ab8bf
Pull Request #634: ci/backward-compatibility-check

47 of 58 new or added lines in 8 files covered. (81.03%)

1 existing line in 1 file now uncovered.

151 of 163 relevant lines covered (92.64%)

15.64 hits per line

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

0.0
/src/ReCaptcha/RequestMethod/Socket.php
1
<?php
2

3
/**
4
 * This is a PHP library that handles calling reCAPTCHA.
5
 *
6
 * BSD 3-Clause License
7
 *
8
 * @copyright (c) 2019, Google Inc.
9
 *
10
 * @see https://www.google.com/recaptcha
11
 * All rights reserved.
12
 *
13
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions are met:
15
 * 1. Redistributions of source code must retain the above copyright notice, this
16
 *    list of conditions and the following disclaimer.
17
 *
18
 * 2. Redistributions in binary form must reproduce the above copyright notice,
19
 *    this list of conditions and the following disclaimer in the documentation
20
 *    and/or other materials provided with the distribution.
21
 *
22
 * 3. Neither the name of the copyright holder nor the names of its
23
 *    contributors may be used to endorse or promote products derived from
24
 *    this software without specific prior written permission.
25
 *
26
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
 */
37

38
namespace ReCaptcha\RequestMethod;
39

40
/**
41
 * Convenience wrapper around native socket and file functions to allow for
42
 * mocking.
43
 */
44
class Socket
45
{
46
    private $handle;
47

48
    /**
49
     * fsockopen.
50
     *
51
     * @see http://php.net/fsockopen
52
     *
53
     * @param string $hostname
54
     * @param int    $port
55
     * @param int    $errno
56
     * @param string $errstr
57
     * @param float  $timeout
58
     *
59
     * @return resource
60
     */
61
    public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null)
62
    {
NEW
63
        $this->handle = fsockopen($hostname, $port, $errno, $errstr, is_null($timeout) ? ini_get('default_socket_timeout') : $timeout);
×
64

NEW
65
        if (false != $this->handle && 0 === $errno && '' === $errstr) {
×
NEW
66
            return $this->handle;
×
67
        }
68

NEW
69
        return false;
×
70
    }
71

72
    /**
73
     * fwrite.
74
     *
75
     * @see http://php.net/fwrite
76
     *
77
     * @param string $string
78
     * @param int    $length
79
     *
80
     * @return bool|int
81
     */
82
    public function fwrite($string, $length = null)
83
    {
NEW
84
        return fwrite($this->handle, $string, is_null($length) ? strlen($string) : $length);
×
85
    }
86

87
    /**
88
     * fgets.
89
     *
90
     * @see http://php.net/fgets
91
     *
92
     * @param int $length
93
     *
94
     * @return string
95
     */
96
    public function fgets($length = null)
97
    {
NEW
98
        return fgets($this->handle, $length);
×
99
    }
100

101
    /**
102
     * feof.
103
     *
104
     * @see http://php.net/feof
105
     *
106
     * @return bool
107
     */
108
    public function feof()
109
    {
NEW
110
        return feof($this->handle);
×
111
    }
112

113
    /**
114
     * fclose.
115
     *
116
     * @see http://php.net/fclose
117
     *
118
     * @return bool
119
     */
120
    public function fclose()
121
    {
NEW
122
        return fclose($this->handle);
×
123
    }
124
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc