From 3b9646b5e95ca0eafa6adcb3d70bae73f2b44c0f Mon Sep 17 00:00:00 2001 From: Krzysztof Madejski Date: Tue, 7 Nov 2017 15:42:52 +0100 Subject: [PATCH] Resolves #1 - Rename update* to parse* --- src/Senat.php | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Senat.php b/src/Senat.php index 8c42241..b1a45f5 100644 --- a/src/Senat.php +++ b/src/Senat.php @@ -519,7 +519,7 @@ private function _senatorExtractSenatAssemblies($html) { return $this->__senatorExtractTeams($html, '

Zespoły senackie

', ''); } - public function updateSenatorSpeechesList($SenatorID, $chamberInt) { + public function parseSenatorSpeechesList($SenatorID, $chamberInt) { $html = $this->curl_get(self::BASE_URL . '/sklad/senatorowie/aktywnosc,' . $SenatorID . ',' . $chamberInt . '.html'); $re = "/[^<]*?([\\d]*?)<\\/td>[\\s\\S]*?([^<]*?)<\\/td>[^<]*?([^<]*?)<\\/td>[^<]*?([\\s\\S]*?)<\\/td>[^<]*?<\\/tr>/"; @@ -567,7 +567,7 @@ public function urlSittingStenogram($id_sitting_with_day) { return self::BASE_URL . '/prace/senat/posiedzenia/przebieg,' . $id_sitting_with_day . '.html'; } - public function updateSenatorVotesAtMeeting($SenatorID, $MeetingID) { + public function parseSenatorVotesAtMeeting($SenatorID, $MeetingID) { $html = $this->curl_get(self::BASE_URL . '/sklad/senatorowie/aktywnosc-glosowania,' . $SenatorID . ',8,szczegoly,' . $MeetingID . '.html'); $re = "/[^<]*?[^<]*?<\\/a>[^<]*?<\\/td>[^<]*?[^<]*?<\\/td>[^<]*?([^<]*)<\\/td>/"; @@ -587,7 +587,7 @@ public function updateSenatorVotesAtMeeting($SenatorID, $MeetingID) { } //Vote might me: za/przeciw/wstrzymał się/nie głosował/nieobecny - public function updateSenatorVotingActivity($SenatorID) { + public function parseSenatorVotingActivity($SenatorID) { $html = $this->curl_get(self::BASE_URL . '/sklad/senatorowie/aktywnosc-glosowania,' . $SenatorID . ',8.html'); $re = "/[^<]*?[^<]*?<\\/a>[^<]*?<\\/td>/"; @@ -598,7 +598,7 @@ public function updateSenatorVotingActivity($SenatorID) { $ans = array(); foreach ($matches as $match) { - $ans[$match[2]] = $this->updateSenatorVotesAtMeeting($SenatorID, $match[2]); + $ans[$match[2]] = $this->parseSenatorVotesAtMeeting($SenatorID, $match[2]); } return $ans; } @@ -608,8 +608,7 @@ public function updateSenatorVotingActivity($SenatorID) { * @param $chamberNo Poczynając od IX kadencji na stronach Senatu zaczęto aggregować archiwalne informacje * @return array */ - // TODO rename update to parse - public function updateSenatorInfo($SenatorID, $chamberNo) { + public function parseSenatorInfo($SenatorID, $chamberNo) { $url = self::BASE_URL . '/sklad/senatorowie/senator,' . $SenatorID . ',' . $chamberNo . '.html'; $html = $this->curl_get($url); @@ -629,7 +628,7 @@ public function updateSenatorInfo($SenatorID, $chamberNo) { 'committees' => $this->_senatorExtractCommissions($html), 'parliamentary_assemblies' => $this->_senatorExtractParlimentaryAssemblies($html), 'senat_assemblies' => $this->_senatorExtractSenatAssemblies($html), - 'activity_senat_meetings' => $this->updateSenatorSpeechesList($SenatorID, $chamberNo), + 'activity_senat_meetings' => $this->parseSenatorSpeechesList($SenatorID, $chamberNo), 'senator_statements' => self::BASE_URL . '/sklad/senatorowie/oswiadczenia-senatorskie,' . $SenatorID . ',' . $chamberNo . '.html', 'source' => $url ); @@ -652,7 +651,7 @@ public function urlSenatorsList() { * @return array * @throws ParserException */ - public function updateSenatorsList($chamberNo = null) { + public function parseSenatorsList($chamberNo = null) { if ($chamberNo === null) { $html = $this->curl_get($this->urlSenatorsList()); } else { @@ -707,19 +706,19 @@ public function getChecksumForInfo($inArray) { return md5(json_encode($inArray)); } - public function updateSenatorsAll() { - $list = $this->updateSenatorsList(); + public function parseSenatorsAll() { + $list = $this->parseSenatorsList(); foreach ($list as &$senator) { - $senator['info'] = $this->updateSenatorInfo($senator['id']); + $senator['info'] = $this->parseSenatorInfo($senator['id']); } return $list; } /** - * This will extract one speech from stenogram (from ::updateMeetingStenogram method), using given $speechRel. - * @param string $meetingTxt Output of ::updateMeetingStenogram + * This will extract one speech from stenogram (from ::parseMeetingStenogram method), using given $speechRel. + * @param string $meetingTxt Output of ::parseMeetingStenogram * @param string $speechRel Speech rel of Senator`s speech. * @param bool $removeMarszalekEtc When true (default) it will try to remove speeches of Marszałek and Wicemarszałek (as it would be introduce to next speech). * @return string @@ -778,7 +777,7 @@ public function getStenogram($id_sitting_with_day) { * @param string $meetingID Meeting ID. * @return string Text, witouh double spaces, HTML etc. */ - public function updateMeetingStenogram($meetingID) { + public function parseMeetingStenogram($meetingID) { $text = "\r\n"; $i = 0; do { @@ -809,7 +808,7 @@ public function updateMeetingStenogram($meetingID) { } // http://senat.gov.pl/prace/senat/posiedzenia/glosowanie-drukuj,368.html - public function updatePeopleVotes($url) { + public function parsePeopleVotes($url) { $html = $this->curl_get($url); $dom = str_get_html($html); @@ -891,7 +890,7 @@ public function urlMeetingsVotings($meetingID, $i) { return self::BASE_URL . '/prace/senat/posiedzenia/przebieg,' . $source_ids[0] . ',' . $i . ',glosowania.html'; } - public function updateMeetingVotings($meetingID) { + public function parseMeetingVotings($meetingID) { $ans = array(); $i = 0; @@ -955,7 +954,7 @@ public function updateMeetingVotings($meetingID) { * This will return list of all meetings * @return array ['id'=>ID of meeting, 'name'=>Name/title/subject of meeting. 'when'=>Date(s) of meeting(s)] */ - public function updateMeetingsList() { + public function parseMeetingsList() { $answer = array(); $i = 0;