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

miaoxing / services / 6057036494

02 Sep 2023 07:10AM UTC coverage: 10.256%. Remained the same
6057036494

push

github

twinh
refactor: `tie` 改为 `assert` 方法

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

5 existing lines in 1 file now uncovered.

64 of 624 relevant lines covered (10.26%)

6.12 hits per line

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

18.18
/src/Action/BaseAction.php
1
<?php
2

3
namespace Miaoxing\Services\Action;
4

5
use ConventionMixin;
6
use Miaoxing\Plugin\BaseService;
7
use Miaoxing\Plugin\HandleRetTrait;
8
use ReqMixin;
9
use ResMixin;
10
use Wei\BaseController;
11
use Wei\Req;
12
use Wei\Ret;
13
use Wei\Wei;
14

15
/**
16
 * @mixin ConventionMixin
17
 * @mixin ReqMixin
18
 * @mixin ResMixin
19
 */
20
abstract class BaseAction extends BaseService
21
{
22
    use HandleRetTrait;
23

24
    protected static $createNewInstance = true;
25

26
    /**
27
     * @var array
28
     */
29
    private $events;
30

31
    /**
32
     * @param BaseController $controller
33
     * @return mixed
34
     * @svc
35
     */
36
    abstract protected function exec(BaseController $controller);
37

38
    /**
39
     * Create a new instance
40
     *
41
     * @return static
42
     */
43
    public static function new(): self
44
    {
UNCOV
45
        return Wei::getContainer()->getBy(static::class);
×
46
    }
47

48
    /**
49
     * Set the request service
50
     *
51
     * @param Req $req
52
     * @return $this
53
     * @svc
54
     */
55
    protected function setReq(Req $req)
56
    {
UNCOV
57
        $this->req = $req;
×
58
        return $this;
×
59
    }
60

61
    protected function on(string $name, callable $callable)
62
    {
63
        $this->events[$name] = $callable;
3✔
64
        return $this;
3✔
65
    }
66

67
    protected function trigger($name, $args)
68
    {
UNCOV
69
        if (isset($this->events[$name])) {
×
70
            return $this->events[$name](...$args);
×
71
        }
72
    }
73

74
    protected function triggerRet($name, $args)
75
    {
UNCOV
76
        $ret = $this->trigger($name, $args);
×
NEW
77
        if ($ret instanceof Ret) {
×
NEW
78
            $ret->assert();
×
79
        }
UNCOV
80
        return $ret;
×
81
    }
82
}
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