Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Linkify | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__invoke | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * Linkify a string so that the links become clickable HTML |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) The National Library of Finland 2020. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package View_Helpers |
25 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
26 | * @author Volodymyr Stelmakh <2980619+vstelmakh@users.noreply.github.com> |
27 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
28 | * @link https://vufind.org/wiki/development Wiki |
29 | */ |
30 | |
31 | namespace VuFind\View\Helper\Root; |
32 | |
33 | use Laminas\View\Helper\AbstractHelper; |
34 | use VStelmakh\UrlHighlight\UrlHighlight; |
35 | |
36 | /** |
37 | * Linkify a string so that the links become clickable HTML |
38 | * |
39 | * @category VuFind |
40 | * @package View_Helpers |
41 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
42 | * @author Volodymyr Stelmakh <2980619+vstelmakh@users.noreply.github.com> |
43 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
44 | * @link https://vufind.org/wiki/development Wiki |
45 | */ |
46 | class Linkify extends AbstractHelper |
47 | { |
48 | /** |
49 | * Url highlighter |
50 | * |
51 | * @var UrlHighlight |
52 | */ |
53 | protected $urlHighlight; |
54 | |
55 | /** |
56 | * Constructor |
57 | * |
58 | * @param UrlHighlight $urlHighlight Url highlighter |
59 | */ |
60 | public function __construct(UrlHighlight $urlHighlight) |
61 | { |
62 | $this->urlHighlight = $urlHighlight; |
63 | } |
64 | |
65 | /** |
66 | * Replace urls and emails by html tags |
67 | * |
68 | * @param string $string String to linkify (must be HTML-escaped) |
69 | * |
70 | * @return string |
71 | */ |
72 | public function __invoke(string $string): string |
73 | { |
74 | return $this->urlHighlight->highlightUrls($string); |
75 | } |
76 | } |