IsActive::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Adlogix package.
5
 *
6
 * (c) Allan Segebarth <[email protected]>
7
 * (c) Jean-Jacques Courtens <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Adlogix\Zf2Rollout\View\Helper;
14
15
use Opensoft\Rollout\Rollout;
16
use Opensoft\Rollout\RolloutUserInterface;
17
use Zend\View\Helper\AbstractHelper;
18
19
/**
20
 * Rollout helper class which will allow in templates to check if
21
 * a specific feature is active for a given RolloutUserInterface or not.
22
 *
23
 * @author Toni Van de Voorde <[email protected]>
24
 */
25
class IsActive extends AbstractHelper
26
{
27
    /**
28
     * @var Rollout
29
     */
30
    private $rollout;
31
32
    public function __construct(Rollout $rollout)
33
    {
34
        $this->rollout = $rollout;
35
    }
36
37
    /**
38
     * Checks if a feature is active for a given RolloutUserInterface
39
     *
40
     * @param string                    $feature
41
     * @param RolloutUserInterface|null $user
42
     *
43
     * @return bool
44
     */
45
    public function __invoke($feature, RolloutUserInterface $user = null)
46
    {
47
        return $this->rollout->isActive($feature, $user);
48
    }
49
}