Completed
Push — master ( a6c8f9...b97be3 )
by Vladimir
03:52 queued 19s
created

FileCreationSubscriber::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\EventSubscriber;
9
10
use allejo\stakx\Compiler;
11
use allejo\stakx\Core\StakxLogger;
12
use allejo\stakx\Filesystem\FilesystemLoader as fs;
13
use Kwf\FileWatcher\Event\AbstractEvent;
14
use Kwf\FileWatcher\Event\Create;
15
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
16
17
class FileCreationSubscriber implements EventSubscriberInterface
18
{
19
    private $compiler;
20
    private $logger;
21
22
    public function __construct(Compiler $compiler, StakxLogger $logger)
23
    {
24
        $this->compiler = $compiler;
25
        $this->logger = $logger;
26
    }
27
28
    public function onFileCreation(AbstractEvent $event)
29
    {
30
        $relFilePath = fs::getRelativePath($event->filename);
31
        $this->logger->writeln(sprintf('File creation detected: %s', $relFilePath));
32
33
//        try
34
//        {
35
//
36
//        }
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public static function getSubscribedEvents()
43
    {
44
        return [
45
            Create::NAME => 'onFileCreation'
46
        ];
47
    }
48
}
49