Issues (2551)

src/Impl/AuthorizationServiceImpl.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Jabe\Impl;
4
5
use Jabe\AuthorizationServiceInterface;
6
use Jabe\Authorization\{
7
    AuthorizationInterface,
8
    AuthorizationQueryInterface,
9
    PermissionInterface,
10
    ResourceInterface
11
};
12
use Jabe\Impl\Cmd\{
13
    AuthorizationCheckCmd,
14
    CreateAuthorizationCommand,
15
    DeleteAuthorizationCmd,
16
    SaveAuthorizationCmd
17
};
18
19
class AuthorizationServiceImpl extends ServiceImpl implements AuthorizationServiceInterface
20
{
21
    public function createAuthorizationQuery(): AuthorizationQueryInterface
22
    {
23
        return new AuthorizationQueryImpl($this->commandExecutor);
24
    }
25
26
    public function createNewAuthorization(int $type): AuthorizationInterface
27
    {
28
        return $this->commandExecutor->execute(new CreateAuthorizationCommand($type));
29
    }
30
31
    public function saveAuthorization(AuthorizationInterface $authorization): AuthorizationInterface
32
    {
33
        return $this->commandExecutor->execute(new SaveAuthorizationCmd($authorization));
34
    }
35
36
    public function deleteAuthorization(string $authorizationId): void
37
    {
38
        $this->commandExecutor->execute(new DeleteAuthorizationCmd($authorizationId));
39
    }
40
41
    public function isUserAuthorized(string $userId, array $groupIds, PermissionInterface $permission, ResourceInterface $resource, string $resourceId = null): bool
42
    {
43
        return $this->commandExecutor->execute(new AuthorizationCheckCmd($userId, $groupIds, $permission, $resource, $resourceId));
0 ignored issues
show
It seems like $resourceId can also be of type null; however, parameter $resourceId of Jabe\Impl\Cmd\AuthorizationCheckCmd::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
        return $this->commandExecutor->execute(new AuthorizationCheckCmd($userId, $groupIds, $permission, $resource, /** @scrutinizer ignore-type */ $resourceId));
Loading history...
44
    }
45
}
46