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

mpyw / laravel-local-class-scope / 13674049511

05 Mar 2025 10:36AM UTC coverage: 100.0%. Remained the same
13674049511

push

github

web-flow
chore: 🤖 Bump version (#9)

11 of 11 relevant lines covered (100.0%)

26.91 hits per line

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

100.0
/src/ScopedMacro.php
1
<?php
2

3
namespace Mpyw\LaravelLocalClassScope;
4

5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Scope;
7
use InvalidArgumentException;
8

9
/**
10
 * Class ScopedMacro
11
 */
12
class ScopedMacro
13
{
14
    /**
15
     * @var \Illuminate\Database\Eloquent\Builder
16
     */
17
    protected $query;
18

19
    /**
20
     * ScopedMacro constructor.
21
     *
22
     * @param \Illuminate\Database\Eloquent\Builder $query
23
     */
24
    public function __construct(Builder $query)
25
    {
26
        $this->query = $query;
32✔
27
    }
28

29
    /**
30
     * Apply Scope to Eloquent\Builder.
31
     *
32
     * @param  \Illuminate\Database\Eloquent\Scope|string $scope
33
     * @param  mixed                                      ...$parameters
34
     * @return \Illuminate\Database\Eloquent\Builder
35
     */
36
    public function __invoke($scope, ...$parameters): Builder
37
    {
38
        if (is_string($scope) && class_exists($scope)) {
32✔
39
            $scope = new $scope(...$parameters);
16✔
40
        }
41
        if (!$scope instanceof Scope) {
32✔
42
            throw new InvalidArgumentException('$scope must be an instance of Scope');
8✔
43
        }
44

45
        $scope->apply($this->query, $this->query->getModel());
24✔
46

47
        return $this->query;
24✔
48
    }
49
}
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

© 2026 Coveralls, Inc