TenantRepository::initializeTenant()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AtlassianConnectBundle\Repository;
6
7
use AtlassianConnectBundle\Entity\TenantInterface;
8
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
9
use Doctrine\Persistence\ManagerRegistry;
10
11
final class TenantRepository extends ServiceEntityRepository implements TenantRepositoryInterface
12
{
13
    public function __construct(ManagerRegistry $registry, private string $tenantClass)
14
    {
15
        parent::__construct($registry, $tenantClass);
16
    }
17
18
    public function findById($id): ?TenantInterface
19
    {
20
        return $this->findOneBy(['id' => $id]);
21
    }
22
23
    public function findByClientKey(string $clientKey): ?TenantInterface
24
    {
25
        return $this->findOneBy(['clientKey' => $clientKey]);
26
    }
27
28
    public function save(TenantInterface $tenant): void
29
    {
30
        $this->getEntityManager()->persist($tenant);
31
        $this->getEntityManager()->flush();
32
    }
33
34
    public function initializeTenant(): TenantInterface
35
    {
36
        return new $this->tenantClass();
37
    }
38
}
39