CoinhiveMinerExtension::coinhiveMiner()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace CoinhiveBundle\Twig\Extensions;
4
5
use Twig_Environment;
6
7
/**
8
 * Class WidgetExtension.
9
 */
10
class CoinhiveMinerExtension extends \Twig_Extension
11
{
12
    /**
13
     * @var
14
     */
15
    private $siteKey;
16
17
    /**
18
     * WidgetExtension constructor.
19
     * @param $siteKey
20
     * @internal param $key
21
     */
22
    public function __construct(
23
        $siteKey
24
    )
25
    {
26
27
        $this->siteKey = $siteKey;
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    public function getFunctions()
34
    {
35
        return array(
36
            new \Twig_SimpleFunction('coinhive_miner', [$this, 'coinhiveMiner'], [
37
                'is_safe' => ['html'],
38
                'needs_environment' => true,
39
            ]),
40
        );
41
    }
42
43
    /**
44
     * @param Twig_Environment $env
45
     * @return mixed
46
     */
47
    public function coinhiveMiner(Twig_Environment $env)
48
    {
49
        return $env->render(
50
            'CoinhiveBundle::coinhive_miner.html.twig',
51
            [
52
                'site_key' => $this->siteKey,
53
            ]
54
        );
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function getName()
61
    {
62
        return 'coinhive_miner';
63
    }
64
}
65