Completed
Push — master ( 808f8c...952fde )
by Vladimir
11s
created

FileDeletionSubscriber::onFileDeletion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/**
4
 * @copyright 2018 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\Delete as DeleteEvent;
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
16 View Code Duplication
class FileDeletionSubscriber implements EventSubscriberInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    private $compiler;
19
    private $logger;
20
21
    public function __construct(Compiler $compiler, StakxLogger $logger)
22
    {
23
        $this->compiler = $compiler;
24
        $this->logger = $logger;
25
    }
26
27
    public function onFileDeletion(DeleteEvent $event)
28
    {
29
        $relFilePath = fs::getRelativePath($event->filename);
30
        $this->logger->writeln(sprintf('File deletion detected: %s', $relFilePath));
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public static function getSubscribedEvents()
37
    {
38
        return [
39
            DeleteEvent::NAME => 'onFileDeletion'
40
        ];
41
    }
42
}
43