Passed
Push — master ( a2e0e2...47f272 )
by mingyoung
02:59
created

Client::upload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the mingyoung/dingtalk.
5
 *
6
 * (c) 张铭阳 <[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 EasyDingTalk\Media;
13
14
use EasyDingTalk\Kernel\BaseClient;
15
16
class Client extends BaseClient
17
{
18
    /**
19
     * 上传图片
20
     *
21
     * @param mixed $media
22
     *
23
     * @return mixed
24
     */
25
    public function uploadImage($media)
26
    {
27
        return $this->upload('image', $media);
28
    }
29
30
    /**
31
     * 上传语音
32
     *
33
     * @param mixed $media
34
     *
35
     * @return mixed
36
     */
37
    public function uploadVoice($media)
38
    {
39
        return $this->upload('voice', $media);
40
    }
41
42
    /**
43
     * 上传普通文件
44
     *
45
     * @param mixed $media
46
     *
47
     * @return mixed
48
     */
49
    public function uploadFile($media)
50
    {
51
        return $this->upload('file', $media);
52
    }
53
54
    /**
55
     * 上传媒体文件
56
     *
57
     * @param string $type
58
     * @param mixed  $media
59
     *
60
     * @return mixed
61
     */
62
    public function upload($type, $media)
63
    {
64
        return $this->client->upload('media/upload', ['media' => $media, 'type' => $type]);
65
    }
66
}
67