From b21464fafe567a02b15493ccc01c1076d53fe953 Mon Sep 17 00:00:00 2001 From: Huw Jones Date: Sun, 20 Oct 2019 14:45:10 +0100 Subject: [PATCH] PHPDoc-ed + added more functionality --- src/Club.php | 13 +- src/Event.php | 75 +++++++++- src/GetTimesBuilder.php | 131 +++++++++++------ src/MemberDetails.php | 81 ++++++++++- src/MemberNotFound.php | 10 -- src/RankingsClient.php | 188 +++++++++++++++++-------- src/Sex.php | 1 + src/SoapClient.php | 13 +- src/Time.php | 64 +++++++-- src/Times.php | 85 ++++------- src/exceptions/ConnectionException.php | 12 ++ src/exceptions/InvalidPersonalKey.php | 12 ++ src/exceptions/MemberNotFound.php | 12 ++ src/exceptions/UnknownException.php | 12 ++ 14 files changed, 509 insertions(+), 200 deletions(-) delete mode 100644 src/MemberNotFound.php create mode 100644 src/exceptions/ConnectionException.php create mode 100644 src/exceptions/InvalidPersonalKey.php create mode 100644 src/exceptions/MemberNotFound.php create mode 100644 src/exceptions/UnknownException.php diff --git a/src/Club.php b/src/Club.php index 602246f..06e8fc7 100644 --- a/src/Club.php +++ b/src/Club.php @@ -2,6 +2,11 @@ namespace RankingsDB; +/** + * Club object + * + * @package RankingsDB + */ class Club { protected $_club; @@ -16,6 +21,8 @@ public function __construct($club_code, $ranked) } /** + * Club Code + * * @return string */ public function Club() @@ -24,6 +31,8 @@ public function Club() } /** + * County Code + * * @return string */ public function County() @@ -32,7 +41,9 @@ public function County() } /** - * @return boolean + * Is this club a member's ranked club + * + * @return boolean true if this club is a member's ranked club */ public function IsRanked() { diff --git a/src/Event.php b/src/Event.php index f3d6d30..0ba9152 100644 --- a/src/Event.php +++ b/src/Event.php @@ -2,8 +2,34 @@ namespace RankingsDB; +/** + * Event obj + * + * @package RankingsDB + */ class Event { + static protected $_event_map = [ + 1 => Stroke::FREESTYLE . "50", + 2 => Stroke::FREESTYLE . "100", + 3 => Stroke::FREESTYLE . "200", + 4 => Stroke::FREESTYLE . "400", + 5 => Stroke::FREESTYLE . "800", + 6 => Stroke::FREESTYLE . "1500", + 7 => Stroke::BREASTSTROKE . "50", + 8 => Stroke::BREASTSTROKE . "100", + 9 => Stroke::BREASTSTROKE . "200", + 10 => Stroke::BUTTERFLY . "50", + 11 => Stroke::BUTTERFLY . "100", + 12 => Stroke::BUTTERFLY . "200", + 13 => Stroke::BACKSTROKE . "50", + 14 => Stroke::BACKSTROKE . "100", + 15 => Stroke::BACKSTROKE . "200", + 16 => Stroke::INDIVIDUAL_MEDLEY . "100", + 17 => Stroke::INDIVIDUAL_MEDLEY . "200", + 18 => Stroke::INDIVIDUAL_MEDLEY . "400" + ]; + static protected $_reverse_map = []; protected $_stroke; protected $_distance; @@ -11,9 +37,34 @@ public function __construct($stroke, $distance) { $this->_stroke = $stroke; $this->_distance = $distance; + + if (count(Event::$_reverse_map) == 0) { + Event::$_reverse_map = array_flip(Event::$_event_map); + } + } + + public static function fromEventCode($code) + { + $event_id = Event::$_event_map[$code]; + return Event::fromEventID($event_id); + } + + /** + * Creates an event from an event ID + * + * @param $event_id + * @return Event + */ + public static function fromEventID($event_id) + { + $stroke = substr($event_id, 0, 2); + $distance = intval(substr($event_id, 2)); + return new Event($stroke, $distance); } /** + * Stroke + * * @return Stroke */ public function stroke() @@ -22,6 +73,8 @@ public function stroke() } /** + * Distance + * * @return int */ public function distance() @@ -29,14 +82,24 @@ public function distance() return $this->_distance; } - public function eventID(){ - return $this->_stroke . $this->_distance; + /** + * Returns the event code for this event object + * + * @return int + */ + public function eventCode() + { + return Event::$_reverse_map[$this->eventID()]; } - public static function fromEventID($event_id){ - $stroke = substr($event_id, 0, 2); - $distance = intval(substr($event_id, 2)); - return new Event($stroke, $distance); + /** + * Returns the event ID for this event object + * + * @return string + */ + public function eventID() + { + return $this->_stroke . $this->_distance; } } \ No newline at end of file diff --git a/src/GetTimesBuilder.php b/src/GetTimesBuilder.php index 3a47c50..6842ff5 100644 --- a/src/GetTimesBuilder.php +++ b/src/GetTimesBuilder.php @@ -2,9 +2,14 @@ namespace RankingsDB; -use Cassandra\Date; use DateTime; +use Exception; +/** + * Builder to create options for GetTimes + * + * @package RankingsDB + */ class GetTimesBuilder { protected $_member_id; @@ -15,52 +20,23 @@ class GetTimesBuilder protected $_include_masters = true; protected $_include_relays = false; - public function __construct($member_id) - { - $this->_member_id = $member_id; - } - - /** - * @param null $from_date - * @return GetTimesBuilder - */ - public function setFromDate($from_date) - { - $this->_from_date = $from_date; - return $this; - } - /** - * @param null $to_date - * @return GetTimesBuilder + * Create a GetTimesBuilder object + * + * @param $member int|MemberDetails SE Membership ID, or Member Details object */ - public function setToDate($to_date) + public function __construct($member) { - $this->_to_date = $to_date; - return $this; - } - - /** - * @param string $course - * @return GetTimesBuilder - */ - public function setCourse($course) - { - $this->_course = $course; - return $this; - } - - /** - * @param int $level - * @return GetTimesBuilder - */ - public function setLevel($level) - { - $this->_level = $level; - return $this; + if (is_int($member)) { + $this->_member_id = $member; + } else { + $this->_member_id = $member->MemberID(); + } } /** + * Include times from masters events + * * @param bool $include_masters * @return GetTimesBuilder */ @@ -71,6 +47,8 @@ public function setIncludeMasters($include_masters) } /** + * Include times from relays + * * @param bool $include_relays * @return GetTimesBuilder */ @@ -81,7 +59,7 @@ public function setIncludeRelays($include_relays) } /** - * @return mixed + * @return int */ public function getMemberID() { @@ -93,23 +71,55 @@ public function getMemberID() */ public function getFromDate() { - if ($this->_from_date === null){ - return (new DateTime("1970-01-01"))->setTime(0, 0, 0); + if ($this->_from_date === null) { + try { + return (new DateTime("1970-01-01"))->setTime(0, 0, 0); + } catch (Exception $e) { + + } } return $this->_from_date; } + /** + * Set the from date + * + * @param null|DateTime $from_date + * @return GetTimesBuilder + */ + public function setFromDate($from_date) + { + $this->_from_date = $from_date; + return $this; + } + /** * @return DateTime */ public function getToDate() { - if ($this->_to_date === null){ - return (new DateTime()); + if ($this->_to_date === null) { + try { + return (new DateTime()); + } catch (Exception $e) { + + } } return $this->_to_date; } + /** + * Set the to date + * + * @param null|DateTime $to_date + * @return GetTimesBuilder + */ + public function setToDate($to_date) + { + $this->_to_date = $to_date; + return $this; + } + /** * @return string */ @@ -118,6 +128,18 @@ public function getCourse() return $this->_course; } + /** + * Set the course code + * + * @param string $course + * @return GetTimesBuilder + */ + public function setCourse($course) + { + $this->_course = $course; + return $this; + } + /** * @return int */ @@ -126,6 +148,23 @@ public function getLevel() return $this->_level; } + /** + * Set the minimum required competition level + * + * - 0: ALL + * - 1: Level 1 + * - 2: Level 2 + * - 3: Level 3 + * + * @param int $level + * @return GetTimesBuilder + */ + public function setLevel($level) + { + $this->_level = $level; + return $this; + } + /** * @return bool */ diff --git a/src/MemberDetails.php b/src/MemberDetails.php index 38fb01e..d11945c 100644 --- a/src/MemberDetails.php +++ b/src/MemberDetails.php @@ -3,7 +3,14 @@ namespace RankingsDB; use DateTime; - +use DateTimeImmutable; +use Exception; + +/** + * Member Details + * + * @package RankingsDB + */ class MemberDetails { protected $_memberID; @@ -22,9 +29,11 @@ class MemberDetails protected $_SM_CLASS; protected $_SB_CLASS; protected $_IPC_CODES; + protected $_lastUpdated; public function __construct($member_details) { + $this->_lastUpdated = new DateTimeImmutable($member_details->TimeStamp); $this->_memberID = $member_details->MemberID; $this->_firstName = $member_details->FirstName; $this->_lastName = $member_details->LastName; @@ -55,6 +64,7 @@ public function __construct($member_details) } /** + * Swim England Membership ID * @return int */ public function MemberID() @@ -63,6 +73,8 @@ public function MemberID() } /** + * First Name + * * @return string */ public function FirstName() @@ -71,6 +83,8 @@ public function FirstName() } /** + * Last Name + * * @return string */ public function LastName() @@ -79,6 +93,8 @@ public function LastName() } /** + * Preferred First Name + * * @return string */ public function KnownAs() @@ -87,6 +103,8 @@ public function KnownAs() } /** + * Middle Initials + * * @return string */ public function Initials() @@ -95,6 +113,8 @@ public function Initials() } /** + * List of clubs the swimmer is a member of + * * @return Club[] */ public function Clubs() @@ -103,6 +123,8 @@ public function Clubs() } /** + * Date of Birth + * * @return DateTime */ public function DateOfBirth() @@ -111,6 +133,27 @@ public function DateOfBirth() } /** + * Age + * + * @param $at DateTime|null age at date, or now if null + * + * @return int + */ + public function Age($at = null) + { + if ($at == null) { + try { + $at = new DateTime(); + } catch (Exception $exception) { + + } + } + return $at->diff($this->_DoB)->y; + } + + /** + * Sex + * * @return Sex */ public function Sex() @@ -119,7 +162,9 @@ public function Sex() } /** - * @return mixed + * Country Code + * + * @return string */ public function CountryCode() { @@ -127,6 +172,8 @@ public function CountryCode() } /** + * Country + * * @return string */ public function Country() @@ -136,7 +183,8 @@ public function Country() /** - * @return mixed + * IPC Codes + * @return string */ public function IPCCodes() { @@ -144,7 +192,9 @@ public function IPCCodes() } /** - * @return int|null + * SB Class + * + * @return int|null null if not classified, otherwise class number */ public function SBClass() { @@ -153,7 +203,9 @@ public function SBClass() } /** - * @return int|null + * SM Class + * + * @return int|null null if not classified, otherwise class number */ public function SMClass() { @@ -162,7 +214,9 @@ public function SMClass() } /** - * @return int|null + * S Class + * + * @return int|null null if not classified, otherwise class number */ public function SClass() { @@ -171,6 +225,8 @@ public function SClass() } /** + * I Class + * * @return mixed */ public function getIClass() @@ -179,10 +235,21 @@ public function getIClass() } /** + * * @return boolean */ - public function Lapsed() + public function getLapsed() { return $this->_lapsed; } + + /** + * Date record was last updated + * + * @return DateTimeImmutable + */ + public function getLastUpdated() + { + return $this->_lastUpdated; + } } \ No newline at end of file diff --git a/src/MemberNotFound.php b/src/MemberNotFound.php deleted file mode 100644 index 33cdd97..0000000 --- a/src/MemberNotFound.php +++ /dev/null @@ -1,10 +0,0 @@ -_soap_pass = new SoapVar(RankingsClient::$_pass, XSD_STRING); if (!is_int($membership_number)) { - throw new TypError("Personal key number must be an integer"); + throw new TypeError("Personal key number must be an integer"); } $this->_personal_key = $personal_key; @@ -51,88 +53,150 @@ public function __construct($personal_key, $membership_number) $this->_soap_pk_id = new SoapVar($this->_personal_key_member_number, XSD_INT); try { -// $this->_soap_client = new nusoap_client("https://www.swimmingresults.org/soap/BritSwimWebServ.php?wsdl", "wsdl"); -// $this->_soap_client->soap_defencoding = 'UTF-8'; -// $this->_soap_client->decode_utf8 = FALSE; -// $this->_soap_client->setUseCURL(true); -// $this->_soap_client->setCurlOption(CURLOPT_USERAGENT, $this->get_user_agent()); -// $this->_soap_client->loadWSDL(); -// $err = $this->_soap_client->getError(); - ini_set("soap.wsdl_cache_ttl", 0); $this->_soap_client = new SoapClient( null, [ - "location" =>"https://www.swimmingresults.org/soap/BritSwimWebServ.php", - "uri" =>"https://www.swimmingresults.org/soap", + "location" => "https://www.swimmingresults.org/soap/BritSwimWebServ.php", + "uri" => "https://www.swimmingresults.org/soap", "trace" => 1 ] ); $this->_soap_client->wsdl = false; - - $this->wsdl = false; -// if($err){ -// print($err); -// } - } catch (\SoapFault $fault) { - print($fault); + $this->_checkConnection(); + } catch (SoapFault $fault) { + throw new ConnectionException("Failed to connect to rankings DB - " . $fault->getMessage()); + } catch (UnknownException $fault) { + throw new ConnectionException("Failed to connect to rankings DB - " . $fault->getMessage()); } } - protected function get_user_agent() + /** + * Check connection to service + * + * @throws ConnectionException + * @throws InvalidPersonalKey + * @throws UnknownException if something unknown failed + */ + protected function _checkConnection() { - if ($this->wsdl) { - return "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; + + $result = $this->_soap_client->CheckConnection2Service($this->_soap_user, $this->_soap_pass); + if ($result != "Okay") { + throw new ConnectionException("Failed to connect to rankings DB - an unknown error occurred."); + } + + // Check to see if personal key is valid + try { + $this->getMemberDetails(-1); + } catch (SoapFault $fault) { + if (strpos($fault->getMessage(), "Invalid Personal Key") !== false || strpos($fault->getMessage(), "No Personal Key") !== false) { + throw new InvalidPersonalKey("Invalid personal key"); + } + } catch (MemberNotFound $exception) { + // We know this will throw if the personal key is correct } - return "SOAP Toolkit 3.0"; } /** * Fetches a member's details from their ID number * - * @param $member_id + * @param $member_number int SE Membership ID * * @return MemberDetails * - * @throws MemberNotFound + * @throws TypeError if member ID is not an integer + * @throws MemberNotFound if a member could not be found + * @throws UnknownException if something unknown failed */ - public function getMemberDetails($member_id) + public function getMemberDetails($member_number) { - if (!is_int($member_id)) { - throw new TypError("Personal key number must be an integer"); + if (!is_int($member_number)) { + throw new TypeError("Membership number must be an integer"); + } + $soap_member_id = new SoapVar($member_number, XSD_INT); + try { + $member = $this->_soap_client->MembDetailsSingleMembV2( + $this->_soap_user, + $this->_soap_pass, + $soap_member_id, + $this->_soap_pk, + $this->_soap_pk_id + ); + return new MemberDetails($member[0]); + } catch (SoapFault $fault) { + if (strpos($fault->getMessage(), "No member found") !== false) { + throw new MemberNotFound("Member with ID '" . $member_number . "' was not found"); + } + throw new UnknownException("Could not fetch member, an unknown error occurred. " . $fault->getMessage()); } - $soap_member_id = new SoapVar($member_id, XSD_INT); - $member = $this->_soap_client->MembDetailsSingleMembV2( - $this->_soap_user, - $this->_soap_pass, - $soap_member_id, - $this->_soap_pk, - $this->_soap_pk_id - ); - return new MemberDetails($member[0]); } - //MembTimeAllEventsV3(ClientUser: xsd:string, ClientPass: xsd:string, MemberID: xsd:int, SwimFromDate: xsd:string, SwimToDate: xsd:string, Course: xsd:string, EntryLevel: xsd:int, MastersSwims: xsd:boolean, RelaySplitsSwims: xsd:boolean) - /** - * @param $options GetTimesBuilder + * Fetch all a member's times + * + * @param $options GetTimesBuilder Search criteria + * + * @return Times Swimmer's times * - * @return Times + * @throws UnknownException */ public function getTimes($options) { $soap_member_id = new SoapVar($options->getMemberID(), XSD_INT); - $times = $this->_soap_client->MembTimeAllEventsV3( - $this->_soap_user, - $this->_soap_pass, - $soap_member_id, - new SoapVar($options->getFromDate()->format("Y-m-d"), XSD_STRING), - new SoapVar($options->getToDate()->format("Y-m-d"), XSD_STRING), - new SoapVar($options->getCourse(), XSD_STRING), - new SoapVar($options->getLevel(), XSD_INT), - new SoapVar($options->includeMasters(), XSD_BOOLEAN), - new SoapVar($options->includeRelays(), XSD_BOOLEAN) - ); - return new Times($times); + try { + $times = $this->_soap_client->MembTimeAllEventsV3( + $this->_soap_user, + $this->_soap_pass, + $soap_member_id, + new SoapVar($options->getFromDate()->format("Y-m-d"), XSD_STRING), + new SoapVar($options->getToDate()->format("Y-m-d"), XSD_STRING), + new SoapVar($options->getCourse(), XSD_STRING), + new SoapVar($options->getLevel(), XSD_INT), + new SoapVar($options->includeMasters(), XSD_BOOLEAN), + new SoapVar($options->includeRelays(), XSD_BOOLEAN) + ); + return new Times($times); + } catch (SoapFault $fault) { + if (strpos($fault->getMessage(), "No swims found")) { + return new Times([]); + } + throw new UnknownException("Could not fetch times, an unknown error occurred. " . $fault->getMessage()); + } + } + + /** + * Fetch a time for specified event + * + * @param $event Event Event to fetch times for + * @param $options GetTimesBuilder Search criteria + * + * @return Time|null Time or null if no time found + * + * @throws UnknownException + */ + public function getTimeForEvent($event, $options) + { + $soap_member_id = new SoapVar($options->getMemberID(), XSD_INT); + try { + $time = $this->_soap_client->MembTimeSingleEventV3( + $this->_soap_user, + $this->_soap_pass, + $soap_member_id, + new SoapVar($options->getFromDate()->format("Y-m-d"), XSD_STRING), + new SoapVar($options->getToDate()->format("Y-m-d"), XSD_STRING), + new SoapVar($options->getCourse(), XSD_STRING), + new SoapVar($event->eventCode(), XSD_INT), + new SoapVar($options->getLevel(), XSD_INT), + new SoapVar($options->includeMasters(), XSD_BOOLEAN), + new SoapVar($options->includeRelays(), XSD_BOOLEAN) + )[0]; + return new Time(Event::fromEventCode($time->Event), $time->Time); + } catch (SoapFault $fault) { + if (strpos($fault->getMessage(), "No swims found") !== false) { + return null; + } + throw new UnknownException("Could not fetch time, an unknown error occurred. " . $fault->getMessage()); + } } } \ No newline at end of file diff --git a/src/Sex.php b/src/Sex.php index 7746d00..1926ce1 100644 --- a/src/Sex.php +++ b/src/Sex.php @@ -1,4 +1,5 @@ get_user_agent()); - return parent::__doRequest($request, $location, $action, $version, $one_way); + + try { + $response = parent::__doRequest($request, $location, $action, $version, $one_way); + } finally { + // Reset User-Agent to default + ini_set("user_agent", $old_ua); + } + return $response; } protected function get_user_agent() diff --git a/src/Time.php b/src/Time.php index d9b636e..f0b3850 100644 --- a/src/Time.php +++ b/src/Time.php @@ -2,6 +2,13 @@ namespace RankingsDB; +/** + * Time object + * + * Contains time and event details + * + * @package RankingsDB + */ class Time { protected $_event; @@ -24,6 +31,8 @@ public function __construct($event, $time_str) } /** + * Stroke + * * @return Stroke */ public function stroke() @@ -32,6 +41,8 @@ public function stroke() } /** + * Distance + * * @return int */ public function distance() @@ -40,6 +51,8 @@ public function distance() } /** + * Event Object + * * @return Event */ public function event() @@ -47,18 +60,32 @@ public function event() return $this->_event; } - public function getTime($leading_zeroes = true) + /** + * Returns the time in seconds + * + * E.g.: + * + * 2:02.72 => 122.72 + * + * @return float + */ + public function getTimeInSeconds() { - $time = sprintf("%02d.%02d", $this->_seconds, $this->_hundredths); - if ($this->_minutes !== 0 || $leading_zeroes) { - $time = $this->_minutes . ":" . $time; - } - return $time; + return $this->_seconds * 60 + $this->_seconds + $this->_hundredths / 100; } - public function getTimeInSeconds() + /** + * Returns the time in hundredths of seconds + * + * E.g.: + * + * 2:02.72 => 12272 + * + * @return int + */ + public function getTimeInHundredths() { - return $this->_seconds * 60 + $this->_seconds + $this->_hundredths / 100; + return 100 * ($this->_seconds * 60 + $this->_seconds) + $this->_hundredths; } public function __toString() @@ -66,5 +93,26 @@ public function __toString() return $this->_event->eventID() . ": " . $this->getTime(); } + /** + * Get the time formatted in m:s.0 + * + * If `$leading_zeroes` is `true`, then anytime less than 60 seconds will be prefixed with `0:`. + * + * E.g.: + * + * '56.78' => '0:56.78' + * + * @param bool $leading_zeroes include minutes if 0 + * @return string + */ + public function getTime($leading_zeroes = true) + { + $time = sprintf("%02d.%02d", $this->_seconds, $this->_hundredths); + if ($this->_minutes !== 0 || $leading_zeroes) { + $time = $this->_minutes . ":" . $time; + } + return $time; + } + } \ No newline at end of file diff --git a/src/Times.php b/src/Times.php index 56084ce..bcd1467 100644 --- a/src/Times.php +++ b/src/Times.php @@ -2,37 +2,18 @@ namespace RankingsDB; -class Times implements \Iterator +use Iterator; + +class Times implements Iterator { - static protected $_event_map = [ - 1 => Stroke::FREESTYLE . "50", - 2 => Stroke::FREESTYLE . "100", - 3 => Stroke::FREESTYLE . "200", - 4 => Stroke::FREESTYLE . "400", - 5 => Stroke::FREESTYLE . "800", - 6 => Stroke::FREESTYLE . "1500", - 7 => Stroke::BREASTSTROKE . "50", - 8 => Stroke::BREASTSTROKE . "100", - 9 => Stroke::BREASTSTROKE . "200", - 10 => Stroke::BUTTERFLY . "50", - 11 => Stroke::BUTTERFLY . "100", - 12 => Stroke::BUTTERFLY . "200", - 13 => Stroke::BACKSTROKE . "50", - 14 => Stroke::BACKSTROKE . "100", - 15 => Stroke::BACKSTROKE . "200", - 16 => Stroke::INDIVIDUAL_MEDLEY . "100", - 17 => Stroke::INDIVIDUAL_MEDLEY . "200", - 18 => Stroke::INDIVIDUAL_MEDLEY . "400" - ]; protected $_times = []; protected $_pointer = 0; public function __construct($times) { foreach ($times as $time) { - $event_id = Times::$_event_map[$time->Event]; - $event = Event::fromEventID($event_id); - $this->_times[$event_id] = new Time($event, $time->Time); + $event = Event::fromEventCode($time->Event); + $this->_times[$event->eventID()] = new Time($event, $time->Time); } } @@ -41,74 +22,60 @@ static protected function _evtKey($distance, $stroke) return (new Event($stroke, $distance))->eventID(); } + /** + * Get the time for a given distance/stroke + * + * You can iterate over this object in a foreach loop + * + * @param $distance int + * @param $stroke Stroke + * + * @return Time|null time, or null if not time + */ public function getTime($distance, $stroke) { - return $this->_times[$this->_evtKey($distance, $stroke)]; + $evt_key = $this->_evtKey($distance, $stroke); + if (!array_key_exists($evt_key, $this->_times)) { + return null; + } + return $this->_times[$evt_key]; } - protected function _getKeyAtPos($position){ + protected function _getKeyAtPos($position) + { $keys = array_keys($this->_times); return $keys[$position]; } - protected function _getTimeAtPos($position){ + protected function _getTimeAtPos($position) + { return $this->_times[$this->_getKeyAtPos($position)]; } - /** - * Return the current element - * @link https://php.net/manual/en/iterator.current.php - * @return mixed Can return any type. - * @since 5.0.0 - */ + // public function current() { return $this->_getTimeAtPos($this->_pointer); } - /** - * Move forward to next element - * @link https://php.net/manual/en/iterator.next.php - * @return void Any returned value is ignored. - * @since 5.0.0 - */ public function next() { ++$this->_pointer; } - /** - * Return the key of the current element - * @link https://php.net/manual/en/iterator.key.php - * @return string|float|int|bool|null scalar on success, or null on failure. - * @since 5.0.0 - */ public function key() { return $this->_getKeyAtPos($this->_pointer); } - /** - * Checks if current position is valid - * @link https://php.net/manual/en/iterator.valid.php - * @return bool The return value will be casted to boolean and then evaluated. - * Returns true on success or false on failure. - * @since 5.0.0 - */ public function valid() { - // TODO: Implement valid() method. return $this->_pointer < count($this->_times); } - /** - * Rewind the Iterator to the first element - * @link https://php.net/manual/en/iterator.rewind.php - * @return void Any returned value is ignored. - * @since 5.0.0 - */ public function rewind() { $this->_pointer = 0; } + // } \ No newline at end of file diff --git a/src/exceptions/ConnectionException.php b/src/exceptions/ConnectionException.php new file mode 100644 index 0000000..6fa1862 --- /dev/null +++ b/src/exceptions/ConnectionException.php @@ -0,0 +1,12 @@ +