Issues (14)

src/Security/ClientRelatedEntityVoter.php (7 issues)

1
<?php
2
3
/*
4
 * This file is part of the ClanManager package.
5
 * (c) Fluxter <https://fluxter.net/>
6
 * Found us at <https://clanmanager.net>
7
 */
8
9
namespace Fluxter\SaasProviderBundle\Security;
10
11
use Fluxter\SaasProviderBundle\Model\SaasClientRelatedInterface;
12
use Fluxter\SaasProviderBundle\Service\SaasClientService;
13
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
0 ignored issues
show
The type Symfony\Component\Securi...on\Token\TokenInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
0 ignored issues
show
The type Symfony\Component\Securi...thorization\Voter\Voter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
0 ignored issues
show
The type Symfony\Component\Securi...on\Voter\VoterInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
class ClientRelatedEntityVoter extends Voter
18
{
19
    private SaasClientService $_clientService;
20
21
    public function __construct(SaasClientService $clientService)
22
    {
23
        $this->_clientService = $clientService;
24
    }
25
26
    protected function supports($attribute, $subject)
27
    {
28
        if (!$subject instanceof SaasClientRelatedInterface) {
29
            return false;
30
        }
31
32
        return true;
33
    }
34
35
    /**
36
     * @param string                     $attribute
37
     * @param SaasClientRelatedInterface $subject
38
     *
39
     * @return void
40
     */
41
    protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
42
    {
43
        if (!$this->_clientService->getCurrentClient()) {
44
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type void.
Loading history...
45
        }
46
47
        if ($subject->getClient() == null) {
48
            return true;
0 ignored issues
show
Bug Best Practice introduced by
The expression return true returns the type true which is incompatible with the documented return type void.
Loading history...
49
        }
50
51
        if ($this->_clientService->getCurrentClient() == $subject->getClient()) {
52
            return true;
0 ignored issues
show
Bug Best Practice introduced by
The expression return true returns the type true which is incompatible with the documented return type void.
Loading history...
53
        }
54
55
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type void.
Loading history...
56
    }
57
}
58