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