Lines 100.00% 10 / 10
Methods 100.00% 6 / 6
Classes 100.00% 1 / 1
Covered by tests of size
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 create 100.00% 1 / 1 100.00% 1 / 1 1
 get 100.00% 1 / 1 100.00% 1 / 1 1
 update 100.00% 1 / 1 100.00% 1 / 1 1
 delete 100.00% 1 / 1 100.00% 1 / 1 1
 getMetaRobots 100.00% 5 / 5 100.00% 1 / 1 5
33readonly class Seo
34{
35    private SeoRepositoryInterface $seoRepository;
36
37    public function __construct(
38        private Configuration $configuration,
39        ?SeoRepositoryInterface $seoRepository = null,
40    ) {
41        $this->seoRepository = $seoRepository ?? new SeoRepository($this->configuration);
42    }
43
44    /**
45     * @return bool True if the SEO entity was created
46     */
47    public function create(SeoEntity $seoEntity): bool
48    {
49        return $this->seoRepository->create($seoEntity);
50    }
51
52    /**
53     * @throws Exception
54     */
55    public function get(SeoEntity $seoEntity): SeoEntity
56    {
57        return $this->seoRepository->get($seoEntity);
58    }
59
60    /**
61     * @return bool True if the SEO entity was updated
62     */
63    public function update(SeoEntity $seoEntity): bool
64    {
65        return $this->seoRepository->update($seoEntity);
66    }
67
68    /**
69     * @return bool True if the SEO entity was deleted
70     */
71    public function delete(SeoEntity $seoEntity): bool
72    {
73        return $this->seoRepository->delete($seoEntity);
74    }
75
76    public function getMetaRobots(string $action): string
77    {
78        return (string) match ($action) {
79            'main' => $this->configuration->get(item: 'seo.metaTagsHome'),
80            'faq' => $this->configuration->get(item: 'seo.metaTagsFaqs'),
81            'show' => $this->configuration->get(item: 'seo.metaTagsCategories'),
82            default => $this->configuration->get(item: 'seo.metaTagsPages'),
83        };
84    }
85}