Total Complexity | 5 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 85.71% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | class Feature implements FeatureInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var FeatureManager |
||
18 | */ |
||
19 | protected $manager; |
||
20 | |||
21 | /** |
||
22 | * @var FeatureSecurity |
||
23 | */ |
||
24 | protected $security; |
||
25 | |||
26 | 5 | public function __construct( |
|
32 | 5 | } |
|
33 | |||
34 | /** |
||
35 | * Check if a feature (defined by name/parent) is granted to the logged user. |
||
36 | * |
||
37 | * @param string $name |
||
38 | * @param string $parent |
||
39 | * |
||
40 | * @return bool |
||
41 | */ |
||
42 | 2 | public function isGranted($name, $parent) |
|
43 | { |
||
44 | try { |
||
45 | 2 | return $this->security->isGranted( |
|
46 | 2 | $this->manager->find($name, $parent) |
|
47 | ); |
||
48 | } catch (Exception $exception) { |
||
49 | return false; |
||
50 | } |
||
51 | } |
||
52 | |||
53 | 3 | public function isGrantedForUser(string $name, string $parent, UserInterface $user): bool |
|
62 | } |
||
63 | } |
||
64 |