Lines 100.00% 23 / 23
Methods 100.00% 11 / 11
Classes 100.00% 1 / 1
Covered by tests of size
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 getCategoryId 100.00% 1 / 1 100.00% 1 / 1 1
 setCategoryId 100.00% 1 / 1 100.00% 1 / 1 1
 getFaqId 100.00% 1 / 1 100.00% 1 / 1 1
 setFaqId 100.00% 1 / 1 100.00% 1 / 1 1
 getLanguage 100.00% 1 / 1 100.00% 1 / 1 1
 setLanguage 100.00% 1 / 1 100.00% 1 / 1 1
 getQuestion 100.00% 1 / 1 100.00% 1 / 1 1
 setQuestion 100.00% 1 / 1 100.00% 1 / 1 1
 getPdfLink 100.00% 7 / 7 100.00% 1 / 1 1
 getPdfApiLink 100.00% 7 / 7 100.00% 1 / 1 1
27class Services
28{
29    /**
30     * FAQ ID.
31     */
32    protected int $faqId;
33
34    /**
35     * Entity ID.
36     */
37    protected int $categoryId;
38
39    /**
40     * Language.
41     */
42    protected string $language;
43
44    /**
45     * Question of the FAQ.
46     */
47    protected string $question;
48
49    /**
50     * Constructor.
51     */
52    public function __construct(
53        private readonly Configuration $configuration,
54    ) {
55    }
56
57    public function getCategoryId(): int
58    {
59        return $this->categoryId;
60    }
61
62    public function setCategoryId(int $categoryId): void
63    {
64        $this->categoryId = $categoryId;
65    }
66
67    public function getFaqId(): int
68    {
69        return $this->faqId;
70    }
71
72    public function setFaqId(int $faqId): void
73    {
74        $this->faqId = $faqId;
75    }
76
77    public function getLanguage(): string
78    {
79        return $this->language;
80    }
81
82    public function setLanguage(string $language): void
83    {
84        $this->language = $language;
85    }
86
87    public function getQuestion(): string
88    {
89        return urlencode(trim($this->question));
90    }
91
92    public function setQuestion(string $question): void
93    {
94        $this->question = $question;
95    }
96
97    /**
98     * Returns the "Show FAQ as PDF" URL.
99     */
100    public function getPdfLink(): string
101    {
102        return sprintf(
103            '%spdf/%d/%d/%s',
104            $this->configuration->getDefaultUrl(),
105            $this->getCategoryId(),
106            $this->getFaqId(),
107            $this->getLanguage(),
108        );
109    }
110
111    /**
112     * Returns the "Show FAQ as PDF" URL.
113     */
114    public function getPdfApiLink(): string
115    {
116        return sprintf(
117            '%spdf/%d/%d/%s',
118            $this->configuration->getDefaultUrl(),
119            $this->getCategoryId(),
120            $this->getFaqId(),
121            $this->getLanguage(),
122        );
123    }
124}