Passed
Push — master ( b4cb9f...51bac7 )
by Anthony
02:22
created

AccountRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A findAllUserArchived() 0 10 1
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
use PiouPiou\RibsAdminBundle\Entity\User;
7
8
class AccountRepository extends EntityRepository
9
{
10
	/**
11
	 * @param User $current_account
12
	 * @param bool $archived
13
	 * @return array function that return a list of all users that are not archived and different of current accout
14
	 */
15
	public function findAllUserArchived(User $current_account, bool $archived = false): array
16
	{
17
		$query = $this->getEntityManager()->createQuery("SELECT fu FROM RibsAdminBundle:Account fu
18
			  JOIN RibsAdminBundle:User u  WITH fu.user = u
19
			  WHERE u.archived = :archived and u != :current_account
20
			")
21
			->setParameter("archived", $archived)
22
			->setParameter("current_account", $current_account);
23
		
24
		return $query->getResult();
25
	}
26
}