Passed
Push — master ( 732152...809fdb )
by Florian
03:32
created

EventVoter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 3
dl 0
loc 27
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 3 1
A voteOnAttribute() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the feedback project.
5
 *
6
 * (c) Florian Moser <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Security\Voter;
13
14
use App\Entity\Event;
15
use App\Security\Voter\Base\BaseVoter;
16
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
17
18
class EventVoter extends BaseVoter
19
{
20
    /**
21
     * @param string $attribute An attribute
22
     * @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type
23
     *
24
     * @return bool True if the attribute and subject are supported, false otherwise
25
     */
26
    protected function supports($attribute, $subject)
27
    {
28
        return $subject instanceof Event;
29
    }
30
31
    /**
32
     * Perform a single access check operation on a given attribute, subject and token.
33
     * It is safe to assume that $attribute and $subject already passed the "supports()" method check.
34
     *
35
     * @param string $attribute
36
     * @param Event $subject
37
     * @param TokenInterface $token
38
     *
39
     * @return bool
40
     */
41
    protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
42
    {
43
        //check if own clinic
44
        return !$subject->feedbackHasStarted();
45
    }
46
}
47