Clickable final class
Minn\Content\Clickable · public/minn/src/Minn/Content/Clickable.php · 64 lines
Bare addresses in text made links (make_clickable, probe formatting-callbacks). Only text is read, never tags or comments, and nothing inside code, pre, script or style. An address must start the text or follow whitespace or "("; trailing . , ; : ! ? stay outside it. URLs (http, https, ftp) are found first, then www. and ftp. hosts, then email addresses; each is handed to its callback, which builds the link. A link made as the whole text of an existing link is unwrapped into it.
Constants and properties
| private | SKIP = 'code|pre|script|style' | |
| private | BEFORE = '(^|[\\s(])' | |
| private | TRAILING = '([.,;:!?]*)(?=[\\s<>"]|$)' |
Public
| static | make(string $text, Closure $url, Closure $web, Closure $email): string# | The text with its addresses made links: $url gets [whole, before, address, trailing], $web the same for a www. or ftp. host, $email [whole, before, user, domain].
| |||||||||
| static | unbalancedClosers(string $url): array# | A URL's trailing ")" taken off while the URL closes more parentheses than it opens: [the URL, what was taken off]. @return array{0: string, 1: string} |
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
Nothing matches.