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

miaoxing / plugin / 3766633246

pending completion
3766633246

push

github

twinh
feat(plugin): `BasePage` 增加 `pageInit` 事件

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

84 existing lines in 24 files now uncovered.

902 of 2275 relevant lines covered (39.65%)

19.29 hits per line

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

69.23
/src/Model/ModelTrait.php
1
<?php
2

3
namespace Miaoxing\Plugin\Model;
4

5
use Miaoxing\Plugin\Resource\BaseResource;
6
use Wei\ModelTrait as BaseModelTrait;
7
use Wei\Ret;
8

9
trait ModelTrait
10
{
11
    use BaseModelTrait;
12

13
    /**
14
     * 返回当前对象
15
     *
16
     * @return $this
17
     * @deprecated 改用 $wei->get($modelName) 返回模型实例
18
     * @internal 用于兼容已有逻辑,待删除
19
     */
20
    public function __invoke(): self
21
    {
22
        return $this;
63✔
23
    }
24

25
    /**
26
     * Returns the success result with model data
27
     *
28
     * @param array|string|BaseResource|mixed $merge
29
     * @return Ret
30
     * @svc
31
     */
32
    protected function toRet($merge = []): Ret
33
    {
34
        if (is_array($merge)) {
9✔
35
            $data = $merge;
3✔
36
        } elseif ($merge instanceof BaseResource) {
6✔
37
            $data = $merge->toArray($this);
3✔
38
        } elseif (is_subclass_of($merge, BaseResource::class)) {
3✔
39
            $data = $merge::toArray($this);
3✔
40
        } else {
41
            throw new \InvalidArgumentException(sprintf(
×
UNCOV
42
                'Expected argument of type array, instance of BaseResource, or subclass of BaseReource, "%s" given',
×
43
                is_object($merge) ? get_class($merge) : gettype($merge)
×
44
            ));
45
        }
46

47
        if ($this->coll) {
9✔
48
            return $this->collToRet($data);
×
49
        } else {
50
            return $this->suc($data + ['data' => $this])->setMetadata('model', $this);
9✔
51
        }
52
    }
53
}
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