cvs: pear /Net_GameServerQuery/GameServerQuery Protocol.php

From: Date: Fri, 05 Nov 2004 15:23:16 +0000
Subject: cvs: pear /Net_GameServerQuery/GameServerQuery Protocol.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-25705@lists.php.net to get a copy of this message
ortega Fri Nov 5 10:23:16 2004 EDT Modified files: /pear/Net_GameServerQuery/GameServerQuery Protocol.php Log: added _getPrefix() function http://cvs.php.net/diff.php/pear/Net_GameServerQuery/GameServerQuery/Protocol.php?r1=1.28&r2=1.29&ty=u Index: pear/Net_GameServerQuery/GameServerQuery/Protocol.php diff -u pear/Net_GameServerQuery/GameServerQuery/Protocol.php:1.28 pear/Net_GameServerQuery/GameServerQuery/Protocol.php:1.29 --- pear/Net_GameServerQuery/GameServerQuery/Protocol.php:1.28 Sat Sep 18 10:21:03 2004 +++ pear/Net_GameServerQuery/GameServerQuery/Protocol.php Fri Nov 5 10:23:13 2004 @@ -16,7 +16,7 @@ // | Tom Buskens <ortega@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Protocol.php,v 1.28 2004/09/18 14:21:03 aidan Exp $ +// $Id: Protocol.php,v 1.29 2004/11/05 15:23:13 ortega Exp $ /** @@ -26,7 +26,7 @@ * @package Net_GameServerQuery * @author Tom Buskens <ortega@php.net> * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.28 $ + * @version $Revision: 1.29 $ */ interface Net_GameServerQuery_Protocol_Interface { @@ -41,7 +41,7 @@ * @package Net_GameServerQuery * @author Tom Buskens <ortega@php.net> * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.28 $ + * @version $Revision: 1.29 $ */ abstract class Net_GameServerQuery_Protocol implements Net_GameServerQuery_Protocol_Interface { @@ -112,7 +112,7 @@ /** * Match response to regular expression * - * @access private + * @access protected * @param string $expr Regular expression * @return bool True if expression was matched, false otherwise */ @@ -144,6 +144,26 @@ /** + * Remove and return a prefix from the response string + * + * @access protected + * @param int $length Length of the prefix + * @return string The prefix + */ + protected function _getPrefix($length = 1) + { + // Get prefix + $result = substr($this->_response, 0, $length); + + // Remove prefix from response string + $remainder = strlen($this->_response) - $length; + $this->_response = substr($this->_response, $length, $remainder); + + return $result; + } + + + /** * Adds variable to output * * @access protected @@ -241,4 +261,4 @@ } -?> \ No newline at end of file +?>

« previous php.pear.cvs (#25705) next »