Lines 100.00% 13 / 13
Methods 100.00% 1 / 1
Classes 100.00% 1 / 1
Covered by tests of size
Name Lines Methods CRAP
 build 100.00% 13 / 13 100.00% 1 / 1 3
24final 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}