Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| NewsStrategy | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| build | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Building News URL segments for phpMyFAQ Link rewriting. |
| 5 | * |
| 6 | * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 7 | * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 8 | * obtain one at https://mozilla.org/MPL/2.0/. |
| 9 | * |
| 10 | * @package phpMyFAQ |
| 11 | * @author Thorsten Rinne <thorsten@phpmyfaq.de> |
| 12 | * @copyright 2025 phpMyFAQ Team |
| 13 | * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
| 14 | * @link https://www.phpmyfaq.de |
| 15 | * @since 2025-11-08 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace phpMyFAQ\Link\Strategy; |
| 21 | |
| 22 | use phpMyFAQ\Link; |
| 23 | |
| 24 | final class NewsStrategy implements StrategyInterface |
| 25 | { |
| 26 | /** |
| 27 | * @param array<string,string> $params |
| 28 | */ |
| 29 | public function build(array $params, Link $link): string |
| 30 | { |
| 31 | if (!array_key_exists(Link::LINK_GET_NEWS_ID, $params)) { |
| 32 | throw new \InvalidArgumentException('Missing required parameter: newsid'); |
| 33 | } |
| 34 | |
| 35 | if (!array_key_exists(Link::LINK_GET_NEWS_LANG, $params)) { |
| 36 | throw new \InvalidArgumentException('Missing required parameter: newslang'); |
| 37 | } |
| 38 | |
| 39 | return ( |
| 40 | Link::LINK_NEWS |
| 41 | . $params[Link::LINK_GET_NEWS_ID] |
| 42 | . Link::LINK_HTML_SLASH |
| 43 | . $params[Link::LINK_GET_NEWS_LANG] |
| 44 | . Link::LINK_SLASH |
| 45 | . $link->getSEOTitle() |
| 46 | . Link::LINK_HTML_EXTENSION |
| 47 | ); |
| 48 | } |
| 49 | } |