BookRepository::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
ccs 0
cts 2
cp 0
crap 2
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