Client::imageCensorComb()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 2
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the strays/baidu-ai.
5
 *
6
 * (c) strays <[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 Strays\BaiDuAi\Review\Image;
13
14
use Strays\BaiDuAi\Kernel\BaseClient;
15
use function Strays\BaiDuAi\Kernel\hasBase64;
16
17
class Client extends BaseClient
18
{
19
    /**
20
     * Gif 图片审核.
21
     *
22
     * @param string $base
23
     *
24
     * @return string
25
     */
26
    public function antiPornGif(string $base)
27
    {
28
        $body = [
29
            'image' => $base,
30
        ];
31
32
        return $this->httpPostFrom('/rest/2.0/antiporn/v1/detect_gif', $body);
33
    }
34
35
    /**
36
     * 用户头像审核.
37
     *
38
     * @param string $base
39
     *
40
     * @return string
41
     */
42
    public function faceAudit(string $base)
43
    {
44
        $body = [];
45
46
        if (hasBase64($base)) {
47
            $body['images'] = $base;
48
        } else {
49
            $body['imgUrls'] = urlencode($base);
50
        }
51
52
        return $this->httpPostFrom('/rest/2.0/solution/v1/face_audit', $body);
53
    }
54
55
    /**
56
     * 组合服务接口.
57
     *
58
     * @param string $base
59
     * @param string $scenes
60
     *
61
     * @return string
62
     */
63
    public function imageCensorComb(string $base, array $scenes = [])
64
    {
65
        $body = [];
66
67
        if (hasBase64($base)) {
68
            $body['images'] = $base;
69
        } else {
70
            $body['imgUrl'] = $base;
71
        }
72
73
        $body = array_merge($body, ['scenes' => $scenes]);
74
75
        return $this->httpPostJson('/api/v1/solution/direct/img_censor', $body);
76
    }
77
78
    /**
79
     * 自定义图像审核接口.
80
     *
81
     * @param string $base
82
     *
83
     * @return string
84
     */
85
    public function imageCensorUserDefined(string $base)
86
    {
87
        $body = [];
88
89
        if (hasBase64($base)) {
90
            $body['image'] = $base;
91
        } else {
92
            $body['imgUrl'] = $base;
93
        }
94
95
        return $this->httpPostFrom('/rest/2.0/solution/v1/img_censor/user_defined', $body);
96
    }
97
}
98