SyntaxHighlighterProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSyntaxHighlighterStrings() 0 14 1
A translate() 0 2 1
A __construct() 0 2 1
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\Provider;
13
14
use Symfony\Contracts\Translation\TranslatorInterface;
15
use WBW\Bundle\CoreBundle\Assets\SyntaxHighlighter\SyntaxHighlighterStrings;
16
use WBW\Bundle\CoreBundle\Translation\TranslatorTrait;
17
use WBW\Bundle\CoreBundle\WBWCoreBundle;
18
19
/**
20
 * SyntaxHighlighter provider.
21
 *
22
 * @author webeweb <https://github.com/webeweb>
23
 * @package WBW\Bundle\CoreBundle\Provider
24
 */
25
class SyntaxHighlighterProvider implements SyntaxHighlighterProviderInterface {
26
27
    use TranslatorTrait;
28
29
    /**
30
     * Service name.
31
     *
32
     * @var string
33
     */
34
    const SERVICE_NAME = "wbw.core.provider.syntax_highlighter";
35
36
    /**
37
     * Constructor.
38
     *
39
     * @param TranslatorInterface $translator The translator.
40
     */
41
    public function __construct(TranslatorInterface $translator) {
42
        $this->setTranslator($translator);
43
    }
44
45
    /**
46
     * Get a strings.
47
     *
48
     * @return SyntaxHighlighterStrings Returns the strings.
49
     */
50
    public function getSyntaxHighlighterStrings(): SyntaxHighlighterStrings {
51
52
        $strings = new SyntaxHighlighterStrings();
53
        $strings->setAlert($this->translate("syntax_highlighter.strings.alert"));
54
        $strings->setBrushNotHtmlScript($this->translate("syntax_highlighter.strings.brush_no_html_script"));
55
        $strings->setCopyToClipboard($this->translate("syntax_highlighter.strings.copy_to_clipboard"));
56
        $strings->setCopyToClipboardConfirmation($this->translate("syntax_highlighter.strings.copy_to_clipboard_confirmation"));
57
        $strings->setExpandSource($this->translate("syntax_highlighter.strings.expand_source"));
58
        $strings->setHelp($this->translate("syntax_highlighter.strings.help"));
59
        $strings->setNoBrush($this->translate("syntax_highlighter.strings.no_brush"));
60
        $strings->setPrint($this->translate("syntax_highlighter.strings.print"));
61
        $strings->setViewSource($this->translate("syntax_highlighter.strings.view_source"));
62
63
        return $strings;
64
    }
65
66
    /**
67
     * Translate.
68
     *
69
     * @param string $id The id.
70
     * @return string Returns the translation.
71
     */
72
    protected function translate(string $id): string {
73
        return $this->getTranslator()->trans($id, [], WBWCoreBundle::getTranslationDomain());
74
    }
75
}
76