Code Duplication    Length = 24-29 lines in 3 locations

src/allejo/stakx/EventSubscriber/FileCreationSubscriber.php 1 location

@@ 17-45 (lines=29) @@
14
use Kwf\FileWatcher\Event\Create as CreateEvent;
15
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
16
17
class FileCreationSubscriber implements EventSubscriberInterface
18
{
19
    private $fileMapper;
20
    private $compiler;
21
    private $logger;
22
23
    public function __construct(Compiler $compiler, FileMapper $fileMapper, StakxLogger $logger)
24
    {
25
        $this->fileMapper = $fileMapper;
26
        $this->compiler = $compiler;
27
        $this->logger = $logger;
28
    }
29
30
    public function onFileCreation(CreateEvent $event)
31
    {
32
        $relFilePath = fs::getRelativePath($event->filename);
33
        $this->logger->writeln(sprintf('File creation detected: %s', $relFilePath));
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public static function getSubscribedEvents()
40
    {
41
        return [
42
            CreateEvent::NAME => 'onFileCreation',
43
        ];
44
    }
45
}
46

src/allejo/stakx/EventSubscriber/FileDeletionSubscriber.php 1 location

@@ 16-42 (lines=27) @@
13
use Kwf\FileWatcher\Event\Delete as DeleteEvent;
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
16
class FileDeletionSubscriber implements EventSubscriberInterface
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

src/allejo/stakx/EventSubscriber/FileModificationSubscriber.php 1 location

@@ 16-39 (lines=24) @@
13
use Kwf\FileWatcher\Event\Modify as ModifyEvent;
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
16
class FileModificationSubscriber implements EventSubscriberInterface
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 onFileModification(ModifyEvent $event)
28
    {
29
        $relFilePath = fs::getRelativePath($event->filename);
30
        $this->logger->writeln(sprintf('File change detected: %s', $relFilePath));
31
    }
32
33
    public static function getSubscribedEvents()
34
    {
35
        return [
36
            ModifyEvent::NAME => 'onFileModification'
37
        ];
38
    }
39
}
40