Completed
Push — master ( d8c1e1...5eb403 )
by Carlos
03:50
created

Client::vehicleLicense()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyWeChat\OfficialAccount\OCR;
13
14
use EasyWeChat\Kernel\BaseClient;
15
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
16
17
/**
18
 * Class Client.
19
 *
20
 * @author joyeekk <[email protected]>
21
 */
22
class Client extends BaseClient
23
{
24
    /**
25
     * Allow image parameter type.
26
     *
27
     * @var array
28
     */
29
    protected $allowTypes = ['photo', 'scan'];
30
31
    /**
32
     * ID card OCR.
33
     *
34
     * @param string $type
35
     * @param string $path
36
     *
37
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
38
     */
39 1
    public function idCard(string $type, string $path)
40
    {
41 1
        if (!in_array($type, $this->allowTypes, true)) {
42 1
            throw new InvalidArgumentException(sprintf("Unsupported type: '%s'", $type));
43
        }
44
45 1
        return $this->httpGet('cv/ocr/idcard', [
46 1
            'type' => $type,
47 1
            'img_url' => $path,
48
        ]);
49
    }
50
51
    /**
52
     * Bank card OCR.
53
     *
54
     * @param string $path
55
     *
56
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
57
     */
58 1
    public function bankCard(string $path)
59
    {
60 1
        return $this->httpGet('cv/ocr/bankcard', [
61 1
            'img_url' => $path,
62
        ]);
63
    }
64
65
    /**
66
     * Vehicle license OCR.
67
     *
68
     * @param string $path
69
     *
70
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
71
     */
72 1
    public function vehicleLicense(string $path)
73
    {
74 1
        return $this->httpGet('cv/ocr/driving', [
75 1
            'img_url' => $path,
76
        ]);
77
    }
78
}
79