Completed
Push — 2.x ( ed04a7...fe437f )
by Cy
01:45
created

HorizonServiceBindings   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getIterator() 0 4 1
1
<?php
2
3
namespace Monospice\LaravelRedisSentinel\Horizon;
4
5
use ArrayIterator;
6
use IteratorAggregate;
7
use Laravel\Horizon\ServiceBindings;
8
9
/**
10
 * Provides the set of Horizon services that depend on the application's Redis
11
 * service so we can replace the dependencies with the package's Redis Sentinel
12
 * connection manager if needed.
13
 *
14
 * @category Package
15
 * @package  Monospice\LaravelRedisSentinel
16
 * @author   Cy Rossignol <[email protected]>
17
 * @license  See LICENSE file
18
 * @link     https://github.com/monospice/laravel-redis-sentinel-drivers
19
 */
20
class HorizonServiceBindings implements IteratorAggregate
21
{
22
    // Conveniently, Horizon provides a trait that declares each of the services
23
    // that it registers with the application container. As long as this trait
24
    // exists, we can use it to find the services that need the Sentinel manager
25
    // dependency injected.
26
    //
27
    // This trait adds the public $serviceBindings property to the service
28
    // provider. We could access this property from the formal Horizon service
29
    // provider, but we'll re-declare it here in case the package's service
30
    // provider loads before Horizon's provider.
31
    use ServiceBindings;
32
33
    /**
34
     * Get an iterator for the service bindings so we can iterate over an
35
     * instance of this class.
36
     *
37
     * @return ArrayIterator
38
     */
39
    public function getIterator()
40
    {
41
        return new ArrayIterator($this->serviceBindings);
42
    }
43
}
44