Passed
Pull Request — 1.11.x (#4549)
by Angel Fernando Quiroz
09:02
created

JWTClient::send()   B

Complexity

Conditions 11
Paths 21

Size

Total Lines 52
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 35
c 0
b 0
f 0
nc 21
nop 4
dl 0
loc 52
rs 7.3166

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\Zoom\API;
6
7
use Firebase\JWT\JWT;
8
9
/**
10
 * Class JWTClient.
11
 *
12
 * @see https://marketplace.zoom.us/docs/guides/auth/jwt
13
 */
14
class JWTClient extends Client
15
{
16
    use Api2RequestTrait;
17
18
    public $token;
19
20
    /**
21
     * JWTClient constructor.
22
     * Requires JWT app credentials.
23
     *
24
     * @param string $apiKey    JWT API Key
25
     * @param string $apiSecret JWT API Secret
26
     */
27
    public function __construct($apiKey, $apiSecret)
28
    {
29
        $this->token = JWT::encode(
30
            [
31
                'iss' => $apiKey,
32
                'exp' => (time() + 60) * 1000, // will expire in one minute
33
            ],
34
            $apiSecret
35
        );
36
        self::register($this);
37
    }
38
}
39