• 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

61.54
/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)) {
3✔
23
            $data = $merge;
1✔
24
        } elseif ($merge instanceof BaseResource) {
2✔
25
            $data = $merge->toArray($this);
1✔
26
        } elseif (is_subclass_of($merge, BaseResource::class)) {
1✔
27
            $data = $merge::toArray($this);
1✔
28
        } else {
29
            throw new \InvalidArgumentException(sprintf(
×
30
                'Expected argument of type array, instance of BaseResource, or subclass of BaseReource, "%s" given',
×
31
                is_object($merge) ? get_class($merge) : gettype($merge)
×
32
            ));
×
33
        }
34

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