BookRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 20
rs 10
ccs 0
cts 8
cp 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findByIsbn() 0 7 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\Book;
6
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
7
use Doctrine\Persistence\ManagerRegistry;
8
9
/**
10
 * @extends ServiceEntityRepository<Book>
11
 */
12
class BookRepository extends ServiceEntityRepository
13
{
14
    public function __construct(ManagerRegistry $registry)
15
    {
16
        parent::__construct($registry, Book::class);
17
    }
18
19
    /**
20
     * Find a book by ISBN.
21
     *
22
     * @param string $isbn ISBN of the book to find
23
     * @return Book|null Returns a Book object or null if not found
24
     */
25
    public function findByIsbn(string $isbn): ?Book
26
    {
27
        return $this->createQueryBuilder('b')
28
            ->andWhere('b.isbn = :isbn')
29
            ->setParameter('isbn', $isbn)
30
            ->getQuery()
31
            ->getOneOrNullResult()
32
        ;
33
    }
34
35
    //    /**
36
    //     * @return Book[] Returns an array of Book objects
37
    //     */
38
    //    public function findByExampleField($value): array
39
    //    {
40
    //        return $this->createQueryBuilder('b')
41
    //            ->andWhere('b.exampleField = :val')
42
    //            ->setParameter('val', $value)
43
    //            ->orderBy('b.id', 'ASC')
44
    //            ->setMaxResults(10)
45
    //            ->getQuery()
46
    //            ->getResult()
47
    //        ;
48
    //    }
49
50
    //    public function findOneBySomeField($value): ?Book
51
    //    {
52
    //        return $this->createQueryBuilder('b')
53
    //            ->andWhere('b.exampleField = :val')
54
    //            ->setParameter('val', $value)
55
    //            ->getQuery()
56
    //            ->getOneOrNullResult()
57
    //        ;
58
    //    }
59
}
60