• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

miaoxing / plugin / 7322930040

25 Dec 2023 04:02PM UTC coverage: 37.918% (-1.7%) from 39.661%
7322930040

push

github

twinh
ci: add PHP 8, remove PHP 7.2, 7.3

907 of 2392 relevant lines covered (37.92%)

5.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Service/Upload.php
1
<?php
2

3
namespace Miaoxing\Plugin\Service;
4

5
class Upload extends \Wei\Upload
6
{
7
    /**
8
     * 允许的图片类型的扩展名
9
     *
10
     * @var array
11
     */
12
    protected $allowedImageExts = [
13
        'jpg',
14
        'jpeg',
15
        'png',
16
        'bmp',
17
        'gif',
18
    ];
19

20
    /**
21
     * 各系统支持的音频类型的扩展名
22
     *
23
     * @var string[]
24
     * @link https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.html#%E6%94%AF%E6%8C%81%E6%A0%BC%E5%BC%8F
25
     */
26
    protected $allowedAudioExts = [
27
        'mp3',
28
        'm4a',
29
        'wav',
30
        'aac',
31
    ];
32

33
    /**
34
     * 获取图片的扩展名
35
     *
36
     * @svc
37
     */
38
    protected function getAllowedImageExts(): array
39
    {
40
        return $this->allowedImageExts;
×
41
    }
42

43
    /**
44
     * 检查扩展名是否为允许的图片类型
45
     *
46
     * @svc
47
     */
48
    protected function isAllowedImageExt(string $ext): bool
49
    {
50
        return in_array($ext, $this->allowedImageExts, true);
×
51
    }
52

53
    /**
54
     * 获取所有允许上传的文件扩展名
55
     *
56
     * @svc
57
     */
58
    protected function getAllowedExts(): array
59
    {
60
        return array_merge(
×
61
            $this->allowedImageExts,
×
62
            $this->allowedAudioExts
×
63
        );
×
64
    }
65

66
    /**
67
     * 上传图片文件
68
     *
69
     * @svc
70
     */
71
    protected function saveImage(array $options = []): \Wei\Ret
72
    {
73
        return $this->save($options + ['exts' => $this->getAllowedImageExts()]);
×
74
    }
75

76
    /**
77
     * 获取音频的扩展名
78
     *
79
     * @svc
80
     */
81
    protected function getAllowedAudioExts(): array
82
    {
83
        return $this->allowedAudioExts;
×
84
    }
85

86
    /**
87
     * 检查扩展名是否为允许的音频类型
88
     *
89
     * @svc
90
     */
91
    protected function isAllowedAudioExt(string $ext): bool
92
    {
93
        return in_array($ext, $this->allowedAudioExts, true);
×
94
    }
95

96
    /**
97
     * 上传音频文件
98
     *
99
     * @svc
100
     */
101
    protected function saveAudio(array $options = []): \Wei\Ret
102
    {
103
        return $this->save($options + ['exts' => $this->getAllowedAudioExts()]);
×
104
    }
105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc