protected function getMatchingAuthzGroup($permissionAuthzGroup, array $authzGroups)
    {
        $invert = $this->stringStartsWith($permissionAuthzGroup, '!');
        
        if ($invert) {
            $permissionAuthzGroup = substr($permissionAuthzGroup, 1);
        }
        
        $matches = [];
        
        foreach ($authzGroups as $authzGroup) {
            $match = $this->authzGroupsAreEqual($permissionAuthzGroup, $authzGroup);
            
            if ($match && $invert) {
                return null;
            }
            
            if ($match && !$invert || !$match && $invert) {
                $matches[] = $authzGroup;
            }
        }
        
        return !empty($matches) ? $matches[0] : null;
    }