[TASK] MailUtility: Add function extractByType

This commit is contained in:
Philipp Dieter 2022-03-24 18:06:06 +01:00
parent 599dc81f7a
commit 94a7c42289

View File

@ -128,6 +128,28 @@ class MailUtility
return $result; return $result;
} }
/**
* Gets row from content by given type
*
* @param array $content the mail content
* @param string $type the type to search
*/
public static function extractByType($content, $type)
{
$elementPosition = array_search(
$type,
array_column($content, 'type')
);
if (!$elementPosition === false) {
return;
}
if (!array_key_exists('data', $content[$elementPosition])) {
return;
}
return $content[$elementPosition]['data'];
}
/** /**
* tages maildata, builds html and text mails an decides where to send them * tages maildata, builds html and text mails an decides where to send them
* allows to intercept sender for testing * allows to intercept sender for testing