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

umbrellio / laravel-heavy-jobs / 4493340875

pending completion
4493340875

push

github

GitHub
Added support for Laravel 10 (#10)

139 of 182 relevant lines covered (76.37%)

16.43 hits per line

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

70.59
/src/Stores/StoreResolver.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Umbrellio\LaravelHeavyJobs\Stores;
6

7
use Closure;
8
use Illuminate\Contracts\Foundation\Application;
9
use InvalidArgumentException;
10

11
final class StoreResolver
12
{
13
    private $app;
14
    private $store;
15
    private $customDrivers = [];
16

17
    public function __construct(Application $app)
18
    {
19
        $this->app = $app;
42✔
20
    }
21

22
    public function resolve(): StoreInterface
23
    {
24
        return $this->store ?? $this->store = $this->getStore();
42✔
25
    }
26

27
    public function extend(string $name, Closure $callback): void
28
    {
29
        $this->customDrivers[$name] = $callback;
6✔
30
    }
31

32
    private function getStore(): StoreInterface
33
    {
34
        $driver = $this->app['config']['heavy-jobs']['driver'];
42✔
35
        $parameters = $this->app['config']['heavy-jobs']['parameters'];
42✔
36

37
        if (isset($this->customDrivers[$driver])) {
42✔
38
            $store = $this->customDrivers[$driver]($this->app, $parameters);
6✔
39
        } else {
40
            $class = sprintf('Umbrellio\\LaravelHeavyJobs\\Stores\\%sStore', ucfirst($driver));
36✔
41
            if (!class_exists($class)) {
36✔
42
                throw new InvalidArgumentException("Driver [{$driver}] is not supported.");
×
43
            }
44

45
            $store = $this->app->make($class, $parameters);
36✔
46
        }
47

48
        if (!$store instanceof StoreInterface) {
42✔
49
            throw new InvalidArgumentException(sprintf(
×
50
                'Store "%s" must be implements StoreInterface.',
×
51
                get_class($store)
×
52
            ));
×
53
        }
54

55
        return $store;
42✔
56
    }
57
}
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