Skip to content

Commit

Permalink
Merge pull request #152 from multnomah-county-it/dev
Browse files Browse the repository at this point in the history
Revised remove_url function
  • Loading branch information
john-c-houser authored Nov 5, 2024
2 parents 5bf0904 + 2ccb141 commit aeec165
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 36 deletions.
36 changes: 18 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions src/Libilsws.php
Original file line number Diff line number Diff line change
Expand Up @@ -1202,14 +1202,23 @@ public function get_hold ($token = null, $hold_key = null)
* Removes URLs from the trailing end of a string
*
* @param string $string String to be modifed
* @return string $string Modifed string
* @return string $string Modified string
*/

private function remove_url ($string)
{
$string = preg_replace('#^(.*)(http)(s*)(:\/\/)(.*)$#', '$1', $string);
$string = trim($string);

$words = preg_split("/[\s]+/", $string);
$new = [];

foreach ($words as $word) {
if ( !preg_match("#^(http)(s{0,1})(:\/\/)(.*)$#", $word) ) {
array_push($new, $word);
}
}

return trim($string);
return implode(' ', $new);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions test/register_patron.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
'language' => 'SOMALI',
'middleName' => 'T',
'notice_type' => 'PHONE',
'pin' => 'Waffles125',
'pin' => 'Waffles126',
'postal_code' => '97209',
'profile' => 'ONLINE',
'street' => '925 NW Hoyt St Apt 406',
'telephone' => '215-534-6821',
'street' => '925 NW Hoyt St Apt 408',
'telephone' => '215-534-6820',
'sms_phone' => [
'number' => '215-534-6821',
'number' => '215-534-6820',
'countryCode' => 'US',
'bills' => true,
'general' => true,
Expand Down
2 changes: 1 addition & 1 deletion test/register_staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'city_state' => 'Portland, OR',
'county' => '0_MULT',
'profile' => '0_MULT',
'patron_id' => '99999999999919',
'patron_id' => '99999999999922',
'email' => 'johnchouser@gmail.com',
'firstName' => 'Bogus',
'friends_notices' => 'YES',
Expand Down
24 changes: 14 additions & 10 deletions test/update_patron.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@
* which fields are required.
*/
$patron = [
'patron_id' => 'HOUSJOALAM12346',
'patron_id' => '21168045918653',
'birthDate' => '1962-03-07',
'city_state' => 'Portland, OR',
'city_state' => 'Astoria, OR',
'county' => '0_MULT',
'email' => 'johnchouser@gmail.com',
'firstName' => 'Bogus',
'firstName' => 'John',
'friends_notices' => 'YES',
'home_library' => 'CEN',
'language' => 'SPANISH',
'lastName' => 'Bogart',
'language' => 'ENGLISH',
'lastName' => 'Houser',
'library_news' => 'YES',
'middleName' => 'T',
'notice_type' => 'PHONE',
'middleName' => 'C',
'notice_type' => 'EMAIL',
'postal_code' => '97209',
'street' => '925 NW Hoyt St Apt 401',
'telephone' => '215-534-6821',
'street' => '225 Alameda Ave Apt 2',
'telephone' => 'a123',
'sms_phone' => [
'number' => '215-534-6821',
'number' => 'abc',
'countryCode' => 'US',
'bills' => true,
'general' => true,
Expand All @@ -49,6 +49,10 @@

$addr_num = 1;

$options = [];
$options['role'] = 'PATRON';
$options['client_id'] = 'SymWSTestClient';

$response = $ilsws->update_patron($patron, $token, $patron_key, $addr_num);
print_r($response);

Expand Down

0 comments on commit aeec165

Please sign in to comment.