right->getSource()); $this->allSourcesToWhichRightApplies = clone ($rightSourceMemberInformation->getAllMembers()); $this->allSourcesToWhichRightApplies->add($this->right->getSource()); } private function hasSource(SourceInterface $source): bool { return $this->allSourcesToWhichRightApplies->contains($source); } private function isLayerEqual(string $layer):bool{ return ($this->right->getLayer() === $layer); } private function isTypeEqual(string $type):bool{ return ($this->right->getType() === $type); } private function checkPermission():bool{ return $this->right->getGrant(); } public function __construct(RightInterface $right) { $this->right = $right; $this->setAllSourcesToWhichRightApplies(); } public function isGranted(string $layer, string $type, SourceInterface $source): bool { return ($this->isLayerEqual($layer) && $this->isTypeEqual($type) && $this->hasSource($source) && $this->checkPermission()); } }