TenantRepository::findDefaultTenant()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 13
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
1
<?php
2
namespace Vivait\AuthBundle\Entity;
3
4
use Symfony\Component\Security\Core\User\UserInterface;
5
use Symfony\Component\Security\Core\User\UserProviderInterface;
6
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
7
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
8
use Doctrine\ORM\EntityRepository;
9
use Doctrine\ORM\NoResultException;
10
11
class TenantRepository extends EntityRepository {
12
	private $default_tenant;
13
14
	public function findDefaultTenant() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
15
		if (!$this->default_tenant) {
16
			$this->default_tenant = $this->findOneBy([
17
				'code' => 'DEF'
18
			]);
19
			if (!$this->default_tenant) {
20
				$this->default_tenant = new Tenant('DEF', 'Default tenant');
21
			}
22
		}
23
24
25
		return $this->default_tenant;
26
	}
27
}
28
29
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
30