Ready   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A execute() 0 8 2
1
<?php
2
3
namespace Nails\Analytics\Event\Listener\System;
4
5
use Nails\Analytics\Constants;
6
use Nails\Common\Events;
7
use Nails\Common\Events\Subscription;
8
use Nails\Common\Exception\NailsException;
9
use Nails\Factory;
10
use ReflectionException;
11
12
/**
13
 * Class Ready
14
 *
15
 * @package Nails\Analytics\Event\Listener\System
16
 */
17
class Ready extends Subscription
18
{
19
    /**
20
     * Ready constructor.
21
     *
22
     * @throws NailsException
23
     * @throws ReflectionException
24
     */
25
    public function __construct()
26
    {
27
        $this
28
            ->setEvent(Events::SYSTEM_READY)
29
            ->setNamespace(Events::getEventNamespace())
30
            ->setCallback([$this, 'execute']);
31
    }
32
33
    // --------------------------------------------------------------------------
34
35
    public function execute(): void
36
    {
37
        /** @var \Nails\Analytics\Service\Drivers $oDrivers */
38
        $oDrivers = Factory::service('Drivers', Constants::MODULE_SLUG);
39
        foreach ($oDrivers->getAll() as $oDriver) {
40
            /** @var \Nails\Analytics\Interfaces\Driver $oInstance */
41
            $oInstance = $oDrivers->getInstance($oDriver);
42
            $oInstance->boot();
43
        }
44
    }
45
}
46