InstallSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 32
ccs 0
cts 14
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onInstall() 0 4 1
A __construct() 0 3 1
A getSubscribedEvents() 0 4 1
1
<?php
2
3
4
namespace Deployee\Plugins\DeployHistory\Subscriber;
5
6
use Deployee\Components\Persistence\LazyPDO;
7
use Deployee\Plugins\Install\Events\RunInstallCommandEvent;
8
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
9
10
class InstallSubscriber implements EventSubscriberInterface
11
{
12
    /**
13
     * @var LazyPDO $lazyPdo
14
     */
15
    private $lazyPdo;
16
17
    /**
18
     * @param LazyPDO $lazyPdo
19
     */
20
    public function __construct(LazyPDO $lazyPdo)
21
    {
22
        $this->lazyPdo = $lazyPdo;
23
    }
24
25
    /**
26
     * @return array
27
     */
28
    public static function getSubscribedEvents(): array
29
    {
30
        return [
31
            RunInstallCommandEvent::class => 'onInstall'
32
        ];
33
    }
34
35
    /**
36
     * @throws \PDOException
37
     */
38
    public function onInstall()
39
    {
40
        $installSql = file_get_contents(__DIR__ . '/../install/install.sql');
41
        $this->lazyPdo->exec($installSql);
42
    }
43
}