Lines 95.23% 20 / 21
Methods 80.00% 4 / 5
Classes 0.00% 0 / 1
Covered by tests of size
Name Lines Methods CRAP
 getScopeEntityByIdentifier 94.11% 16 / 17 0.00% 0 / 1 4.00
 finalizeScopes 100.00% 1 / 1 100.00% 1 / 1 1
 [phpMyFAQ\Auth\OAuth2\Repository\AbstractRepository] __construct 100.00% 1 / 1 100.00% 1 / 1 1
 [phpMyFAQ\Auth\OAuth2\Repository\AbstractRepository] db 100.00% 1 / 1 100.00% 1 / 1 1
 [phpMyFAQ\Auth\OAuth2\Repository\AbstractRepository] table 100.00% 1 / 1 100.00% 1 / 1 1
27final class ScopeRepository extends AbstractRepository implements ScopeRepositoryInterface
28{
29    public function getScopeEntityByIdentifier(string $identifier): ?ScopeEntityInterface
30    {
31        $query = sprintf(
32            "SELECT scope_id FROM %s WHERE scope_id = '%s'",
33            $this->table('faqoauth_scopes'),
34            $this->db()->escape($identifier),
35        );
36
37        $result = $this->db()->query($query);
38        if ($result === false) {
39            return null;
40        }
41
42        $row = $this->db()->fetchObject($result);
43        if (!is_object($row)) {
44            return null;
45        }
46
47        $scopeIdentifier = (string) $row->scope_id;
48        if ($scopeIdentifier === '') {
49            return null;
50        }
51
52        $scope = new ScopeEntity();
53        $scope->setIdentifier($scopeIdentifier);
54
55        return $scope;
56    }
57
58    public function finalizeScopes(
59        array $scopes,
60        string $grantType,
61        ClientEntityInterface $clientEntity,
62        ?string $userIdentifier = null,
63        ?string $authCodeId = null,
64    ): array {
65        return $scopes;
66    }
67}

Inherited from phpMyFAQ\Auth\OAuth2\Repository\AbstractRepository

28    public function __construct(
29        protected readonly Configuration $configuration,
30    ) {
31    }
33    protected function db(): DatabaseDriver
34    {
35        return $this->configuration->getDb();
36    }
38    protected function table(string $tableName): string
39    {
40        return Database::getTablePrefix() . $tableName;
41    }