Token::send()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 5
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
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