Token   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 9 2
A verify() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Authy;
6
7
class Token extends Client
8
{
9
    /**
10
     * Send verification token to the given Authy user.
11
     *
12
     * @param int         $authyId
13
     * @param string      $method
14
     * @param bool        $force
15
     * @param string|null $action
16
     * @param string|null $actionMessage
17
     *
18
     * @return \Rinvex\Authy\Response
19
     */
20
    public function send($authyId, $method = 'sms', $force = false, $action = null, $actionMessage = null): Response
21
    {
22
        // Prepare required variables
23
        $url = $this->api.$method."/{$authyId}";
24
        $params = $this->params + ['query' => ['force' => $force ? 'true' : 'false', 'action' => $action, 'actionMessage' => $actionMessage]];
25
26
        // Send Authy token, and return response
27
        return new Response($this->http->get($url, $params));
28
    }
29
30
    /**
31
     * Verify the given token for the given Authy user.
32
     *
33
     * @param int         $token
34
     * @param int         $authyId
35
     * @param bool        $force
36
     * @param string|null $action
37
     *
38
     * @return \Rinvex\Authy\Response
39
     */
40
    public function verify($token, $authyId, $force = false, $action = null): Response
41
    {
42
        // Prepare required variables
43
        $url = $this->api."verify/{$token}/{$authyId}";
44
        $params = $this->params + ['query' => ['force' => $force ? 'true' : 'false', 'action' => $action]];
45
46
        // Verify Authy token
47
        return new Response($this->http->get($url, $params));
48
    }
49
}
50