• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

php-bug-catcher / bug-catcher / 11534267277

26 Oct 2024 07:05PM UTC coverage: 87.486% (-3.3%) from 90.754%
11534267277

push

github

tito10047
fixed timezone in tests

804 of 919 relevant lines covered (87.49%)

6.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.0
/src/EventSubscriber/RecordLogSubscriber.php
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Jozef Môstka
5
 * Date: 14. 7. 2024
6
 * Time: 21:01
7
 */
8
namespace BugCatcher\EventSubscriber;
9

10
use ApiPlatform\Symfony\EventListener\EventPriorities;
11
use BugCatcher\Entity\NotifierFavicon;
12
use BugCatcher\Entity\Record;
13
use BugCatcher\Entity\RecordLog;
14
use BugCatcher\Entity\RecordPing;
15
use BugCatcher\Enum\Importance;
16
use BugCatcher\Enum\RecordEventType;
17
use BugCatcher\Event\RecordEvent;
18
use BugCatcher\Event\RecordRecordedEvent;
19
use BugCatcher\Repository\RecordRepository;
20
use BugCatcher\Service\RecordLogWithholder;
21
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
22
use Symfony\Component\EventDispatcher\EventDispatcher;
23
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
24
use Symfony\Component\HttpFoundation\Request;
25
use Symfony\Component\HttpFoundation\Response;
26
use Symfony\Component\HttpKernel\Event\ViewEvent;
27
use Symfony\Component\HttpKernel\KernelEvents;
28
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
29

30
final class RecordLogSubscriber implements EventSubscriberInterface
31
{
32

33

34
        public function __construct(
35
                private readonly RecordLogWithholder      $withholder,
36
                private readonly EventDispatcherInterface $dispatcher
37
        ) {}
31✔
38

39
        public static function getSubscribedEvents() {
40
                return [
×
41
                        KernelEvents::VIEW => ['process', EventPriorities::POST_WRITE],
×
42
                ];
×
43
        }
44

45
        public function process(ViewEvent $event): void {
46
                $record = $event->getControllerResult();
31✔
47
                $method = $event->getRequest()->getMethod();
31✔
48

49
                if ($record instanceof RecordLog && Request::METHOD_POST == $method) {
31✔
50
                        $this->withholder->process($record);
16✔
51
                }
52
                if ($record instanceof Record && Request::METHOD_POST == $method) {
31✔
53
                        $this->dispatcher->dispatch(new RecordEvent($record, RecordEventType::CREATED, [$record->getProject()]));
17✔
54
                }
55
        }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc