Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
Feature
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
7 / 7
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isAvailable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getGroup
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNameKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDescriptionKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MobileFrontend\Features;
4
5/**
6 * @package MobileFrontend\Features
7 */
8class Feature implements IFeature {
9
10    private const DEFAULT_ENABLED_MODE = false;
11    /**
12     * @var string
13     */
14    private $name;
15    /**
16     * Feature group (mobile-frontend, minerva, ...)
17     * @var string
18     */
19    private $group;
20    /**
21     * @var array
22     */
23    private $options;
24
25    /**
26     * @param string $name feature name (used as an ID)
27     * @param string $group feature group (used as a translation prefix)
28     * @param array $options Feature options
29     */
30    public function __construct( $name, $group = 'mobile-frontend', array $options = [] ) {
31        $this->name = $name;
32        $this->group = $group;
33        $this->options = $options;
34    }
35
36    /**
37     * @inheritDoc
38     */
39    public function __toString() {
40        return $this->name;
41    }
42
43    /**
44     * @inheritDoc
45     */
46    public function isAvailable( IUserMode $userMode ) {
47        return $this->options[ $userMode->getModeIdentifier() ] ?? self::DEFAULT_ENABLED_MODE;
48    }
49
50    /**
51     * @inheritDoc
52     */
53    public function getId() {
54        return $this->name;
55    }
56
57    /**
58     * @inheritDoc
59     */
60    public function getGroup() {
61        return $this->group;
62    }
63
64    /**
65     * @inheritDoc
66     */
67    public function getNameKey() {
68        return $this->group . '-mobile-option-' . $this->name;
69    }
70
71    /**
72     * @inheritDoc
73     */
74    public function getDescriptionKey() {
75        return $this->group . '-mobile-option-' . $this->name . '-description';
76    }
77}