Failed Conditions
Push — master ( 476087...9b9b51 )
by Florent
11:32
created

RevokePreConfiguredAuthorizationCommandHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 14 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Component\Server\Command\PreConfiguredAuthorization;
15
16
use OAuth2Framework\Component\Server\Model\PreConfiguredAuthorization\PreConfiguredAuthorizationRepositoryInterface;
17
18
final class RevokePreConfiguredAuthorizationCommandHandler
19
{
20
    /**
21
     * @var PreConfiguredAuthorizationRepositoryInterface
22
     */
23
    private $preConfiguredAuthorizationRepository;
24
25
    /**
26
     * RevokeClientCommandHandler constructor.
27
     *
28
     * @param PreConfiguredAuthorizationRepositoryInterface $preConfiguredAuthorizationRepository
29
     */
30
    public function __construct(PreConfiguredAuthorizationRepositoryInterface $preConfiguredAuthorizationRepository)
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $preConfiguredAuthorizationRepository exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
31
    {
32
        $this->preConfiguredAuthorizationRepository = $preConfiguredAuthorizationRepository;
33
    }
34
35
    /**
36
     * @param RevokePreConfiguredAuthorizationCommand $command
37
     */
38
    public function handle(RevokePreConfiguredAuthorizationCommand $command)
39
    {
40
        $preConfiguredAuthorization = $this->preConfiguredAuthorizationRepository->find(
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $preConfiguredAuthorization exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
41
            $command->getUserAccountId(),
42
            $command->getClientId(),
43
            $command->getScopes(),
44
            $command->getResourceServerId()
45
        );
46
47
        if (null !== $preConfiguredAuthorization && !$preConfiguredAuthorization->isRevoked()) {
48
            $preConfiguredAuthorization = $preConfiguredAuthorization->markAsRevoked();
49
            $this->preConfiguredAuthorizationRepository->save($preConfiguredAuthorization);
50
        }
51
    }
52
}
53