• 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

91.67
/src/Command/PingCollectorCommand.php
1
<?php
2

3
namespace BugCatcher\Command;
4

5
use BugCatcher\Entity\RecordPing;
6
use BugCatcher\Repository\ProjectRepository;
7
use BugCatcher\Repository\RecordPingRepository;
8
use BugCatcher\Service\PingCollector\PingCollectorInterface;
9
use Symfony\Component\Console\Attribute\AsCommand;
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\DependencyInjection\Attribute\Autowire;
14
use Symfony\Component\HttpFoundation\Response;
15
use Symfony\Contracts\Service\ServiceSubscriberInterface;
16
use Throwable;
17

18
#[AsCommand(
19
        name: 'app:ping-collector',
20
)]
21
final class PingCollectorCommand extends Command implements ServiceSubscriberInterface
22
{
23
        public function __construct(
24
                private readonly array                $collectors,
25
                private readonly ProjectRepository    $projectRepo,
26
                private readonly RecordPingRepository $pingRecordRepo
27
        ) {
28
                parent::__construct();
7✔
29
        }
30

31

32
        protected function execute(InputInterface $input, OutputInterface $output): int {
33
                $projects = $this->projectRepo->findBy(["enabled" => true]);
7✔
34
                foreach ($projects as $project) {
7✔
35
                        /** @var PingCollectorInterface $collector */
36
                        $collector = $this->collectors[$project->getPingCollector()]??null;
7✔
37
                        if (!$collector) {
7✔
38
                                continue;
1✔
39
                        }
40
                        try {
41
                                $status = $collector->ping($project);
6✔
42
                        } catch (Throwable $e) {
1✔
43
                                $status = Response::HTTP_INTERNAL_SERVER_ERROR;
1✔
44
                        }
45
                        $this->pingRecordRepo->save(new RecordPing($project, $status), true);
6✔
46
                }
47

48
                return Command::SUCCESS;
7✔
49
        }
50

51
        public static function getSubscribedServices(): array {
52
                return [];
×
53
        }
54
}
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

© 2026 Coveralls, Inc