NotifyProcessing   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 20.59 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 2
cbo 3
dl 14
loc 68
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A componentVerifyTicket() 0 8 1
A Authorized() 7 7 1
A UpdateAuthorized() 7 7 1
A UnAuthorized() 0 14 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace OpenOauth;
4
5
use OpenOauth\Core\Core;
6
7
class NotifyProcessing extends Core
8
{
9
    /**
10
     * componentVerifyTicket
11
     *
12
     * @param $xml_array
13
     *
14
     * @return mixed
15
     */
16
    public function componentVerifyTicket($xml_array)
17
    {
18
        $key = 'component_verify_ticket:' . $xml_array['AppId'];
19
        self::$cacheDriver->_set($key, $xml_array['ComponentVerifyTicket'], 0);
20
        $component_verify_ticket = $xml_array['ComponentVerifyTicket'];
21
22
        return $component_verify_ticket;
23
    }
24
25
    /**
26
     * Authorized
27
     *
28
     * @param $xml_array
29
     *
30
     * @return mixed
31
     */
32 View Code Duplication
    public function Authorized($xml_array)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        $key = 'authorized:' . $xml_array['AppId'] . ':' . $xml_array['AuthorizerAppid'];
35
        self::$databaseDriver->_set($key, $xml_array);
36
37
        return $xml_array;
38
    }
39
40
    /**
41
     * UpdateAuthorized
42
     *
43
     * @param $xml_array
44
     *
45
     * @return mixed
46
     */
47 View Code Duplication
    public function UpdateAuthorized($xml_array)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $key = 'authorized:' . $xml_array['AppId'] . ':' . $xml_array['AuthorizerAppid'];
50
        self::$databaseDriver->_set($key, $xml_array);
51
52
        return $xml_array;
53
    }
54
55
    /**
56
     * @param $xml_array
57
     *
58
     * @return mixed
59
     */
60
    public function UnAuthorized($xml_array)
61
    {
62
        $key = 'query_auth:' . $this->configs->component_app_id . ':' . $xml_array['AuthorizerAppid'];
63
64
        $query_auth_info = self::$databaseDriver->_get($key);
65
66
        if (!empty($query_auth_info)) {
67
            $query_auth_info['authorization_state'] = 'unauthorized';
68
69
            self::$databaseDriver->_set($key, $query_auth_info);
70
        }
71
72
        return $xml_array;
73
    }
74
}