Skip to content

Commit

Permalink
[DRKBlutspendeBridge] move explode_lines into DRKBlutspendeBridge class
Browse files Browse the repository at this point in the history
  • Loading branch information
User123698745 committed Nov 24, 2024
1 parent 083406c commit 260dfe7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 10 additions & 2 deletions bridges/DRKBlutspendeBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ protected function parseItem(array $item)
$detailsElement = $html->find('.details', 0);

$dateElement = $detailsElement->find('.datum', 0);
$dateLines = explode_lines($dateElement->plaintext);
$dateLines = self::explode_lines($dateElement->plaintext);

$addressElement = $detailsElement->find('.adresse', 0);
$addressLines = explode_lines($addressElement->plaintext);
$addressLines = self::explode_lines($addressElement->plaintext);

$infoElement = $detailsElement->find('.angebote > h4 + p', 0);
$info = $infoElement ? $infoElement->innertext : '';
Expand Down Expand Up @@ -96,4 +96,12 @@ private function buildAppointmentsURI()
$dateTo = $limitDays > 0 ? date('Y-m-d', time() + (60 * 60 * 24 * $limitDays)) : '';
return self::BASE_URI . '/blutspendetermine/termine.rss?date_to=' . $dateTo . '&radius=' . $radius . '&term=' . $term;
}

/**
* Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by line breaks.
*/
private function explode_lines(string $text): array
{
return array_map('trim', preg_split('/(\s*(\r\n|\n|\r)\s*)+/', $text));
}
}
8 changes: 0 additions & 8 deletions lib/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ function is_html(string $text): bool
return strlen(strip_tags($text)) !== strlen($text);
}

/**
* Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by line breaks.
*/
function explode_lines(string $text): array
{
return array_map('trim', preg_split('/(\s*(\r\n|\n|\r)\s*)+/', $text));
}

/**
* Determines the MIME type from a URL/Path file extension.
*
Expand Down

0 comments on commit 260dfe7

Please sign in to comment.