BrandingRuntime   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 52
rs 10
c 2
b 0
f 1
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getSiteSlogan() 0 3 1
A __construct() 0 4 1
A getSiteDefinition() 0 3 1
A getSiteImagePath() 0 9 2
A getSiteName() 0 3 1
A getSiteBrandingMarkup() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\ThemeBundle\Twig\Runtime;
15
16
use Twig\Environment;
17
use Twig\Extension\RuntimeExtensionInterface;
18
use Zikula\CoreBundle\Site\SiteDefinitionInterface;
19
20
class BrandingRuntime implements RuntimeExtensionInterface
21
{
22
    public function __construct(
23
        private readonly Environment $twig,
24
        private readonly SiteDefinitionInterface $site
25
    ) {
26
    }
27
28
    /**
29
     * Returns site definition.
30
     */
31
    public function getSiteDefinition(): SiteDefinitionInterface
32
    {
33
        return $this->site;
34
    }
35
36
    /**
37
     * Returns site name.
38
     */
39
    public function getSiteName(): string
40
    {
41
        return $this->site->getName();
42
    }
43
44
    /**
45
     * Returns site slogan.
46
     */
47
    public function getSiteSlogan(): string
48
    {
49
        return $this->site->getSlogan();
50
    }
51
52
    /**
53
     * Returns site branding markup.
54
     */
55
    public function getSiteBrandingMarkup(): string
56
    {
57
        return $this->twig->render('@ZikulaTheme/Branding/manifest.html.twig');
58
    }
59
60
    /**
61
     * Returns site image path.
62
     */
63
    public function getSiteImagePath(string $imageType = ''): string
64
    {
65
        if (!in_array($imageType, ['logo', 'mobileLogo', 'icon'], true)) {
66
            $imageType = 'logo';
67
        }
68
69
        $accessor = 'get' . ucfirst($imageType) . 'Path';
70
71
        return $this->site->{$accessor}();
72
    }
73
}
74