Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
VuFindHighlighter | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getLink | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * Provide URL formatted as HTML and prefixed with proxy if applicable |
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 UrlHighlight |
25 | * @author Volodymyr Stelmakh <2980619+vstelmakh@users.noreply.github.com> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org/wiki/development Wiki |
28 | */ |
29 | |
30 | namespace VuFind\UrlHighlight; |
31 | |
32 | use VStelmakh\UrlHighlight\Highlighter\HtmlHighlighter; |
33 | use VStelmakh\UrlHighlight\Matcher\UrlMatch; |
34 | use VuFind\View\Helper\Root\ProxyUrl; |
35 | |
36 | /** |
37 | * Provide URL formatted as HTML and prefixed with proxy if applicable |
38 | * |
39 | * @category VuFind |
40 | * @package UrlHighlight |
41 | * @author Volodymyr Stelmakh <2980619+vstelmakh@users.noreply.github.com> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org/wiki/development Wiki |
44 | */ |
45 | class VuFindHighlighter extends HtmlHighlighter |
46 | { |
47 | public const DEFAULT_SCHEME = 'http'; |
48 | |
49 | /** |
50 | * Proxy url helper |
51 | * |
52 | * @var ProxyUrl |
53 | */ |
54 | protected $proxyUrl; |
55 | |
56 | /** |
57 | * Constructor |
58 | * |
59 | * @param ProxyUrl $proxyUrl Proxy url helper |
60 | */ |
61 | public function __construct(ProxyUrl $proxyUrl) |
62 | { |
63 | $this->proxyUrl = $proxyUrl; |
64 | parent::__construct(self::DEFAULT_SCHEME); |
65 | } |
66 | |
67 | /** |
68 | * Return url with proxy |
69 | * |
70 | * @param UrlMatch $match url highlight match |
71 | * |
72 | * @return string |
73 | */ |
74 | protected function getLink(UrlMatch $match): string |
75 | { |
76 | $link = parent::getLink($match); |
77 | return ($this->proxyUrl)($link); |
78 | } |
79 | } |