Passed
Push — develop ( 7ff764...a20136 )
by BENARD
05:11 queued 02:32
created

UserRepository::save()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace ProjetNormandie\UserBundle\Repository;
4
5
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
6
use Doctrine\Persistence\ManagerRegistry;
7
use ProjetNormandie\UserBundle\Entity\User;
8
9
class UserRepository extends ServiceEntityRepository
10
{
11
    public function __construct(ManagerRegistry $registry)
12
    {
13
        parent::__construct($registry, User::class);
14
    }
15
16
    /**
17
     * @param $q
18
     * @return mixed
19
     */
20
    public function autocomplete($q): mixed
21
    {
22
        $query = $this->createQueryBuilder('u');
23
24
        $query
25
            ->where('u.username LIKE :q')
26
            ->setParameter('q', '%' . $q . '%')
27
            //->andWhere('u.enabled = 1')
28
            ->orderBy('u.username', 'ASC');
29
30
        return $query->getQuery()->getResult();
31
    }
32
33
    /**
34
     * @param $object
35
     * @return void
36
     */
37
    public function save($object): void
38
    {
39
        $this->_em->persist($object);
0 ignored issues
show
Bug Best Practice introduced by
The property _em does not exist on ProjetNormandie\UserBund...pository\UserRepository. Did you maybe forget to declare it?
Loading history...
40
        $this->_em->flush();
41
    }
42
43
44
    public function flush(): void
45
    {
46
        $this->_em->flush();
0 ignored issues
show
Bug Best Practice introduced by
The property _em does not exist on ProjetNormandie\UserBund...pository\UserRepository. Did you maybe forget to declare it?
Loading history...
47
    }
48
}
49