Repository: appwrite/appwrite
File: src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php (PHP)

Code before:
                name: 'getResource',
                description: <<<EOT
                Check if a resource ID is available.
                EOT,
                auth: [AuthType::ADMIN],
                responses: [
                    new SDKResponse(
                        code: Response::STATUS_CODE_NOCONTENT,
                        model: Response::MODEL_NONE,
                    )
                ],
                contentType: ContentType::NONE,
            ))
            ->label('abuse-limit', 10)
            ->label('abuse-key', 'userId:{userId}, url:{url}')
            ->label('abuse-time', 60)
            ->param('value', '', new Text(256), 'Resource value.')
            ->param('type', '', new WhiteList(['rules']), 'Resource type.')
            ->inject('response')
            ->inject('dbForPlatform')
            ->callback([$this, 'action']);
    }

    public function action(string $value, string $type, Response $response, Database $dbForPlatform)
    {
        if ($type == 'rules') {
            $validator = new Domain($value);

            if (!$validator->isValid($value)) {
                throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, $validator->getDescription());
            }

            $document = Authorization::skip(fn () => $dbForPlatform->findOne('rules', [
                Query::equal('domain', [$value]),
            ]));

            if (!$document->isEmpty()) {
                throw new Exception(Exception::RESOURCE_ALREADY_EXISTS);
            }

            $response->noContent();
        }

        throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid type');
    }
}


Review comment (suggestion):
```suggestion
        if ($type === 'rules') {
```

Code after:
                name: 'getResource',
                description: <<<EOT
                Check if a resource ID is available.
                EOT,
                auth: [AuthType::ADMIN],
                responses: [
                    new SDKResponse(
                        code: Response::STATUS_CODE_NOCONTENT,
                        model: Response::MODEL_NONE,
                    )
                ],
                contentType: ContentType::NONE,
            ))
            ->label('abuse-limit', 10)
            ->label('abuse-key', 'userId:{userId}, url:{url}')
            ->label('abuse-time', 60)
            ->param('value', '', new Text(256), 'Resource value.')
            ->param('type', '', new WhiteList(['rules']), 'Resource type.')
            ->inject('response')
            ->inject('dbForPlatform')
            ->callback([$this, 'action']);
    }

    public function action(string $value, string $type, Response $response, Database $dbForPlatform)
    {
        if ($type === 'rules') {
            $validator = new Domain($value);

            if (!$validator->isValid($value)) {
                throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, $validator->getDescription());
            }

            $document = Authorization::skip(fn () => $dbForPlatform->findOne('rules', [
                Query::equal('domain', [$value]),
            ]));

            if (!$document->isEmpty()) {
                throw new Exception(Exception::RESOURCE_ALREADY_EXISTS);
            }

            $response->noContent();
        }

        // Only occurs if type is added into whitelist, but not supported in action
        throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid type');
    }
}