From 7e6c58b67a6ef6b3cd6aaca109e1bcf245f52e57 Mon Sep 17 00:00:00 2001 From: Joseph Date: Sat, 6 Jul 2019 09:55:31 +0000 Subject: [PATCH] [HaveIBeenPwnedBridge] Display breach type (#1203) * Extract breach types for each data breach * Add paragraph tag --- bridges/HaveIBeenPwnedBridge.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/bridges/HaveIBeenPwnedBridge.php b/bridges/HaveIBeenPwnedBridge.php index caf73f31..1eb62e32 100644 --- a/bridges/HaveIBeenPwnedBridge.php +++ b/bridges/HaveIBeenPwnedBridge.php @@ -58,8 +58,9 @@ class HaveIBeenPwnedBridge extends BridgeAbstract { $item['breachDate'] = strtotime($breachDate[1]); $item['uri'] = self::URI . '/PwnedWebsites' . $permalink; - $item['content'] = '

' . $breach->find('p', 0)->innertext . '

'; - $item['content'] .= '

' . $breach->find('p', 1)->innertext . '

'; + $item['content'] = '

' . $breach->find('p', 0)->innertext . '

'; + $item['content'] .= '

' . $this->breachType($breach) . '

'; + $item['content'] .= '

' . $breach->find('p', 1)->innertext . '

'; $this->breaches[] = $item; } @@ -68,6 +69,25 @@ class HaveIBeenPwnedBridge extends BridgeAbstract { $this->createItems(); } + /** + * Extract data breach type(s) + */ + private function breachType($breach) { + + $content = ''; + + if ($breach->find('h3 > i', 0)) { + + foreach ($breach->find('h3 > i') as $i) { + $content .= $i->title . '.
'; + } + + } + + return $content; + + } + /** * Order Breaches by date added or date breached */