Token::find()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the PhpMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpMob\Omise\Api;
15
16
use PhpMob\Omise\Api;
17
use PhpMob\Omise\Domain\Token as Domain;
18
19
/**
20
 * @author Ishmael Doss <[email protected]>
21
 *
22
 * @see https://www.omise.co/tokens-api
23
 */
24
final class Token extends Api
25
{
26
    /**
27
     * @var bool
28
     */
29
    protected $isSensitive = true;
30
31
    /**
32
     * @param string $id
33
     *
34
     * @return Domain
35
     */
36 3
    public function find($id)
37
    {
38 3
        self::assertNotEmpty($id);
39
40 2
        return $this->doRequest('GET', '/tokens/' . $id);
41
    }
42
43
    /**
44
     * @param Domain $token
45
     */
46 1
    public function refresh(Domain $token)
47
    {
48 1
        $token->updateStore($this->find($token->id)->toArray());
49 1
    }
50
51
    /**
52
     * @param Domain $token
53
     */
54 1
    public function create(Domain $token)
55
    {
56 1
        $token->updateStore($this->doRequest('POST', '/tokens', $token->getCreateData())->toArray());
57 1
    }
58
}
59