ConfigurationRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 14
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOrCreate() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Repository;
6
7
use Application\Model\Configuration;
8
9
/**
10
 * @extends AbstractRepository<Configuration>
11
 */
12
class ConfigurationRepository extends AbstractRepository
13
{
14
    /**
15
     * Get or create the configuration for the given key.
16
     */
17
    public function getOrCreate(string $key): Configuration
18
    {
19
        $configuration = $this->findOneByKey($key);
20
        if (!$configuration) {
21
            $configuration = new Configuration($key);
22
            $this->getEntityManager()->persist($configuration);
23
        }
24
25
        return $configuration;
26
    }
27
}
28