class Socket in reCAPTCHA 7.2
Same name and namespace in other branches
- 8.2 recaptcha-php/src/ReCaptcha/RequestMethod/Socket.php \ReCaptcha\RequestMethod\Socket
- 6.2 recaptcha-php/src/ReCaptcha/RequestMethod/Socket.php \ReCaptcha\RequestMethod\Socket
Convenience wrapper around native socket and file functions to allow for mocking.
Hierarchy
- class \ReCaptcha\RequestMethod\Socket
Expanded class hierarchy of Socket
File
- recaptcha-php/
src/ ReCaptcha/ RequestMethod/ Socket.php, line 33
Namespace
ReCaptcha\RequestMethodView source
class Socket {
private $handle = null;
/**
* fsockopen
*
* @see http://php.net/fsockopen
* @param string $hostname
* @param int $port
* @param int $errno
* @param string $errstr
* @param float $timeout
* @return resource
*/
public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null) {
$this->handle = fsockopen($hostname, $port, $errno, $errstr, is_null($timeout) ? ini_get("default_socket_timeout") : $timeout);
if ($this->handle != false && $errno === 0 && $errstr === '') {
return $this->handle;
}
return false;
}
/**
* fwrite
*
* @see http://php.net/fwrite
* @param string $string
* @param int $length
* @return int | bool
*/
public function fwrite($string, $length = null) {
return fwrite($this->handle, $string, is_null($length) ? strlen($string) : $length);
}
/**
* fgets
*
* @see http://php.net/fgets
* @param int $length
* @return string
*/
public function fgets($length = null) {
return fgets($this->handle, $length);
}
/**
* feof
*
* @see http://php.net/feof
* @return bool
*/
public function feof() {
return feof($this->handle);
}
/**
* fclose
*
* @see http://php.net/fclose
* @return bool
*/
public function fclose() {
return fclose($this->handle);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Socket:: |
private | property | ||
Socket:: |
public | function | fclose | |
Socket:: |
public | function | feof | |
Socket:: |
public | function | fgets | |
Socket:: |
public | function | fsockopen | |
Socket:: |
public | function | fwrite |