| Total Complexity | 5 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 85.71% |
| Changes | 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 | /** |
||
| 27 | * @param FeatureManager $manager |
||
| 28 | * @param FeatureSecurity $security |
||
| 29 | */ |
||
| 30 | 5 | public function __construct( |
|
| 36 | 5 | } |
|
| 37 | |||
| 38 | /** |
||
| 39 | * Check if a feature (defined by name/parent) is granted to the logged user. |
||
| 40 | * |
||
| 41 | * @param string $name |
||
| 42 | * @param string $parent |
||
| 43 | * |
||
| 44 | * @return bool |
||
| 45 | */ |
||
| 46 | 2 | public function isGranted($name, $parent) |
|
| 47 | { |
||
| 48 | try { |
||
| 49 | 2 | return $this->security->isGranted( |
|
| 50 | 2 | $this->manager->find($name, $parent) |
|
| 51 | ); |
||
| 52 | } catch (Exception $exception) { |
||
| 53 | return false; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | 3 | public function isGrantedForUser(string $name, string $parent, UserInterface $user): bool |
|
| 66 | } |
||
| 67 | } |
||
| 68 |