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

HorizonServiceBindings::getIterator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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