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

miaoxing / plugin / 3812753794

pending completion
3812753794

push

github

twinh
refactor: `wei()->user()` 改为 `UserModel`

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

36 existing lines in 2 files now uncovered.

901 of 2262 relevant lines covered (39.83%)

19.49 hits per line

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

66.67
/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
     * Returns the success result with model data
15
     *
16
     * @param array|string|BaseResource|mixed $merge
17
     * @return Ret
18
     * @svc
19
     */
20
    protected function toRet($merge = []): Ret
21
    {
22
        if (is_array($merge)) {
9✔
23
            $data = $merge;
3✔
24
        } elseif ($merge instanceof BaseResource) {
6✔
25
            $data = $merge->toArray($this);
3✔
26
        } elseif (is_subclass_of($merge, BaseResource::class)) {
3✔
27
            $data = $merge::toArray($this);
3✔
28
        } else {
UNCOV
29
            throw new \InvalidArgumentException(sprintf(
×
UNCOV
30
                'Expected argument of type array, instance of BaseResource, or subclass of BaseReource, "%s" given',
×
UNCOV
31
                is_object($merge) ? get_class($merge) : gettype($merge)
×
32
            ));
33
        }
34

35
        if ($this->coll) {
9✔
UNCOV
36
            return $this->collToRet($data);
×
37
        } else {
38
            return $this->suc($data + ['data' => $this])->setMetadata('model', $this);
9✔
39
        }
40
    }
41
}
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