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

php-bug-catcher / bug-catcher / 11066135309

27 Sep 2024 07:05AM UTC coverage: 86.646% (-0.4%) from 87.07%
11066135309

push

github

tito10047
Fix #14

3 of 8 new or added lines in 2 files covered. (37.5%)

837 of 966 relevant lines covered (86.65%)

13.37 hits per line

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

23.53
/src/Repository/RecordPingRepository.php
1
<?php
2

3
namespace BugCatcher\Repository;
4

5
use BugCatcher\Entity\Project;
6
use BugCatcher\Entity\Record;
7
use BugCatcher\Entity\RecordPing;
8
use DateTime;
9
use DateTimeInterface;
10
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
11
use Doctrine\ORM\QueryBuilder;
12
use Doctrine\Persistence\ManagerRegistry;
13
use Symfony\Bridge\Doctrine\Types\UuidType;
14
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15

16
/**
17
 * @extends ServiceEntityRepository<RecordPing>
18
 *
19
 * @method RecordPing|null find($id, $lockMode = null, $lockVersion = null)
20
 * @method RecordPing|null findOneBy(array $criteria, array $orderBy = null)
21
 * @method RecordPing[]    findAll()
22
 * @method RecordPing[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
23
 */
24
final class RecordPingRepository extends ServiceEntityRepository implements RecordRepositoryInterface
25
{
26
    public function __construct(
27
        ManagerRegistry $registry,
28
        EventDispatcherInterface $dispatcher,
29
        private readonly RecordRepositoryInterface $recordRepository,
30
    ) {
31
        parent::__construct($registry, RecordPing::class);
7✔
32
    }
33

34
    public function save(RecordPing $entity, bool $flush = false): void
35
    {
36
        $this->getEntityManager()->persist($entity);
6✔
37

38
        if ($flush) {
6✔
39
            $this->getEntityManager()->flush();
6✔
40
        }
41
    }
42

43

44
    public function getQBWith(Project $project): QueryBuilder
45
    {
NEW
46
        $qb = $this->createQueryBuilder('r');
×
47

NEW
48
        $qb->andWhere('r.project = :project')
×
NEW
49
            ->setParameter('project', $project->getId(), UuidType::NAME);
×
50

NEW
51
        return $qb;
×
52
    }
53

54
    public function getLastRecord(Project $project, string $maxLife = '-1 hour'): ?RecordPing
55
    {
56
        return $this->getQBWith(project: $project)
×
57
            ->andWhere("r.date >= :date")
×
58
            ->orderBy('r.date', 'DESC')
×
59
            ->setParameter('date', new DateTime($maxLife))
×
60
            ->setMaxResults(1)
×
61
            ->getQuery()
×
62
            ->getOneOrNullResult();
×
63
    }
64

65

66
    public function setStatusBetween(
67
        array $projects,
68
        DateTimeInterface $from,
69
        DateTimeInterface $to,
70
        string $newStatus,
71
        string $previousStatus = 'new',
72
        callable $qbCreator = null
73
    ): void {
74
        $this->recordRepository->setStatusBetween($projects, $from, $to, $newStatus, $previousStatus, $qbCreator);
×
75
    }
76

77
    public function setStatus(
78
        Record $log,
79
        DateTimeInterface $lastDate,
80
        string $newStatus,
81
        string $previousStatus = 'new',
82
        bool $flush = false,
83
        callable $qbCreator = null
84
    ) {
85
        $this->recordRepository->setStatus($log, $lastDate, $newStatus, $previousStatus, $flush, $qbCreator);
×
86
    }
87
}
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