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

miaoxing / admin / 6668325895

27 Oct 2023 02:04PM UTC coverage: 28.897%. Remained the same
6668325895

push

github

twinh
feat(admin, experimental): `options` 接口支持使用 `.` 区分服务和选项

22 of 87 branches covered (0.0%)

0 of 2 new or added lines in 1 file covered. (0.0%)

7 existing lines in 1 file now uncovered.

165 of 571 relevant lines covered (28.9%)

2.1 hits per line

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

0.0
/pages/api/admin/options/index.php
1
<?php
2

3
use Miaoxing\App\Middleware\CheckPagePermission;
4
use Miaoxing\Plugin\BasePage;
5

6
return new /**
×
7
 * @experimental
8
 */
9
class () extends BasePage {
10
    public function init()
11
    {
12
        parent::init();
×
13
        $this->removeMiddleware(CheckPagePermission::class);
×
14
    }
15

16
    public function get($req)
17
    {
18
        $data = [];
×
19
        $ids = explode(',', (string) $req['id']);
×
20
        foreach ($ids as $id) {
×
NEW
21
            $separator = false !== strpos($id, '.') ? '.' : '-';
×
NEW
22
            [$name, $option] = explode($separator, $id);
×
23

UNCOV
24
            if (!$this->wei->has($name)) {
×
25
                return err('服务不存在');
×
26
            }
UNCOV
27
            $service = $this->wei->get($name);
×
28

UNCOV
29
            if (!property_exists($service, $option)) {
×
30
                return err(['选项 %s 不存在', $id]);
×
31
            }
32

UNCOV
33
            $property = new \ReflectionProperty($service, $option);
×
34
            if (!str_contains($property->getDocComment(), '@api')) {
×
35
                return err(['选项 %s 不存在', $id]);
×
36
            }
37

UNCOV
38
            $data[$id] = $service->getOption($option);
×
39
        }
40

UNCOV
41
        return suc([
×
42
            'data' => count($ids) > 1 ? $data : current($data),
×
43
        ]);
×
44
    }
UNCOV
45
};
×
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

© 2025 Coveralls, Inc